pub struct QuantizedTensor {
pub data: Vec<u8>,
pub scales: Vec<f32>,
pub zero_points: Option<Vec<f32>>,
pub scales_quantized: Option<Vec<u8>>,
pub scales_scales: Option<Vec<f32>>,
pub shape: Vec<usize>,
pub block_size: usize,
pub double_quant_enabled: bool,
pub strategy: QuantizationStrategy,
}Expand description
A quantized tensor with scale factors.
Fields§
§data: Vec<u8>Packed 4-bit values (2 values per byte).
scales: Vec<f32>Scale factors per block.
zero_points: Option<Vec<f32>>Zero points per block (for asymmetric quantization).
scales_quantized: Option<Vec<u8>>Quantized scales (when double quantization is used).
scales_scales: Option<Vec<f32>>Scale factors for the scales (when double quantization is used).
shape: Vec<usize>Original shape.
block_size: usizeBlock size used for quantization.
double_quant_enabled: boolWhether double quantization was applied.
strategy: QuantizationStrategyQuantization strategy used.
Implementations§
Source§impl QuantizedTensor
impl QuantizedTensor
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Get the memory size in bytes.
Sourcepub fn compression_ratio(&self) -> f64
pub fn compression_ratio(&self) -> f64
Get the compression ratio relative to FP32 format.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QuantizedTensor
impl RefUnwindSafe for QuantizedTensor
impl Send for QuantizedTensor
impl Sync for QuantizedTensor
impl Unpin for QuantizedTensor
impl UnwindSafe for QuantizedTensor
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more