Skip to content

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-mainardi committed Sep 27, 2023
1 parent 6c091c5 commit 5c44c9c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions plonky2/src/gadgets/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
// handle chunks that can fill all the slots of a `LookupGate`
lookup_iter.for_each(|chunk| {
let row = self.add_gate(gate.clone(), vec![]);
for (i,(looking_in, looking_out)) in chunk.iter().enumerate() {
for (i, (looking_in, looking_out)) in chunk.iter().enumerate() {
let gate_in = Target::wire(row, LookupGate::wire_ith_looking_inp(i));
let gate_out = Target::wire(row, LookupGate::wire_ith_looking_out(i));
self.connect(gate_in, *looking_in);
self.connect(gate_out, *looking_out);
}
});
// deal with the last chunk
for (_,(looking_in, looking_out)) in last_chunk.iter().enumerate() {
for (_, (looking_in, looking_out)) in last_chunk.iter().enumerate() {
let (gate, i) =
self.find_slot(gate.clone(), &[F::from_canonical_usize(lut_index)], &[]);
let gate_in = Target::wire(gate, LookupGate::wire_ith_looking_inp(i));
Expand Down
28 changes: 15 additions & 13 deletions plonky2/src/lookup_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,9 @@ fn test_big_lut() -> anyhow::Result<()> {
let config = CircuitConfig::standard_recursion_config();
let mut builder = CircuitBuilder::<F, D>::new(config);

const LUT_SIZE: usize = u16::MAX as usize +1;
const LUT_SIZE: usize = u16::MAX as usize + 1;
let inputs: [u16; LUT_SIZE] = core::array::from_fn(|i| i as u16);
let lut_fn = |inp: u16| inp/10;
let lut_fn = |inp: u16| inp / 10;
let lut_index = builder.add_lookup_table_from_fn(lut_fn, &inputs);

let initial_a = builder.add_virtual_target();
Expand Down Expand Up @@ -536,16 +536,18 @@ fn test_many_lookups_on_big_lut() -> anyhow::Result<()> {
let config = CircuitConfig::standard_recursion_config();
let mut builder = CircuitBuilder::<F, D>::new(config);

const LUT_SIZE: usize = u16::MAX as usize +1;
const LUT_SIZE: usize = u16::MAX as usize + 1;
let inputs: [u16; LUT_SIZE] = core::array::from_fn(|i| i as u16);
let lut_fn = |inp: u16| inp/10;
let lut_fn = |inp: u16| inp / 10;
let lut_index = builder.add_lookup_table_from_fn(lut_fn, &inputs);

let inputs = (0..LUT_SIZE).map(|_| {
let input_target = builder.add_virtual_target();
_ = builder.add_lookup_from_index(input_target, lut_index);
input_target
}).collect::<Vec<_>>();
let inputs = (0..LUT_SIZE)
.map(|_| {
let input_target = builder.add_virtual_target();
_ = builder.add_lookup_from_index(input_target, lut_index);
input_target
})
.collect::<Vec<_>>();

let initial_a = builder.add_virtual_target();
let initial_b = builder.add_virtual_target();
Expand All @@ -563,9 +565,10 @@ fn test_many_lookups_on_big_lut() -> anyhow::Result<()> {

let mut pw = PartialWitness::new();

inputs.into_iter().enumerate().for_each(|(i,t)|
pw.set_target(t, F::from_canonical_usize(i))
);
inputs
.into_iter()
.enumerate()
.for_each(|(i, t)| pw.set_target(t, F::from_canonical_usize(i)));
pw.set_target(initial_a, F::from_canonical_u16(look_val_a));
pw.set_target(initial_b, F::from_canonical_u16(look_val_b));

Expand All @@ -576,7 +579,6 @@ fn test_many_lookups_on_big_lut() -> anyhow::Result<()> {
);

data.verify(proof)

}

fn init_logger() -> anyhow::Result<()> {
Expand Down

0 comments on commit 5c44c9c

Please sign in to comment.