Skip to main content

CompressionMetrics

Struct CompressionMetrics 

Source
pub struct CompressionMetrics {
    pub n_parameters: u64,
    pub original_bits_per_param: f32,
    pub effective_bits_per_param: f32,
    pub sparsity: f32,
    pub quantization_mse: f32,
}
Expand description

Compression statistics for a single layer or entire model.

Fields§

§n_parameters: u64

Number of parameters.

§original_bits_per_param: f32

Bit-width of the original (full-precision) representation.

§effective_bits_per_param: f32

Effective bit-width used in the compressed representation. For quantized weights this equals quant_bits; for pruned weights the effective bits = quant_bits × (1 − sparsity).

§sparsity: f32

Fraction of weights that are pruned ∈ [0, 1].

§quantization_mse: f32

Mean squared quantization error (0 if no quantization was applied).

Implementations§

Source§

impl CompressionMetrics

Source

pub fn quantized_only( n_parameters: u64, quant_bits: u32, quant_mse: f32, ) -> Self

Create metrics for a layer quantized to quant_bits bits with no pruning.

Source

pub fn pruned_only(n_parameters: u64, sparsity: f32) -> Self

Create metrics for a layer pruned to sparsity with FP32 weights.

Source

pub fn quantized_and_pruned( n_parameters: u64, quant_bits: u32, sparsity: f32, quant_mse: f32, ) -> Self

Create metrics for a layer that is both quantized and pruned.

Source

pub fn compression_ratio(&self) -> f32

Ratio of original to compressed storage: original_bits / effective_bits.

Returns f32::INFINITY if the effective bits per param is 0.

Source

pub fn total_original_bits(&self) -> f64

Total original bits for this layer.

Source

pub fn total_compressed_bits(&self) -> f64

Total compressed bits for this layer.

Trait Implementations§

Source§

impl Clone for CompressionMetrics

Source§

fn clone(&self) -> CompressionMetrics

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompressionMetrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CompressionMetrics

Source§

fn default() -> CompressionMetrics

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.