pub struct Statistics {
pub computed_mask: StatisticsMask,
pub nnz: u64,
pub sparsity_ratio: f64,
pub value_min: f64,
pub value_max: f64,
pub value_abs_max: f64,
pub value_mean: f64,
pub value_stddev: f64,
pub nm_n: u8,
pub nm_m: u8,
pub has_nan: bool,
pub has_inf: bool,
}Expand description
Advisory statistics about a tensor’s data buffer.
Statistics reflect the tensor data at write time. A reader MUST NOT rely on any statistic for correctness — they are optimization hints only (algorithm selection, memory pre-allocation, routing decisions).
Each group of fields is guarded by a bit in computed_mask. A reader MUST
check the relevant bit via StatisticsMask before using any field.
Note: derives PartialEq but NOT Eq — f64 NaN semantics make Eq unsound.
§Examples
use hurray_core::descriptor::{Statistics, StatisticsMask};
let stats = Statistics {
computed_mask: StatisticsMask(StatisticsMask::NNZ_VALID),
nnz: 42,
sparsity_ratio: 0.0,
value_min: 0.0,
value_max: 0.0,
value_abs_max: 0.0,
value_mean: 0.0,
value_stddev: 0.0,
nm_n: 0,
nm_m: 0,
has_nan: false,
has_inf: false,
};
assert!(stats.computed_mask.nnz_valid());
assert_eq!(stats.nnz, 42);Fields§
§computed_mask: StatisticsMaskBitmask indicating which fields contain valid data.
nnz: u64Number of non-zero elements. Valid when NNZ_VALID is set.
sparsity_ratio: f64Fraction of zero elements [0.0, 1.0]. Valid when SPARSITY_VALID is set.
value_min: f64Minimum element value (dequantized). Valid when VALUE_RANGE_VALID is set.
value_max: f64Maximum element value (dequantized). Valid when VALUE_RANGE_VALID is set.
value_abs_max: f64Maximum absolute element value. Valid when VALUE_RANGE_VALID is set.
value_mean: f64Arithmetic mean of all elements. Valid when VALUE_STATS_VALID is set.
value_stddev: f64Population standard deviation. Valid when VALUE_STATS_VALID is set.
nm_n: u8N in N:M structured sparsity. Valid when NM_SPARSITY_VALID is set.
nm_m: u8M in N:M structured sparsity. Valid when NM_SPARSITY_VALID is set.
has_nan: booltrue if at least one NaN element is present. Valid when NAN_INF_VALID is set.
has_inf: booltrue if at least one infinity is present. Valid when NAN_INF_VALID is set.
Trait Implementations§
Source§impl Clone for Statistics
impl Clone for Statistics
Source§fn clone(&self) -> Statistics
fn clone(&self) -> Statistics
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Statistics
impl Debug for Statistics
Source§impl PartialEq for Statistics
impl PartialEq for Statistics
Source§fn eq(&self, other: &Statistics) -> bool
fn eq(&self, other: &Statistics) -> bool
self and other values to be equal, and is used by ==.