pub enum QParams {
PerTensor {
scale: f32,
zero_point: i32,
},
PerChannel {
axis: usize,
scales: Vec<f32>,
zero_points: Vec<i32>,
},
PerGroup {
axis: usize,
group_size: usize,
scales: Vec<f32>,
zero_points: Vec<i32>,
},
}Expand description
Quantization parameters describing how a quantized tensor can be inverted.
Per-channel and group-wise schemes need one scale/zero-point pair per
channel (or per group); collapsing them to a single pair — as the legacy
(Tensor, f32, i32) return type is forced to do — makes dequantization
impossible for every channel but the first. QuantizedTensor keeps the
full parameter set so the transform stays invertible.
Variants§
PerTensor
A single scale/zero-point pair for the whole tensor.
Fields
PerChannel
One scale/zero-point pair per channel along axis.
Fields
PerGroup
One scale/zero-point pair per contiguous group of channels along axis.
Implementations§
Source§impl QParams
impl QParams
Sourcepub fn representative_scale(&self) -> f32
pub fn representative_scale(&self) -> f32
Scale of the first channel/group, for interoperability with the legacy
scalar-returning API. Only exact for QParams::PerTensor.
Sourcepub fn representative_zero_point(&self) -> i32
pub fn representative_zero_point(&self) -> i32
Zero point of the first channel/group. Only exact for
QParams::PerTensor.
Trait Implementations§
impl StructuralPartialEq for QParams
Auto Trait Implementations§
impl Freeze for QParams
impl RefUnwindSafe for QParams
impl Send for QParams
impl Sync for QParams
impl Unpin for QParams
impl UnsafeUnpin for QParams
impl UnwindSafe for QParams
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<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> ⓘ
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