mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-10 09:43:09 +00:00
Optimize evaluate_gate_constraints_recurively
This commit is contained in:
parent
702eab1583
commit
7271af823b
@ -3,7 +3,6 @@ use num::Integer;
|
||||
use crate::field::extension_field::target::ExtensionTarget;
|
||||
use crate::field::extension_field::Extendable;
|
||||
use crate::field::field_types::Field;
|
||||
use crate::gates::arithmetic::ArithmeticExtensionGate;
|
||||
use crate::gates::gate::PrefixedGate;
|
||||
use crate::iop::target::Target;
|
||||
use crate::plonk::circuit_builder::CircuitBuilder;
|
||||
@ -242,6 +241,7 @@ pub fn evaluate_gate_constraints_recursively<F: Extendable<D>, const D: usize>(
|
||||
vars: EvaluationTargets<D>,
|
||||
) -> Vec<ExtensionTarget<D>> {
|
||||
let mut constraints = vec![builder.zero_extension(); num_gate_constraints];
|
||||
let mut all_gate_constraints: Vec<Vec<_>> = Vec::new();
|
||||
for gate in gates {
|
||||
let gate_constraints = with_context!(
|
||||
builder,
|
||||
@ -251,9 +251,16 @@ pub fn evaluate_gate_constraints_recursively<F: Extendable<D>, const D: usize>(
|
||||
.eval_filtered_recursively(builder, vars, &gate.prefix)
|
||||
);
|
||||
for (i, c) in gate_constraints.into_iter().enumerate() {
|
||||
constraints[i] = builder.add_extension(constraints[i], c);
|
||||
if i < all_gate_constraints.len() {
|
||||
all_gate_constraints[i].push(c);
|
||||
} else {
|
||||
all_gate_constraints.push(vec![c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i, v) in all_gate_constraints.into_iter().enumerate() {
|
||||
constraints[i] = builder.add_many_extension(&v);
|
||||
}
|
||||
constraints
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user