pub struct Quantization {
pub scale: f32,
pub zero_point: i32,
}Expand description
Describes the quantization parameters for a tensor
Fields§
§scale: f32§zero_point: i32Implementations§
Source§impl Quantization
impl Quantization
Sourcepub fn new(scale: f32, zero_point: i32) -> Self
pub fn new(scale: f32, zero_point: i32) -> Self
Creates a new Quantization struct
§Examples
let quant = Quantization::new(0.1, -128);
assert_eq!(quant.scale, 0.1);
assert_eq!(quant.zero_point, -128);Sourcepub fn identity() -> Self
pub fn identity() -> Self
Returns a quantization that’s a no-op: scale=1.0, zero_point=0.
Used by the per-scale pipeline as a sentinel for float-to-float passthrough cells where no affine transform is required.
§Examples
let quant = Quantization::identity();
assert_eq!(quant.scale, 1.0);
assert_eq!(quant.zero_point, 0);Trait Implementations§
Source§impl Clone for Quantization
impl Clone for Quantization
Source§fn clone(&self) -> Quantization
fn clone(&self) -> Quantization
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Quantization
impl Debug for Quantization
Source§impl Default for Quantization
impl Default for Quantization
Source§impl<S, Z> From<(S, Z)> for Quantization
impl<S, Z> From<(S, Z)> for Quantization
Source§impl From<QuantTuple> for Quantization
impl From<QuantTuple> for Quantization
Source§fn from(quant_tuple: QuantTuple) -> Quantization
fn from(quant_tuple: QuantTuple) -> Quantization
Creates a new Quantization struct from a QuantTuple
§Examples
let quant_tuple = QuantTuple(0.1_f32, -128_i32);
let quant = Quantization::from(quant_tuple);
assert_eq!(quant.scale, 0.1);
assert_eq!(quant.zero_point, -128);Source§impl PartialEq for Quantization
impl PartialEq for Quantization
Source§fn eq(&self, other: &Quantization) -> bool
fn eq(&self, other: &Quantization) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for Quantization
impl StructuralPartialEq for Quantization
Auto Trait Implementations§
impl Freeze for Quantization
impl RefUnwindSafe for Quantization
impl Send for Quantization
impl Sync for Quantization
impl Unpin for Quantization
impl UnsafeUnpin for Quantization
impl UnwindSafe for Quantization
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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