in crates/ratchet-core/src/storage/cpu_buffer.rs [171:193]
fn dump(&self, dtype: DType, full: bool) -> String {
let bytes = self.inner().as_bytes();
fn dump_inner<T: TensorDType>(data: &[T], full: bool) -> String {
let length = if data.len() < 64 { data.len() } else { 64 };
if full {
format!("{:?}", data)
} else {
format!(
"{:?} ... {:?}",
&data[..length],
&data[data.len() - length..]
)
}
}
match dtype {
DType::F32 => dump_inner(bytemuck::cast_slice::<u8, f32>(bytes), full),
DType::I32 => dump_inner(bytemuck::cast_slice::<u8, i32>(bytes), full),
DType::U32 => dump_inner(bytemuck::cast_slice::<u8, u32>(bytes), full),
DType::F16 => dump_inner(bytemuck::cast_slice::<u8, f16>(bytes), full),
dt => format!("[{:?} dump not yet supported]", dt),
}
}