proof_stream/viz/
circuit.rs1use crate::events::{CircuitNodeMeta, LayerKind, ProofEvent};
7
8#[derive(Debug, Clone)]
12pub struct CircuitLayerDesc {
13 pub layer_idx: usize,
14 pub node_id: usize,
15 pub kind: LayerKind,
16 pub input_shape: (usize, usize),
17 pub output_shape: (usize, usize),
18 pub trace_cost: usize,
20 pub input_layers: Vec<usize>,
22}
23
24pub fn circuit_compiled_event(
26 layers: &[CircuitLayerDesc],
27 total_layers: usize,
28 input_shape: (usize, usize),
29 output_shape: (usize, usize),
30) -> ProofEvent {
31 let nodes: Vec<CircuitNodeMeta> = layers
32 .iter()
33 .map(|l| CircuitNodeMeta {
34 layer_idx: l.layer_idx,
35 node_id: l.node_id,
36 kind: l.kind,
37 input_shape: l.input_shape,
38 output_shape: l.output_shape,
39 trace_cost: l.trace_cost,
40 input_layers: l.input_layers.clone(),
41 })
42 .collect();
43
44 ProofEvent::CircuitCompiled {
45 total_layers,
46 input_shape,
47 output_shape,
48 nodes,
49 has_simd: false,
50 simd_num_blocks: 0,
51 }
52}
53
54pub fn matmul_trace_cost(m: usize, k: usize, n: usize) -> usize {
57 let raw = m * k * n;
58 raw.next_power_of_two()
59}