pub struct QuantScheme {
pub level: QuantLevel,
pub mode: QuantMode,
pub q_type: QuantInputType,
pub acc_precision: QuantAccPrecision,
pub propagation: QuantPropagation,
}
Expand description
Describes a quantization scheme/configuration.
Fields§
§level: QuantLevel
Granularity level of quantization (e.g., per-tensor).
mode: QuantMode
Quantization mode (e.g., symmetric).
q_type: QuantInputType
Data type used for storing quantized values (e.g., QInt8).
acc_precision: QuantAccPrecision
Precision used for accumulating intermediate values (e.g., during matmul).
propagation: QuantPropagation
Whether to propagate quantization to outputs or return unquantized results.
Implementations§
Source§impl QuantScheme
impl QuantScheme
Sourcepub fn set_level(self, level: QuantLevel) -> QuantScheme
pub fn set_level(self, level: QuantLevel) -> QuantScheme
Set the quantization level.
Sourcepub fn set_mode(self, mode: QuantMode) -> QuantScheme
pub fn set_mode(self, mode: QuantMode) -> QuantScheme
Set the quantization mode.
Sourcepub fn set_q_type(self, q_type: QuantInputType) -> QuantScheme
pub fn set_q_type(self, q_type: QuantInputType) -> QuantScheme
Set the data type used for quantized values.
Sourcepub fn set_acc_precision(self, acc_precision: QuantAccPrecision) -> QuantScheme
pub fn set_acc_precision(self, acc_precision: QuantAccPrecision) -> QuantScheme
Set the accumulation precision used during computations.
Sourcepub fn set_propagation(self, propagation: QuantPropagation) -> QuantScheme
pub fn set_propagation(self, propagation: QuantPropagation) -> QuantScheme
Set whether quantization is propagated through operations.
Source§impl QuantScheme
impl QuantScheme
Sourcepub fn compute_range<B, const D: usize>(
&self,
tensor: &Tensor<B, D>,
calibration: &Calibration,
) -> CalibrationRange<B>where
B: Backend,
pub fn compute_range<B, const D: usize>(
&self,
tensor: &Tensor<B, D>,
calibration: &Calibration,
) -> CalibrationRange<B>where
B: Backend,
Compute the quantization range mapping.
Sourcepub fn compute_q_params<B>(
&self,
range: CalibrationRange<B>,
) -> QParams<Tensor<B, 1>, Tensor<B, 1, Int>>where
B: Backend,
pub fn compute_q_params<B>(
&self,
range: CalibrationRange<B>,
) -> QParams<Tensor<B, 1>, Tensor<B, 1, Int>>where
B: Backend,
Compute the quantization parameters.
Trait Implementations§
Source§impl Clone for QuantScheme
impl Clone for QuantScheme
Source§fn clone(&self) -> QuantScheme
fn clone(&self) -> QuantScheme
Returns a duplicate of the value. Read more
1.0.0 · 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 QuantScheme
impl Debug for QuantScheme
Source§impl Default for QuantScheme
impl Default for QuantScheme
Source§fn default() -> QuantScheme
fn default() -> QuantScheme
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for QuantScheme
impl<'de> Deserialize<'de> for QuantScheme
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<QuantScheme, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<QuantScheme, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for QuantScheme
impl Hash for QuantScheme
Source§impl Ord for QuantScheme
impl Ord for QuantScheme
Source§fn cmp(&self, other: &QuantScheme) -> Ordering
fn cmp(&self, other: &QuantScheme) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for QuantScheme
impl PartialEq for QuantScheme
Source§impl PartialOrd for QuantScheme
impl PartialOrd for QuantScheme
Source§impl Serialize for QuantScheme
impl Serialize for QuantScheme
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for QuantScheme
impl Eq for QuantScheme
impl StructuralPartialEq for QuantScheme
Auto Trait Implementations§
impl Freeze for QuantScheme
impl RefUnwindSafe for QuantScheme
impl Send for QuantScheme
impl Sync for QuantScheme
impl Unpin for QuantScheme
impl UnwindSafe for QuantScheme
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.