mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-04-20 18:43:07 +00:00
Move shorten in find_tree
This commit is contained in:
parent
bae3777bcd
commit
eee3026eee
@ -69,14 +69,12 @@ impl<F: Extendable<D>, const D: usize> Tree<GateRef<F, D>> {
|
|||||||
let max_degree = 1 << max_degree_bits;
|
let max_degree = 1 << max_degree_bits;
|
||||||
for max_constants in 1..100 {
|
for max_constants in 1..100 {
|
||||||
if let Some(mut best_tree) = Self::find_tree(&gates, max_degree, max_constants) {
|
if let Some(mut best_tree) = Self::find_tree(&gates, max_degree, max_constants) {
|
||||||
best_tree.shorten();
|
|
||||||
let mut best_num_constants = best_tree.num_constants();
|
let mut best_num_constants = best_tree.num_constants();
|
||||||
let mut best_degree = max_degree;
|
let mut best_degree = max_degree;
|
||||||
// Iterate backwards from `max_degree` to try to find a tree with a lower degree
|
// Iterate backwards from `max_degree` to try to find a tree with a lower degree
|
||||||
// but the same number of constants.
|
// but the same number of constants.
|
||||||
'optdegree: for degree in (0..max_degree).rev() {
|
'optdegree: for degree in (0..max_degree).rev() {
|
||||||
if let Some(mut tree) = Self::find_tree(&gates, degree, max_constants) {
|
if let Some(mut tree) = Self::find_tree(&gates, degree, max_constants) {
|
||||||
tree.shorten();
|
|
||||||
let num_constants = tree.num_constants();
|
let num_constants = tree.num_constants();
|
||||||
if num_constants > best_num_constants {
|
if num_constants > best_num_constants {
|
||||||
break 'optdegree;
|
break 'optdegree;
|
||||||
@ -108,6 +106,7 @@ impl<F: Extendable<D>, const D: usize> Tree<GateRef<F, D>> {
|
|||||||
for g in gates {
|
for g in gates {
|
||||||
tree.try_add_gate(g, max_degree, max_constants)?;
|
tree.try_add_gate(g, max_degree, max_constants)?;
|
||||||
}
|
}
|
||||||
|
tree.shorten();
|
||||||
Some(tree)
|
Some(tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user