Skip to content

Commit

Permalink
slight clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalancea committed Dec 10, 2024
1 parent 3af1ef1 commit e13ef15
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 20 deletions.
1 change: 0 additions & 1 deletion ceno_zkvm/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ pub trait Instruction<E: ExtensionField> {
}
.max(1);
let lk_multiplicity = LkMultiplicity::default();
// dbg!(steps.len(), num_witin);
let mut raw_witin =
RowMajorMatrix::<E::BaseField>::new(steps.len(), num_witin, Self::padding_strategy());
let raw_witin_iter = raw_witin.par_batch_iter_mut(num_instance_per_batch);
Expand Down
2 changes: 0 additions & 2 deletions ceno_zkvm/src/tables/ops/ops_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ impl OpTableConfig {
num_fixed: usize,
content: Vec<[u64; 3]>,
) -> RowMajorMatrix<F> {
//dbg!(content.len(), num_fixed);
let mut fixed =
RowMajorMatrix::<F>::new(content.len(), num_fixed, InstancePaddingStrategy::Zero);

Expand All @@ -71,7 +70,6 @@ impl OpTableConfig {
multiplicity: &HashMap<u64, usize>,
length: usize,
) -> Result<RowMajorMatrix<F>, ZKVMError> {
//dbg!(length, num_witin);
let mut witness =
RowMajorMatrix::<F>::new(length, num_witin, InstancePaddingStrategy::Zero);

Expand Down
4 changes: 0 additions & 4 deletions ceno_zkvm/src/tables/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ impl<E: ExtensionField> TableCircuit<E> for ProgramTableCircuit<E> {
let pc_base = program.base_address;
assert!(num_instructions <= config.program_size);

// dbg!(config.program_size, num_fixed);
let mut fixed = RowMajorMatrix::<E::BaseField>::new(
config.program_size,
num_fixed,
Expand All @@ -181,7 +180,6 @@ impl<E: ExtensionField> TableCircuit<E> for ProgramTableCircuit<E> {
}
});

// Self::padding_zero(&mut fixed, num_fixed).expect("padding error");
fixed
}

Expand All @@ -199,7 +197,6 @@ impl<E: ExtensionField> TableCircuit<E> for ProgramTableCircuit<E> {
prog_mlt[i] = *mlt;
}

// dbg!(config.program_size, num_witin);
let mut witness = RowMajorMatrix::<E::BaseField>::new(
config.program_size,
num_witin,
Expand All @@ -213,7 +210,6 @@ impl<E: ExtensionField> TableCircuit<E> for ProgramTableCircuit<E> {
set_val!(row, config.mlt, E::BaseField::from(mlt as u64));
});

// Self::padding_zero(&mut witness, num_witin).expect("padding error");
Ok(witness)
}
}
Expand Down
2 changes: 0 additions & 2 deletions ceno_zkvm/src/tables/ram/ram_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ impl<NVRAM: NonVolatileTable + Send + Sync + Clone> NonVolatileTableConfig<NVRAM
NVRAM::len(&self.params)
);

//dbg!(NVRAM::len(&self.params), num_fixed);
let mut init_table = RowMajorMatrix::<F>::new(
NVRAM::len(&self.params),
num_fixed,
Expand Down Expand Up @@ -389,7 +388,6 @@ impl<DVRAM: DynVolatileRamTable + Send + Sync + Clone> DynVolatileRamTableConfig
) -> Result<RowMajorMatrix<F>, ZKVMError> {
assert!(final_mem.len() <= DVRAM::max_len(&self.params));
assert!(DVRAM::max_len(&self.params).is_power_of_two());
//dbg!(final_mem.len(), num_witness);
let mut final_table =
RowMajorMatrix::<F>::new(final_mem.len(), num_witness, InstancePaddingStrategy::Zero);

Expand Down
2 changes: 0 additions & 2 deletions ceno_zkvm/src/tables/range/range_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl RangeTableConfig {
num_fixed: usize,
content: Vec<u64>,
) -> RowMajorMatrix<F> {
//dbg!(content.len(), num_fixed);
let mut fixed =
RowMajorMatrix::<F>::new(content.len(), num_fixed, InstancePaddingStrategy::Zero);

Expand All @@ -64,7 +63,6 @@ impl RangeTableConfig {
multiplicity: &HashMap<u64, usize>,
length: usize,
) -> Result<RowMajorMatrix<F>, ZKVMError> {
//dbg!(length, num_witin);
let mut witness =
RowMajorMatrix::<F>::new(length, num_witin, InstancePaddingStrategy::Zero);

Expand Down
15 changes: 6 additions & 9 deletions ceno_zkvm/src/witness.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use ff::Field;
use itertools::Itertools;
use std::{
array,
cell::RefCell,
Expand All @@ -13,7 +12,7 @@ use std::{

use multilinear_extensions::mle::{DenseMultilinearExtension, IntoMLE};
use rayon::{
iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator},
iter::{IntoParallelIterator, ParallelIterator},
slice::ParallelSliceMut,
};
use thread_local::ThreadLocal;
Expand Down Expand Up @@ -49,7 +48,6 @@ pub struct RowMajorMatrix<T: Sized + Sync + Clone + Send + Copy> {

impl<T: Sized + Sync + Clone + Send + Copy + Default> RowMajorMatrix<T> {
pub fn new(num_rows: usize, num_col: usize, padding_strategy: InstancePaddingStrategy) -> Self {
// assert!(false);
RowMajorMatrix {
values: (0..num_rows * num_col)
.into_par_iter()
Expand Down Expand Up @@ -90,23 +88,22 @@ impl<F: Field> RowMajorMatrix<F> {
self,
) -> Vec<DenseMultilinearExtension<E>> {
let padding_row = match self.padding_strategy {
// If asked to repeat and actually have content to repeat
// Repeat last row if it exists
InstancePaddingStrategy::RepeatLast if !self.values.is_empty() => {
self.values[self.values.len() - self.num_col..].to_vec()
}
// Otherwise zeros
// Otherwise use zeroes
_ => vec![F::ZERO; self.num_col],
};
let num_padding = self.num_padding_instances();
let result = (0..self.num_col)
.collect_vec()
.par_iter()
.into_par_iter()
.map(|i| {
self.values
.iter()
.skip(*i)
.skip(i)
.step_by(self.num_col)
.chain(&mut iter::repeat(&padding_row[*i]).take(num_padding))
.chain(&mut iter::repeat(&padding_row[i]).take(num_padding))
.copied()
.collect::<Vec<_>>()
.into_mle()
Expand Down

0 comments on commit e13ef15

Please sign in to comment.