QuantizationArguments

Enum QuantizationArguments 

Source
pub enum QuantizationArguments<'a> {
    ScaleZeroPointDataType {
        scale: f64,
        zero_point: i64,
        data_type: DataType,
    },
    ScaleTensorZeroPointDataTypeAxis {
        scale_tensor: &'a Tensor,
        zero_point: f64,
        data_type: DataType,
        axis: i64,
    },
    ScaleTensorZeroPointTensorDataTypeAxis {
        scale_tensor: &'a Tensor,
        zero_point_tensor: &'a Tensor,
        data_type: DataType,
        axis: i64,
    },
}
Expand description

Arguments controlling how a floating-point tensor is quantized into an integer representation.

All variants follow the same conceptual formula but differ in whether the scale and zero-point are provided as scalars or tensors and whether the scaling is applied per-axis.

Variants§

§

ScaleZeroPointDataType

Quantize using scalar scale / zero_point.

§Details

Formula: result = (tensor / scale) + zero_point.

Fields

§scale: f64

Scale scalar parameter

§zero_point: i64

Bias scalar parameter (converted to dataType of resultTensor)

§data_type: DataType

Integer data type of the result tensor.

§

ScaleTensorZeroPointDataTypeAxis

Quantize using a per-axis scale_tensor and scalar zero_point.

§Details

Formula: result = (tensor / scale_tensor) + zero_point.

Fields

§scale_tensor: &'a Tensor

Scale 1D Tensor parameter with size == tensor.shape[axis]

§zero_point: f64

Bias scalar parameter (converted to dataType of resultTensor)

§data_type: DataType

Integer data type of the result tensor.

§axis: i64

Axis on which the scale 1D value is being broadcasted

§

ScaleTensorZeroPointTensorDataTypeAxis

Quantize using per-axis scale_tensor and zero_point_tensor.

§Details

Formula: result = (tensor / scale_tensor) + zero_point_tensor.

Fields

§scale_tensor: &'a Tensor

Scale scalar or 1D Tensor parameter with size == tensor.shape[axis]

§zero_point_tensor: &'a Tensor

Bias scalar or 1D Tensor parameter with size == tensor.shape[axis]

§data_type: DataType

Integer data type of the result tensor.

§axis: i64

Axis on which the scale 1D value is being broadcasted

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,