Skip to content
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

Parse conditional multi #2437

Merged
merged 22 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2a2e2b8
Store index with extracted prover functions.
chriseth Jan 31, 2025
f74ed40
Add prover function call as new effect.
chriseth Jan 29, 2025
908650c
Introduce enum ProverFunctionCall.
chriseth Jan 31, 2025
38ed098
Process prover functions.
chriseth Jan 31, 2025
dcdf6a7
Filter out uses of prover functions for now.
chriseth Jan 31, 2025
795b78f
Merge remote-tracking branch 'origin/main' into process_prover_functions
chriseth Jan 31, 2025
80b310c
Merge remote-tracking branch 'origin/main' into process_prover_functions
chriseth Feb 3, 2025
ab3fb80
Merge remote-tracking branch 'origin/main' into process_prover_functions
chriseth Feb 3, 2025
e2a4674
Re-structure prover functions.
chriseth Feb 3, 2025
1a211f1
Merge branch 're-structure-prover-functions' into process_prover_func…
chriseth Feb 3, 2025
7efc4d7
Compute multiple cell values conditionally from other cell values.
chriseth Feb 3, 2025
6e92315
Review comments.
chriseth Feb 4, 2025
450005a
Merge remote-tracking branch 'origin/main' into process_prover_functions
chriseth Feb 4, 2025
060ef82
Merge branch 'process_prover_functions' into parse_conditional_multi
chriseth Feb 4, 2025
fa089eb
Parse conditional multi prover functions.
chriseth Feb 4, 2025
057fc71
Merge remote-tracking branch 'origin/main' into parse_conditional_multi
chriseth Feb 4, 2025
1b7e3b4
rest of parsing.
chriseth Feb 4, 2025
05c6b0d
processing
chriseth Feb 4, 2025
f0d1df1
remove todo
chriseth Feb 4, 2025
d758f17
clippy
chriseth Feb 4, 2025
82d0455
Update executor/src/witgen/jit/witgen_inference.rs
chriseth Feb 5, 2025
8120c51
Merge remote-tracking branch 'origin/main' into parse_conditional_multi
chriseth Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion executor/src/witgen/jit/block_machine_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ params[3] = main_binary::C[3];"
assert_eq!(
format_code(&code),
"Sub::a[0] = params[0];
Sub::b[0] = prover_function_0(0, [Sub::a[0]]);
[Sub::b[0]] = prover_function_0(0, [Sub::a[0]]);
params[1] = Sub::b[0];"
);
}
Expand Down
6 changes: 3 additions & 3 deletions executor/src/witgen/jit/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,15 @@ fn format_effect<T: FieldElement>(effect: &Effect<T, Variable>, is_top_level: bo
)
}
Effect::ProverFunctionCall(ProverFunctionCall {
target,
targets,
function_index,
row_offset,
inputs,
}) => {
format!(
"{}{} = prover_function_{function_index}(row_offset + {row_offset}, &[{}]);",
"{}[{}] = prover_function_{function_index}(row_offset + {row_offset}, &[{}]);",
if is_top_level { "let " } else { "" },
variable_to_string(target),
targets.iter().map(variable_to_string).format(", "),
inputs.iter().map(variable_to_string).format(", ")
)
}
Expand Down
19 changes: 10 additions & 9 deletions executor/src/witgen/jit/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ impl<T: FieldElement> Effect<T, Variable> {
.zip_eq(known)
.flat_map(|(v, known)| (!known).then_some((v, true))),
),
Effect::ProverFunctionCall(ProverFunctionCall { target, .. }) => {
Box::new(iter::once((target, false)))
Effect::ProverFunctionCall(ProverFunctionCall { targets, .. }) => {
Box::new(targets.iter().map(|v| (v, false)))
}
Effect::Branch(_, first, second) => {
Box::new(first.iter().chain(second).flat_map(|e| e.written_vars()))
Expand All @@ -63,9 +63,9 @@ impl<T: FieldElement, V: Hash + Eq> Effect<T, V> {
Box::new(lhs.referenced_symbols().chain(rhs.referenced_symbols()))
}
Effect::MachineCall(_, _, args) => Box::new(args.iter()),
Effect::ProverFunctionCall(ProverFunctionCall { target, inputs, .. }) => {
Box::new(iter::once(target).chain(inputs))
}
Effect::ProverFunctionCall(ProverFunctionCall {
targets, inputs, ..
}) => Box::new(targets.iter().chain(inputs)),
Effect::Branch(branch_condition, first, second) => Box::new(
iter::once(&branch_condition.variable).chain(
[first, second]
Expand Down Expand Up @@ -123,8 +123,8 @@ pub struct BranchCondition<T: FieldElement, V> {

#[derive(Clone, PartialEq, Eq)]
pub struct ProverFunctionCall<V> {
/// Which variable to assign the result to.
pub target: V,
/// Which variables to assign the result to.
pub targets: Vec<V>,
/// The index of the prover function in the list.
pub function_index: usize,
/// The row offset to supply to the prover function.
Expand Down Expand Up @@ -166,13 +166,14 @@ pub fn format_code<T: FieldElement>(effects: &[Effect<T, Variable>]) -> String {
panic!("Range constraints should not be part of the code.")
}
Effect::ProverFunctionCall(ProverFunctionCall {
target,
targets,
function_index,
row_offset,
inputs,
}) => {
format!(
"{target} = prover_function_{function_index}({row_offset}, [{}]);",
"[{}] = prover_function_{function_index}({row_offset}, [{}]);",
targets.iter().join(", "),
inputs.iter().join(", ")
)
}
Expand Down
4 changes: 2 additions & 2 deletions executor/src/witgen/jit/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Processor<'a, T: FieldElement, FixedEval> {
identities: Vec<(&'a Identity<T>, i32)>,
/// The prover functions, i.e. helpers to compute certain values that
/// we cannot easily determine.
prover_functions: Vec<(ProverFunction<'a>, i32)>,
prover_functions: Vec<(ProverFunction<'a, T>, i32)>,
/// The size of a block.
block_size: usize,
/// If the processor should check for correctly stackable block shapes.
Expand Down Expand Up @@ -99,7 +99,7 @@ impl<'a, T: FieldElement, FixedEval: FixedEvaluator<T>> Processor<'a, T, FixedEv

pub fn with_prover_functions(
mut self,
prover_functions: Vec<(ProverFunction<'a>, i32)>,
prover_functions: Vec<(ProverFunction<'a, T>, i32)>,
) -> Self {
assert!(self.prover_functions.is_empty());
self.prover_functions = prover_functions;
Expand Down
Loading
Loading