MLIR  19.0.0git
Functions
Quant.cpp File Reference
#include "mlir-c/Dialect/Quant.h"
#include "mlir/CAPI/Registration.h"
#include "mlir/Dialect/Quant/QuantOps.h"
#include "mlir/Dialect/Quant/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 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 115 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ 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 205 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ mlirCalibratedQuantizedTypeGetMax()

double mlirCalibratedQuantizedTypeGetMax ( MlirType  type)

Returns the max value of the given calibrated quantized type.

Definition at line 215 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirCalibratedQuantizedTypeGetMin()

double mlirCalibratedQuantizedTypeGetMin ( MlirType  type)

Returns the min value of the given calibrated quantized type.

Definition at line 211 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ 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 101 of file Quant.cpp.

References unwrap(), and wrap().

Referenced by populateDialectQuantSubmodule().

◆ 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 91 of file Quant.cpp.

References unwrap(), and wrap().

Referenced by populateDialectQuantSubmodule().

◆ 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 80 of file Quant.cpp.

References unwrap(), and wrap().

Referenced by populateDialectQuantSubmodule().

◆ 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 97 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ 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 86 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetDefaultMaximumForInteger()

int64_t mlirQuantizedTypeGetDefaultMaximumForInteger ( bool  isSigned,
unsigned  integralWidth 
)

Returns the maximum possible value stored by a quantized type.

Definition at line 36 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetDefaultMinimumForInteger()

int64_t mlirQuantizedTypeGetDefaultMinimumForInteger ( bool  isSigned,
unsigned  integralWidth 
)

Returns the minimum possible value stored by a quantized type.

Definition at line 30 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetExpressedType()

MlirType mlirQuantizedTypeGetExpressedType ( MlirType  type)

Gets the original type approximated by the given quantized type.

Definition at line 42 of file Quant.cpp.

References unwrap(), and wrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetFlags()

unsigned mlirQuantizedTypeGetFlags ( MlirType  type)

Gets the flags associated with the given quantized type.

Definition at line 46 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetQuantizedElementType()

MlirType mlirQuantizedTypeGetQuantizedElementType ( MlirType  type)

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

Definition at line 76 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetSignedFlag()

unsigned mlirQuantizedTypeGetSignedFlag ( void  )

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

Definition at line 26 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetStorageType()

MlirType mlirQuantizedTypeGetStorageType ( MlirType  type)

Returns the underlying type used to store the values.

Definition at line 54 of file Quant.cpp.

References unwrap(), and wrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetStorageTypeIntegralWidth()

unsigned mlirQuantizedTypeGetStorageTypeIntegralWidth ( MlirType  type)

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

Definition at line 66 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetStorageTypeMax()

int64_t mlirQuantizedTypeGetStorageTypeMax ( MlirType  type)

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

Definition at line 62 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeGetStorageTypeMin()

int64_t mlirQuantizedTypeGetStorageTypeMin ( MlirType  type)

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

Definition at line 58 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeIsCompatibleExpressedType()

bool mlirQuantizedTypeIsCompatibleExpressedType ( MlirType  type,
MlirType  candidate 
)

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

Definition at line 70 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirQuantizedTypeIsSigned()

bool mlirQuantizedTypeIsSigned ( MlirType  type)

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

Definition at line 50 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirTypeIsAAnyQuantizedType()

bool mlirTypeIsAAnyQuantizedType ( MlirType  type)

Returns true if the given type is an AnyQuantizedType.

Definition at line 111 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirTypeIsACalibratedQuantizedType()

bool mlirTypeIsACalibratedQuantizedType ( MlirType  type)

Returns true if the given type is a CalibratedQuantizedType.

Definition at line 201 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirTypeIsAQuantizedType()

bool mlirTypeIsAQuantizedType ( MlirType  type)

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

Definition at line 22 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirTypeIsAUniformQuantizedPerAxisType()

bool mlirTypeIsAUniformQuantizedPerAxisType ( MlirType  type)

Returns true if the given type is a UniformQuantizedPerAxisType.

Definition at line 156 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirTypeIsAUniformQuantizedType()

bool mlirTypeIsAUniformQuantizedType ( MlirType  type)

Returns true if the given type is a UniformQuantizedType.

Definition at line 127 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ 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 160 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ mlirUniformQuantizedPerAxisTypeGetNumDims()

intptr_t mlirUniformQuantizedPerAxisTypeGetNumDims ( MlirType  type)

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

Definition at line 171 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirUniformQuantizedPerAxisTypeGetQuantizedDimension()

int32_t mlirUniformQuantizedPerAxisTypeGetQuantizedDimension ( MlirType  type)

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

Definition at line 188 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirUniformQuantizedPerAxisTypeGetScale()

double mlirUniformQuantizedPerAxisTypeGetScale ( MlirType  type,
intptr_t  pos 
)

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

Definition at line 177 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirUniformQuantizedPerAxisTypeGetZeroPoint()

int64_t mlirUniformQuantizedPerAxisTypeGetZeroPoint ( MlirType  type,
intptr_t  pos 
)

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

Definition at line 182 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirUniformQuantizedPerAxisTypeIsFixedPoint()

bool mlirUniformQuantizedPerAxisTypeIsFixedPoint ( MlirType  type)

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

Definition at line 193 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ 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 131 of file Quant.cpp.

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

Referenced by populateDialectQuantSubmodule().

◆ mlirUniformQuantizedTypeGetScale()

double mlirUniformQuantizedTypeGetScale ( MlirType  type)

Returns the scale of the given uniform quantized type.

Definition at line 140 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirUniformQuantizedTypeGetZeroPoint()

int64_t mlirUniformQuantizedTypeGetZeroPoint ( MlirType  type)

Returns the zero point of the given uniform quantized type.

Definition at line 144 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().

◆ mlirUniformQuantizedTypeIsFixedPoint()

bool mlirUniformQuantizedTypeIsFixedPoint ( MlirType  type)

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

Definition at line 148 of file Quant.cpp.

References unwrap().

Referenced by populateDialectQuantSubmodule().