use crate::math::common::AlignedVec;
#[derive(Debug, Clone, Copy, Default)]
pub struct DiagnosticConfig {
pub capture_condition_dsp: bool,
pub capture_head_per_layer: bool,
pub capture_final_output: bool,
}
#[derive(Debug, Clone)]
pub struct ConditionDspSnapshot {
pub channels: usize,
pub num_frames: usize,
pub data: AlignedVec<f32>,
}
#[derive(Debug, Clone)]
pub struct HeadPerLayerSnapshot {
pub layer: usize,
pub accum_size: usize,
pub num_frames: usize,
pub head_wp: usize,
pub data: AlignedVec<f32>,
}
#[derive(Debug, Clone)]
pub struct DiagnosticDump {
pub total_frames: usize,
pub condition_dsp_snapshots: Vec<ConditionDspSnapshot>,
pub head_per_layer_snapshots: Vec<HeadPerLayerSnapshot>,
pub final_output: Option<AlignedVec<f32>>,
}
impl DiagnosticDump {
pub fn new(total_frames: usize) -> Self {
Self {
total_frames,
condition_dsp_snapshots: Vec::new(),
head_per_layer_snapshots: Vec::new(),
final_output: None,
}
}
pub fn bit_stable_hash(&self) -> u64 {
let mut h: u64 = self.total_frames as u64;
for snap in &self.condition_dsp_snapshots {
h = h.wrapping_add(snap.channels as u64);
h = h.wrapping_add(snap.num_frames as u64);
for &v in snap.data.iter() {
h = h.wrapping_add(v.to_bits() as u64);
}
}
for snap in &self.head_per_layer_snapshots {
h = h.wrapping_add(snap.layer as u64);
h = h.wrapping_add(snap.accum_size as u64);
h = h.wrapping_add(snap.num_frames as u64);
for &v in snap.data.iter() {
h = h.wrapping_add(v.to_bits() as u64);
}
}
if let Some(ref out) = self.final_output {
for &v in out.iter() {
h = h.wrapping_add(v.to_bits() as u64);
}
}
h
}
}