MLIR  21.0.0git
Functions
Quant.cpp File Reference
#include "mlir-c/Dialect/Quant.h"
#include "mlir-c/BuiltinAttributes.h"
#include "mlir/CAPI/Registration.h"
#include "mlir/Dialect/Quant/IR/Quant.h"
#include "mlir/Dialect/Quant/IR/QuantTypes.h"

Go to the source code of this file.

Functions

bool mlirTypeIsAQuantizedType (MlirType type)
 Returns true if the given type is a quantization dialect type. More...
 
unsigned mlirQuantizedTypeGetSignedFlag ()
 Returns the bit flag used to indicate signedness of a quantized type. More...
 
int64_t mlirQuantizedTypeGetDefaultMinimumForInteger (bool isSigned, unsigned integralWidth)
 Returns the minimum possible value stored by a quantized type. More...
 
int64_t mlirQuantizedTypeGetDefaultMaximumForInteger (bool isSigned, unsigned integralWidth)
 Returns the maximum possible value stored by a quantized type. More...
 
MlirType mlirQuantizedTypeGetExpressedType (MlirType type)
 Gets the original type approximated by the given quantized type. More...
 
unsigned mlirQuantizedTypeGetFlags (MlirType type)
 Gets the flags associated with the given quantized type. More...
 
bool mlirQuantizedTypeIsSigned (MlirType type)
 Returns true if the given type is signed, false otherwise. More...
 
MlirType mlirQuantizedTypeGetStorageType (MlirType type)
 Returns the underlying type used to store the values. More...
 
int64_t mlirQuantizedTypeGetStorageTypeMin (MlirType type)
 Returns the minimum value that the storage type of the given quantized type can take. More...
 
int64_t mlirQuantizedTypeGetStorageTypeMax (MlirType type)
 Returns the maximum value that the storage type of the given quantized type can take. More...
 
unsigned mlirQuantizedTypeGetStorageTypeIntegralWidth (MlirType type)
 Returns the integral bitwidth that the storage type of the given quantized type can represent exactly. More...
 
bool mlirQuantizedTypeIsCompatibleExpressedType (MlirType type, MlirType candidate)
 Returns true if the candidate type is compatible with the given quantized type. More...
 
MlirType mlirQuantizedTypeGetQuantizedElementType (MlirType type)
 Returns the element type of the given quantized type as another quantized type. More...
 
MlirType mlirQuantizedTypeCastFromStorageType (MlirType type, MlirType candidate)
 Casts from a type based on the storage type of the given type to a corresponding type based on the given type. More...
 
MlirType mlirQuantizedTypeCastToStorageType (MlirType type)
 Casts from a type based on a quantized type to a corresponding typed based on the storage type. More...
 
MlirType mlirQuantizedTypeCastFromExpressedType (MlirType type, MlirType candidate)
 Casts from a type based on the expressed type of the given type to a corresponding type based on the given type. More...
 
MlirType mlirQuantizedTypeCastToExpressedType (MlirType type)
 Casts from a type based on a quantized type to a corresponding typed based on the expressed type. More...
 
MlirType mlirQuantizedTypeCastExpressedToStorageType (MlirType type, MlirType candidate)
 Casts from a type based on the expressed type of the given quantized type to equivalent type based on storage type of the same quantized type. More...
 
bool mlirTypeIsAAnyQuantizedType (MlirType type)
 Returns true if the given type is an AnyQuantizedType. More...
 
MlirType mlirAnyQuantizedTypeGet (unsigned flags, MlirType storageType, MlirType expressedType, int64_t storageTypeMin, int64_t storageTypeMax)
 Creates an instance of AnyQuantizedType with the given parameters in the same context as storageType and returns it. More...
 
bool mlirTypeIsAUniformQuantizedType (MlirType type)
 Returns true if the given type is a UniformQuantizedType. More...
 
MlirType mlirUniformQuantizedTypeGet (unsigned flags, MlirType storageType, MlirType expressedType, double scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax)
 Creates an instance of UniformQuantizedType with the given parameters in the same context as storageType and returns it. More...
 
double mlirUniformQuantizedTypeGetScale (MlirType type)
 Returns the scale of the given uniform quantized type. More...
 
int64_t mlirUniformQuantizedTypeGetZeroPoint (MlirType type)
 Returns the zero point of the given uniform quantized type. More...
 
bool mlirUniformQuantizedTypeIsFixedPoint (MlirType type)
 Returns true if the given uniform quantized type is fixed-point. More...
 
bool mlirTypeIsAUniformQuantizedPerAxisType (MlirType type)
 Returns true if the given type is a UniformQuantizedPerAxisType. More...
 
MlirType mlirUniformQuantizedPerAxisTypeGet (unsigned flags, MlirType storageType, MlirType expressedType, intptr_t nDims, double *scales, int64_t *zeroPoints, int32_t quantizedDimension, int64_t storageTypeMin, int64_t storageTypeMax)
 Creates an instance of UniformQuantizedPerAxisType with the given parameters in the same context as storageType and returns it. More...
 
intptr_t mlirUniformQuantizedPerAxisTypeGetNumDims (MlirType type)
 Returns the number of axes in the given quantized per-axis type. More...
 
double mlirUniformQuantizedPerAxisTypeGetScale (MlirType type, intptr_t pos)
 Returns pos-th scale of the given quantized per-axis type. More...
 
int64_t mlirUniformQuantizedPerAxisTypeGetZeroPoint (MlirType type, intptr_t pos)
 Returns pos-th zero point of the given quantized per-axis type. More...
 
int32_t mlirUniformQuantizedPerAxisTypeGetQuantizedDimension (MlirType type)
 Returns the index of the quantized dimension in the given quantized per-axis type. More...
 
bool mlirUniformQuantizedPerAxisTypeIsFixedPoint (MlirType type)
 Returns true if the given uniform quantized per-axis type is fixed-point. More...
 
bool mlirTypeIsAUniformQuantizedSubChannelType (MlirType type)
 Returns true if the given type is a UniformQuantizedSubChannel. More...
 
MlirType mlirUniformQuantizedSubChannelTypeGet (unsigned flags, MlirType storageType, MlirType expressedType, MlirAttribute scalesAttr, MlirAttribute zeroPointsAttr, intptr_t nDims, int32_t *quantizedDimensions, int64_t *blockSizes, int64_t storageTypeMin, int64_t storageTypeMax)
 Creates a UniformQuantizedSubChannelType with the given parameters. More...
 
intptr_t mlirUniformQuantizedSubChannelTypeGetNumBlockSizes (MlirType type)
 Returns the number of block sizes provided in type. More...
 
int32_t mlirUniformQuantizedSubChannelTypeGetQuantizedDimension (MlirType type, intptr_t pos)
 Returns the quantized dimension at the given position. More...
 
int64_t mlirUniformQuantizedSubChannelTypeGetBlockSize (MlirType type, intptr_t pos)
 Returns the block size at the given position. More...
 
MlirAttribute mlirUniformQuantizedSubChannelTypeGetScales (MlirType type)
 Returns the scales of the quantized type. More...
 
MlirAttribute mlirUniformQuantizedSubChannelTypeGetZeroPoints (MlirType type)
 Returns the zero-points of the quantized type. More...
 
bool mlirTypeIsACalibratedQuantizedType (MlirType type)
 Returns true if the given type is a CalibratedQuantizedType. More...
 
MlirType mlirCalibratedQuantizedTypeGet (MlirType expressedType, double min, double max)
 Creates an instance of CalibratedQuantizedType with the given parameters in the same context as expressedType and returns it. More...
 
double mlirCalibratedQuantizedTypeGetMin (MlirType type)
 Returns the min value of the given calibrated quantized type. More...
 
double mlirCalibratedQuantizedTypeGetMax (MlirType type)
 Returns the max value of the given calibrated quantized type. More...
 

Function Documentation

◆ mlirAnyQuantizedTypeGet()

MlirType mlirAnyQuantizedTypeGet ( unsigned  flags,
MlirType  storageType,
MlirType  expressedType,
int64_t  storageTypeMin,
int64_t  storageTypeMax 
)

Creates an instance of AnyQuantizedType with the given parameters in the same context as storageType and returns it.

The instance is owned by the context.

Definition at line 116 of file Quant.cpp.

References mlir::quant::AnyQuantizedType::get(), unwrap(), and wrap().

◆ mlirCalibratedQuantizedTypeGet()

MlirType mlirCalibratedQuantizedTypeGet ( MlirType  expressedType,
double  min,
double  max 
)

Creates an instance of CalibratedQuantizedType with the given parameters in the same context as expressedType and returns it.

The instance is owned by the context.

Definition at line 261 of file Quant.cpp.

References mlir::quant::CalibratedQuantizedType::get(), max(), min(), unwrap(), and wrap().

◆ mlirCalibratedQuantizedTypeGetMax()

double mlirCalibratedQuantizedTypeGetMax ( MlirType  type)

Returns the max value of the given calibrated quantized type.

Definition at line 271 of file Quant.cpp.

References unwrap().

◆ mlirCalibratedQuantizedTypeGetMin()

double mlirCalibratedQuantizedTypeGetMin ( MlirType  type)

Returns the min value of the given calibrated quantized type.

Definition at line 267 of file Quant.cpp.

References unwrap().

◆ mlirQuantizedTypeCastExpressedToStorageType()

MlirType mlirQuantizedTypeCastExpressedToStorageType ( MlirType  type,
MlirType  candidate 
)

Casts from a type based on the expressed type of the given quantized type to equivalent type based on storage type of the same quantized type.

Definition at line 102 of file Quant.cpp.

References unwrap(), and wrap().

◆ mlirQuantizedTypeCastFromExpressedType()

MlirType mlirQuantizedTypeCastFromExpressedType ( MlirType  type,
MlirType  candidate 
)

Casts from a type based on the expressed type of the given type to a corresponding type based on the given type.

Returns a null type if the cast is not valid.

Definition at line 92 of file Quant.cpp.

References unwrap(), and wrap().

◆ mlirQuantizedTypeCastFromStorageType()

MlirType mlirQuantizedTypeCastFromStorageType ( MlirType  type,
MlirType  candidate 
)

Casts from a type based on the storage type of the given type to a corresponding type based on the given type.

Returns a null type if the cast is not valid.

Definition at line 81 of file Quant.cpp.

References unwrap(), and wrap().

◆ mlirQuantizedTypeCastToExpressedType()

MlirType mlirQuantizedTypeCastToExpressedType ( MlirType  type)

Casts from a type based on a quantized type to a corresponding typed based on the expressed type.

Returns a null type if the cast is not valid.

Definition at line 98 of file Quant.cpp.

References mlir::quant::QuantizedType::castToExpressedType(), unwrap(), and wrap().

◆ mlirQuantizedTypeCastToStorageType()

MlirType mlirQuantizedTypeCastToStorageType ( MlirType  type)

Casts from a type based on a quantized type to a corresponding typed based on the storage type.

Returns a null type if the cast is not valid.

Definition at line 87 of file Quant.cpp.

References mlir::quant::QuantizedType::castToStorageType(), unwrap(), and wrap().

◆ mlirQuantizedTypeGetDefaultMaximumForInteger()

int64_t mlirQuantizedTypeGetDefaultMaximumForInteger ( bool  isSigned,
unsigned  integralWidth 
)

Returns the maximum possible value stored by a quantized type.

Definition at line 37 of file Quant.cpp.

References mlir::quant::QuantizedType::getDefaultMaximumForInteger().

◆ mlirQuantizedTypeGetDefaultMinimumForInteger()

int64_t mlirQuantizedTypeGetDefaultMinimumForInteger ( bool  isSigned,
unsigned  integralWidth 
)

Returns the minimum possible value stored by a quantized type.

Definition at line 31 of file Quant.cpp.

References mlir::quant::QuantizedType::getDefaultMinimumForInteger().

◆ mlirQuantizedTypeGetExpressedType()

MlirType mlirQuantizedTypeGetExpressedType ( MlirType  type)

Gets the original type approximated by the given quantized type.

Definition at line 43 of file Quant.cpp.

References unwrap(), and wrap().

◆ mlirQuantizedTypeGetFlags()

unsigned mlirQuantizedTypeGetFlags ( MlirType  type)

Gets the flags associated with the given quantized type.

Definition at line 47 of file Quant.cpp.

References unwrap().

◆ mlirQuantizedTypeGetQuantizedElementType()

MlirType mlirQuantizedTypeGetQuantizedElementType ( MlirType  type)

Returns the element type of the given quantized type as another quantized type.

Definition at line 77 of file Quant.cpp.

References mlir::quant::QuantizedType::getQuantizedElementType(), unwrap(), and wrap().

◆ mlirQuantizedTypeGetSignedFlag()

unsigned mlirQuantizedTypeGetSignedFlag ( void  )

Returns the bit flag used to indicate signedness of a quantized type.

Definition at line 27 of file Quant.cpp.

References mlir::quant::QuantizationFlags::Signed.

◆ mlirQuantizedTypeGetStorageType()

MlirType mlirQuantizedTypeGetStorageType ( MlirType  type)

Returns the underlying type used to store the values.

Definition at line 55 of file Quant.cpp.

References unwrap(), and wrap().

◆ mlirQuantizedTypeGetStorageTypeIntegralWidth()

unsigned mlirQuantizedTypeGetStorageTypeIntegralWidth ( MlirType  type)

Returns the integral bitwidth that the storage type of the given quantized type can represent exactly.

Definition at line 67 of file Quant.cpp.

References unwrap().

◆ mlirQuantizedTypeGetStorageTypeMax()

int64_t mlirQuantizedTypeGetStorageTypeMax ( MlirType  type)

Returns the maximum value that the storage type of the given quantized type can take.

Definition at line 63 of file Quant.cpp.

References unwrap().

◆ mlirQuantizedTypeGetStorageTypeMin()

int64_t mlirQuantizedTypeGetStorageTypeMin ( MlirType  type)

Returns the minimum value that the storage type of the given quantized type can take.

Definition at line 59 of file Quant.cpp.

References unwrap().

◆ mlirQuantizedTypeIsCompatibleExpressedType()

bool mlirQuantizedTypeIsCompatibleExpressedType ( MlirType  type,
MlirType  candidate 
)

Returns true if the candidate type is compatible with the given quantized type.

Definition at line 71 of file Quant.cpp.

References unwrap().

◆ mlirQuantizedTypeIsSigned()

bool mlirQuantizedTypeIsSigned ( MlirType  type)

Returns true if the given type is signed, false otherwise.

Definition at line 51 of file Quant.cpp.

References unwrap().

◆ mlirTypeIsAAnyQuantizedType()

bool mlirTypeIsAAnyQuantizedType ( MlirType  type)

Returns true if the given type is an AnyQuantizedType.

Definition at line 112 of file Quant.cpp.

References unwrap().

◆ mlirTypeIsACalibratedQuantizedType()

bool mlirTypeIsACalibratedQuantizedType ( MlirType  type)

Returns true if the given type is a CalibratedQuantizedType.

Definition at line 257 of file Quant.cpp.

References unwrap().

◆ mlirTypeIsAQuantizedType()

bool mlirTypeIsAQuantizedType ( MlirType  type)

Returns true if the given type is a quantization dialect type.

Definition at line 23 of file Quant.cpp.

References unwrap().

◆ mlirTypeIsAUniformQuantizedPerAxisType()

bool mlirTypeIsAUniformQuantizedPerAxisType ( MlirType  type)

Returns true if the given type is a UniformQuantizedPerAxisType.

Definition at line 157 of file Quant.cpp.

References unwrap().

◆ mlirTypeIsAUniformQuantizedSubChannelType()

bool mlirTypeIsAUniformQuantizedSubChannelType ( MlirType  type)

Returns true if the given type is a UniformQuantizedSubChannel.

Definition at line 202 of file Quant.cpp.

References unwrap().

◆ mlirTypeIsAUniformQuantizedType()

bool mlirTypeIsAUniformQuantizedType ( MlirType  type)

Returns true if the given type is a UniformQuantizedType.

Definition at line 128 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedPerAxisTypeGet()

MlirType mlirUniformQuantizedPerAxisTypeGet ( unsigned  flags,
MlirType  storageType,
MlirType  expressedType,
intptr_t  nDims,
double *  scales,
int64_t *  zeroPoints,
int32_t  quantizedDimension,
int64_t  storageTypeMin,
int64_t  storageTypeMax 
)

Creates an instance of UniformQuantizedPerAxisType with the given parameters in the same context as storageType and returns it.

scales and zeroPoints point to nDims number of elements. The instance is owned by the context.

Definition at line 161 of file Quant.cpp.

References mlir::quant::UniformQuantizedPerAxisType::get(), unwrap(), and wrap().

◆ mlirUniformQuantizedPerAxisTypeGetNumDims()

intptr_t mlirUniformQuantizedPerAxisTypeGetNumDims ( MlirType  type)

Returns the number of axes in the given quantized per-axis type.

Definition at line 172 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedPerAxisTypeGetQuantizedDimension()

int32_t mlirUniformQuantizedPerAxisTypeGetQuantizedDimension ( MlirType  type)

Returns the index of the quantized dimension in the given quantized per-axis type.

Definition at line 189 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedPerAxisTypeGetScale()

double mlirUniformQuantizedPerAxisTypeGetScale ( MlirType  type,
intptr_t  pos 
)

Returns pos-th scale of the given quantized per-axis type.

Definition at line 178 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedPerAxisTypeGetZeroPoint()

int64_t mlirUniformQuantizedPerAxisTypeGetZeroPoint ( MlirType  type,
intptr_t  pos 
)

Returns pos-th zero point of the given quantized per-axis type.

Definition at line 183 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedPerAxisTypeIsFixedPoint()

bool mlirUniformQuantizedPerAxisTypeIsFixedPoint ( MlirType  type)

Returns true if the given uniform quantized per-axis type is fixed-point.

Definition at line 194 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedSubChannelTypeGet()

MlirType mlirUniformQuantizedSubChannelTypeGet ( unsigned  flags,
MlirType  storageType,
MlirType  expressedType,
MlirAttribute  scalesAttr,
MlirAttribute  zeroPointsAttr,
intptr_t  blockSizeInfoLength,
int32_t *  quantizedDimensions,
int64_t *  blockSizes,
int64_t  storageTypeMin,
int64_t  storageTypeMax 
)

Creates a UniformQuantizedSubChannelType with the given parameters.

The type is owned by the context. scalesAttr and zeroPointsAttr must be DenseElementsAttrs. quantizedDimensions and blockSizes point to blockSizeInfoLength number of elements, describing respectively the quantization axis and corresponding block size.

Definition at line 206 of file Quant.cpp.

References mlir::quant::UniformQuantizedSubChannelType::get(), unwrap(), and wrap().

◆ mlirUniformQuantizedSubChannelTypeGetBlockSize()

int64_t mlirUniformQuantizedSubChannelTypeGetBlockSize ( MlirType  type,
intptr_t  pos 
)

Returns the block size at the given position.

Definition at line 237 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedSubChannelTypeGetNumBlockSizes()

intptr_t mlirUniformQuantizedSubChannelTypeGetNumBlockSizes ( MlirType  type)

Returns the number of block sizes provided in type.

Definition at line 225 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedSubChannelTypeGetQuantizedDimension()

int32_t mlirUniformQuantizedSubChannelTypeGetQuantizedDimension ( MlirType  type,
intptr_t  pos 
)

Returns the quantized dimension at the given position.

Definition at line 231 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedSubChannelTypeGetScales()

MlirAttribute mlirUniformQuantizedSubChannelTypeGetScales ( MlirType  type)

Returns the scales of the quantized type.

Definition at line 243 of file Quant.cpp.

References unwrap(), and wrap().

◆ mlirUniformQuantizedSubChannelTypeGetZeroPoints()

MlirAttribute mlirUniformQuantizedSubChannelTypeGetZeroPoints ( MlirType  type)

Returns the zero-points of the quantized type.

Definition at line 248 of file Quant.cpp.

References unwrap(), and wrap().

◆ mlirUniformQuantizedTypeGet()

MlirType mlirUniformQuantizedTypeGet ( unsigned  flags,
MlirType  storageType,
MlirType  expressedType,
double  scale,
int64_t  zeroPoint,
int64_t  storageTypeMin,
int64_t  storageTypeMax 
)

Creates an instance of UniformQuantizedType with the given parameters in the same context as storageType and returns it.

The instance is owned by the context.

Definition at line 132 of file Quant.cpp.

References mlir::quant::UniformQuantizedType::get(), unwrap(), and wrap().

◆ mlirUniformQuantizedTypeGetScale()

double mlirUniformQuantizedTypeGetScale ( MlirType  type)

Returns the scale of the given uniform quantized type.

Definition at line 141 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedTypeGetZeroPoint()

int64_t mlirUniformQuantizedTypeGetZeroPoint ( MlirType  type)

Returns the zero point of the given uniform quantized type.

Definition at line 145 of file Quant.cpp.

References unwrap().

◆ mlirUniformQuantizedTypeIsFixedPoint()

bool mlirUniformQuantizedTypeIsFixedPoint ( MlirType  type)

Returns true if the given uniform quantized type is fixed-point.

Definition at line 149 of file Quant.cpp.

References unwrap().