pub struct CompressedData<T: Float + Debug + ScalarOperand + Send + Sync + 'static> {
pub shape: Vec<usize>,
pub codes: Vec<u8>,
pub quantization_min: f64,
pub quantization_step: f64,
pub original_size: usize,
pub compressed_size: usize,
/* private fields */
}Expand description
A quantized tensor.
The payload is codes (one u8 per element) plus the affine dequantization
parameters. The old version of this struct stored data: Vec<T> — the
uncompressed input — while advertising a halved compressed_size.
Fields§
§shape: Vec<usize>Original tensor shape (2-D).
codes: Vec<u8>Quantization codes, row-major.
quantization_min: f64Value the zero code maps to.
quantization_step: f64Value increment per code step (0 for a constant tensor).
original_size: usizeBytes the uncompressed tensor occupied.
compressed_size: usizeBytes this payload occupies, counted for real.
Implementations§
Source§impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> CompressedData<T>
impl<T: Float + Debug + ScalarOperand + Send + Sync + 'static> CompressedData<T>
Sourcepub fn compression_ratio(&self) -> f64
pub fn compression_ratio(&self) -> f64
Achieved compression ratio compressed_size / original_size.
A measurement, not the configured target: for f64 input this is
roughly 1/8 plus metadata, and for f32 roughly 1/4.
Sourcepub fn max_reconstruction_error(&self) -> f64
pub fn max_reconstruction_error(&self) -> f64
Worst-case absolute reconstruction error, quantization_step / 2.
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Number of quantized elements.
Trait Implementations§
Source§impl<T: Clone + Float + Debug + ScalarOperand + Send + Sync + 'static> Clone for CompressedData<T>
impl<T: Clone + Float + Debug + ScalarOperand + Send + Sync + 'static> Clone for CompressedData<T>
Auto Trait Implementations§
impl<T> Freeze for CompressedData<T>where
PhantomData<T>: Freeze,
impl<T> RefUnwindSafe for CompressedData<T>where
PhantomData<T>: RefUnwindSafe,
impl<T> Send for CompressedData<T>where
PhantomData<T>: Send,
impl<T> Sync for CompressedData<T>where
PhantomData<T>: Sync,
impl<T> Unpin for CompressedData<T>where
PhantomData<T>: Unpin,
impl<T> UnsafeUnpin for CompressedData<T>where
PhantomData<T>: UnsafeUnpin,
impl<T> UnwindSafe for CompressedData<T>where
PhantomData<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.