pub struct DequantizeCastOperation<'c> { /* private fields */ }Expand description
A dcast operation. Dequantize cast operation.
Convert an input quantized value into its expressed floating-point value. The dequantization process consists of the following steps:
def dequantize(quantizedValue: quantizedType) -> expressedType:
storedValue = reinterpretCast(quantizedValue, storageType)
storedValueFloat = convertIntToFloat(storedValue, expressedType)
zeroPointFloat = convertIntToFloat(zeroPoint, expressedType)
expressedValue = (storedValueFloat - zeroPointFloat) * scale
return expressedValueHere, storageType, expressedType, scale, and zeroPoint are obtained
from the corresponding parameters encoded in quantizedType. For
per-channel quantization, the appropriate scale and zeroPoint values
are used for each tensor element computation according to the channel the
element belongs to.
The numerical results produced by the algorithm above may vary depending on
the rounding methods used by convertIntToFloat(), subtraction (-), and
multiplication (*). This operation does not define specific rounding
methods; instead, it is the responsibility of a transform pipeline to
determine which rounding method to apply when this operation is broken down
into lower-level dialects.
The operation must satisfy the following syntactic constraints:
-
Operand
inputmust be a scalar or tensor of type!quant.uniform. -
The result type must be a floating-point scalar or tensor.
-
The
expressedTypeparameter of the!quant.uniformtype of the input must match the floating-point type of the result. -
The operand and result types must be both scalars or both tensors. If tensors, they must be both ranked or both unranked. If ranked, both must have the same shape, including matching static and dynamic dimensions.
-
If the operand uses per-channel quantization, its
!quant.uniformtype must adhere to the Per-axis quantization integrity guidelines.
Examples:
// Dequantize a scalar quantized value
%result = quant.dcast %input : !quant.uniform<i8:f32, 2.0> to f32
// Dequantize a dynamically shaped tensor of quantized values
%result = quant.dcast %input : tensor<?x!quant.uniform<i8:f32, 2.0>> to tensor<?xf32>
// Dequantize an unranked tensor using per-axis quantization information
%result = quant.dcast %input : tensor<*x!quant.uniform<i8:f32:1, {2.0, 3.0}>> to tensor<*xf32>Implementations§
Source§impl<'c> DequantizeCastOperation<'c>
impl<'c> DequantizeCastOperation<'c>
Sourcepub fn as_operation(&self) -> &Operation<'c>
pub fn as_operation(&self) -> &Operation<'c>
Returns a generic operation.
Sourcepub fn builder(
context: &'c Context,
location: Location<'c>,
) -> DequantizeCastOperationBuilder<'c, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c>, ) -> DequantizeCastOperationBuilder<'c, Unset, Unset>
Creates a builder.
pub fn result(&self) -> Result<OperationResult<'c, '_>, Error>
pub fn input(&self) -> Result<Value<'c, '_>, Error>
Trait Implementations§
Source§impl<'c> Clone for DequantizeCastOperation<'c>
impl<'c> Clone for DequantizeCastOperation<'c>
Source§fn clone(&self) -> DequantizeCastOperation<'c>
fn clone(&self) -> DequantizeCastOperation<'c>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more