pub enum QuantizationMethod {
Uniform,
Symmetric,
Affine,
PowerOfTwo,
Int4,
UInt4,
Float16,
BFloat16,
PerChannelSymmetric,
PerChannelAffine,
}
Expand description
Supported methods of quantization
Variants§
Uniform
Uniform quantization maps the input range to uniform discrete levels with equal spacing between consecutive levels
Symmetric
Symmetric quantization is centered around zero and has equal positive and negative ranges, making it suitable for weight matrices
Affine
Affine quantization uses the formula q = scale * (x - zero_point) allowing better representation of asymmetric distributions
PowerOfTwo
Power-of-two quantization uses powers of 2 for the scale factor, enabling efficient implementation with bitshifts
Int4
Int4 quantization uses 4-bit signed integers, packing two values into each byte for memory efficiency. This is useful for model compression in ML applications.
UInt4
UInt4 quantization uses 4-bit unsigned integers, packing two values into each byte. This provides a positive-only range with maximum memory efficiency.
Float16
Float16 quantization uses IEEE 754 16-bit half-precision floating point format. It provides a good balance between precision and memory efficiency for ML models.
BFloat16
BFloat16 quantization uses the “brain floating point” 16-bit format, which has the same exponent size as f32 but fewer mantissa bits. This is especially well-suited for deep learning applications.
PerChannelSymmetric
Per-channel symmetric quantization applies different symmetric quantization parameters to each channel (column), improving accuracy for matrices with varying distributions across channels.
PerChannelAffine
Per-channel affine quantization applies different affine quantization parameters to each channel (column), allowing for better representation of asymmetric distributions that vary by channel.
Trait Implementations§
Source§impl Clone for QuantizationMethod
impl Clone for QuantizationMethod
Source§fn clone(&self) -> QuantizationMethod
fn clone(&self) -> QuantizationMethod
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for QuantizationMethod
impl Debug for QuantizationMethod
Source§impl PartialEq for QuantizationMethod
impl PartialEq for QuantizationMethod
impl Copy for QuantizationMethod
impl Eq for QuantizationMethod
impl StructuralPartialEq for QuantizationMethod
Auto Trait Implementations§
impl Freeze for QuantizationMethod
impl RefUnwindSafe for QuantizationMethod
impl Send for QuantizationMethod
impl Sync for QuantizationMethod
impl Unpin for QuantizationMethod
impl UnwindSafe for QuantizationMethod
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
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