#[non_exhaustive]pub struct QuantizedWeightInfo {
pub name: String,
pub bits: u8,
pub scales: Vec<f32>,
pub zero_points: Vec<i8>,
pub original_length: usize,
pub storage_bytes: usize,
}Expand description
Metadata about a quantized weight recovered from a QDQ-format model.
Marked #[non_exhaustive] so future fields can be added without a
breaking change.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringOriginal weight name (without _quantized suffix).
bits: u8Quantization bit width (4 or 8).
scales: Vec<f32>Quantization scales. len() == 1 for per-tensor quantization;
len() == num_channels for per-channel.
zero_points: Vec<i8>Quantization zero points. Same length as scales.
original_length: usizeNumber of elements in the quantized tensor.
storage_bytes: usizeActual on-disk byte count of the quantized initializer’s raw_data.
For INT8 storage this equals original_length; for native INT4
(opset 21) it is ceil(original_length / 2).
Implementations§
Source§impl QuantizedWeightInfo
impl QuantizedWeightInfo
Sourcepub fn is_per_channel(&self) -> bool
pub fn is_per_channel(&self) -> bool
true if the weight was quantized per-channel (more than one scale).
Sourcepub fn scale(&self) -> Option<f32>
pub fn scale(&self) -> Option<f32>
Per-tensor convenience accessor: returns the first scale, or None
if no scales were recovered for this weight (malformed model).
For per-channel tensors, iterate over scales instead.
Sourcepub fn zero_point(&self) -> Option<i8>
pub fn zero_point(&self) -> Option<i8>
Per-tensor convenience accessor: returns the first zero-point, or
None if no zero-points were recovered (malformed model).
For per-channel tensors, iterate over zero_points instead.
Trait Implementations§
Source§impl Clone for QuantizedWeightInfo
impl Clone for QuantizedWeightInfo
Source§fn clone(&self) -> QuantizedWeightInfo
fn clone(&self) -> QuantizedWeightInfo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for QuantizedWeightInfo
impl RefUnwindSafe for QuantizedWeightInfo
impl Send for QuantizedWeightInfo
impl Sync for QuantizedWeightInfo
impl Unpin for QuantizedWeightInfo
impl UnsafeUnpin for QuantizedWeightInfo
impl UnwindSafe for QuantizedWeightInfo
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
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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