-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default pipeline with backend arguments #2557
Open
qwang98
wants to merge
3
commits into
pilopt-two-pass
Choose a base branch
from
split-with-backend
base: pilopt-two-pass
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,14 +97,14 @@ impl<R: io::Read> AsIoRead for Option<R> { | |
} | ||
|
||
/// Optional Arguments for various stages of the pipeline. | ||
#[derive(Default, Clone)] | ||
#[derive(Clone)] | ||
struct Arguments<T: FieldElement> { | ||
/// Externally computed witness values for witness generation. | ||
external_witness_values: Vec<(String, Vec<T>)>, | ||
/// Callback for queries for witness generation. | ||
query_callback: Option<Arc<dyn QueryCallback<T>>>, | ||
/// Backend to use for proving. If None, proving will fail. | ||
backend: Option<BackendType>, | ||
/// Backend to use for proving. Defaults to Mock Backend. | ||
backend: BackendType, | ||
/// Backend options | ||
backend_options: BackendOptions, | ||
/// Linker options | ||
|
@@ -127,6 +127,29 @@ struct Arguments<T: FieldElement> { | |
existing_proof_file: Option<PathBuf>, | ||
} | ||
|
||
impl<T> Default for Arguments<T> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would then go away |
||
where | ||
T: FieldElement, | ||
{ | ||
fn default() -> Self { | ||
Arguments { | ||
external_witness_values: vec![], | ||
query_callback: None, | ||
backend: BackendType::Mock, // the only non-default value | ||
backend_options: Default::default(), | ||
linker_params: Default::default(), | ||
csv_render_mode: Default::default(), | ||
export_witness_csv: false, | ||
export_all_columns_csv: false, | ||
setup_file: None, | ||
pkey_file: None, | ||
vkey_file: None, | ||
vkey_app_file: None, | ||
existing_proof_file: None, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct Pipeline<T: FieldElement> { | ||
/// Stores all artifacts at the same time. | ||
|
@@ -363,19 +386,17 @@ impl<T: FieldElement> Pipeline<T> { | |
self | ||
} | ||
|
||
pub fn with_backend(mut self, backend: BackendType, options: Option<BackendOptions>) -> Self { | ||
self.arguments.backend = Some(backend); | ||
self.arguments.backend_options = options.unwrap_or_default(); | ||
pub fn with_backend_factory(mut self, backend: BackendType) -> Self { | ||
self.arguments.backend = backend; | ||
self.artifact.backend = None; | ||
self | ||
} | ||
|
||
pub fn with_backend_if_none(&mut self, backend: BackendType, options: Option<BackendOptions>) { | ||
if self.arguments.backend.is_none() { | ||
self.arguments.backend = Some(backend); | ||
self.arguments.backend_options = options.unwrap_or_default(); | ||
self.artifact.backend = None; | ||
} | ||
pub fn with_backend(mut self, backend: BackendType, options: Option<BackendOptions>) -> Self { | ||
self.arguments.backend = backend; | ||
self.arguments.backend_options = options.unwrap_or_default(); | ||
self.artifact.backend = None; | ||
self | ||
} | ||
|
||
pub fn with_setup_file(mut self, setup_file: Option<PathBuf>) -> Self { | ||
|
@@ -998,7 +1019,7 @@ impl<T: FieldElement> Pipeline<T> { | |
|
||
self.compute_optimized_pil()?; | ||
|
||
let backend_type = self.arguments.backend.expect("no backend selected!"); | ||
let backend_type = self.arguments.backend; | ||
|
||
// If backend option is set, compute and cache the backend-tuned pil in artifacts and return backend-tuned pil. | ||
let optimized_pil = self.artifact.optimized_pil.clone().unwrap(); | ||
|
@@ -1140,7 +1161,7 @@ impl<T: FieldElement> Pipeline<T> { | |
let pil = self.compute_backend_tuned_pil()?; // will panic if backend type is not set yet | ||
let fixed_cols = self.compute_fixed_cols()?; | ||
|
||
let backend = self.arguments.backend.expect("no backend selected!"); | ||
let backend = self.arguments.backend; | ||
let factory = backend.factory::<T>(); | ||
|
||
// Opens the setup file, if set. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not implement default on backend and keep this?