From a42bd839b851c4c35e6e6e844df411cf4b081b4e Mon Sep 17 00:00:00 2001 From: Ohad Agadi Date: Mon, 23 Dec 2024 13:15:15 +0200 Subject: [PATCH] trace to evals --- crates/air_utils/src/trace/iterable_trace.rs | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/air_utils/src/trace/iterable_trace.rs b/crates/air_utils/src/trace/iterable_trace.rs index 836175da2..6c64d5be5 100644 --- a/crates/air_utils/src/trace/iterable_trace.rs +++ b/crates/air_utils/src/trace/iterable_trace.rs @@ -4,10 +4,11 @@ use bytemuck::{cast_slice, Zeroable}; use itertools::Itertools; use rayon::iter::plumbing::{bridge, Consumer, Producer, ProducerCallback, UnindexedConsumer}; use rayon::prelude::*; +use stwo_prover::core::backend::simd::column::BaseColumn; use stwo_prover::core::backend::simd::m31::{PackedM31, N_LANES}; use stwo_prover::core::backend::simd::SimdBackend; use stwo_prover::core::fields::m31::M31; -use stwo_prover::core::poly::circle::CircleEvaluation; +use stwo_prover::core::poly::circle::{CanonicCoset, CircleEvaluation}; use stwo_prover::core::poly::BitReversedOrder; /// A 2D Matrix of [`PackedM31`] values. @@ -51,8 +52,8 @@ use stwo_prover::core::poly::BitReversedOrder; pub struct IterableTrace { data: [Vec; N], - /// Number of M31 rows in each column. - length: usize, + /// Log number of M31 rows in each column. + log_size: u32, } impl IterableTrace { @@ -60,7 +61,7 @@ impl IterableTrace { let length = 1 << log_size; let n_simd_elems = length / N_LANES; let data = [(); N].map(|_| vec![PackedM31::zeroed(); n_simd_elems]); - Self { data, length } + Self { data, log_size } } /// # Safety @@ -70,12 +71,8 @@ impl IterableTrace { todo!() } - pub fn len(&self) -> usize { - self.length - } - - pub fn is_empty(&self) -> bool { - self.length == 0 + pub fn log_size(&self) -> u32 { + self.log_size } pub fn iter_mut(&mut self) -> RowIterMut<'_, N> { @@ -101,11 +98,18 @@ impl IterableTrace { } pub fn to_evals(self) -> [CircleEvaluation; N] { - todo!() + let domain = CanonicCoset::new(self.log_size).circle_domain(); + self.data.map(|column| { + let eval = BaseColumn { + data: column, + length: 1 << self.log_size, + }; + CircleEvaluation::::new(domain, eval) + }) } pub fn pretty_print(&self, row_limit: usize) -> String { - assert!(row_limit <= self.len()); + assert!(row_limit <= 1 << self.log_size); let cpu_trace: Vec<&[u32]> = self .data .iter()