pub struct StorageCastOperation<'c> { /* private fields */ }Expand description
A scast operation. Storage cast operation.
Convert a value from a quantized type to the corresponding signless integer storage type, or vice versa. This conversion simply involves a reinterpretation of the input bits and does not involve any data manipulation.
The following syntactic restrictions must be met:
-
Operand
inputmust be a scalar or tensor of a signless integer or!quant.uniformtype. -
The result must be a scalar or tensor of a signless integer or
!quant.uniformtype. -
If the operand is a scalar or tensor of type integer, the result must be a scalar or tensor of type
!quant.uniform, and vice versa. -
The operand and result 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.
-
The width of the
storageTypeparameter of the quantized type of the operand or result must match the width of the signless integer type of the operand or result. -
If the operand or result uses per-channel quantization, its
!quant.uniformtype must adhere to the Per-axis quantization integrity guidelines.
Examples:
// Cast a scalar quantized value into its storage type
%result = quant.scast %input : !quant.uniform<i8:f32, 2.0> to i8
// Cast a dynamically shaped tensor of quantized values into their storage type
%result = quant.scast %input : tensor<?x!quant.uniform<i8:f32, 2.0>> to tensor<?xi8>
// Cast an unranked tensor of signless integers into a quantized type using
// per-channel quantization
%result = quant.scast %input : tensor<*xi8> to tensor<*x!quant.uniform<i8:f32:1, {2.0, 3.0}>>Implementations§
Source§impl<'c> StorageCastOperation<'c>
impl<'c> StorageCastOperation<'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>,
) -> StorageCastOperationBuilder<'c, Unset, Unset>
pub fn builder( context: &'c Context, location: Location<'c>, ) -> StorageCastOperationBuilder<'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 StorageCastOperation<'c>
impl<'c> Clone for StorageCastOperation<'c>
Source§fn clone(&self) -> StorageCastOperation<'c>
fn clone(&self) -> StorageCastOperation<'c>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more