24 return isa<quant::QuantizedType>(
unwrap(type));
32 unsigned integralWidth) {
38 unsigned integralWidth) {
44 return wrap(cast<quant::QuantizedType>(
unwrap(type)).getExpressedType());
48 return cast<quant::QuantizedType>(
unwrap(type)).getFlags();
52 return cast<quant::QuantizedType>(
unwrap(type)).isSigned();
56 return wrap(cast<quant::QuantizedType>(
unwrap(type)).getStorageType());
60 return cast<quant::QuantizedType>(
unwrap(type)).getStorageTypeMin();
64 return cast<quant::QuantizedType>(
unwrap(type)).getStorageTypeMax();
68 return cast<quant::QuantizedType>(
unwrap(type)).getStorageTypeIntegralWidth();
73 return cast<quant::QuantizedType>(
unwrap(type))
74 .isCompatibleExpressedType(
unwrap(candidate));
83 return wrap(cast<quant::QuantizedType>(
unwrap(type))
84 .castFromStorageType(
unwrap(candidate)));
89 cast<quant::QuantizedType>(
unwrap(type))));
94 return wrap(cast<quant::QuantizedType>(
unwrap(type))
95 .castFromExpressedType(
unwrap(candidate)));
103 MlirType candidate) {
104 return wrap(cast<quant::QuantizedType>(
unwrap(type))
105 .castExpressedToStorageType(
unwrap(candidate)));
113 return isa<quant::AnyQuantizedType>(
unwrap(type));
121 MlirType expressedType,
int64_t storageTypeMin,
125 storageTypeMin, storageTypeMax));
137 return isa<quant::UniformQuantizedType>(
unwrap(type));
145 MlirType expressedType,
double scale,
149 flags,
unwrap(storageType),
unwrap(expressedType), scale, zeroPoint,
150 storageTypeMin, storageTypeMax));
158 return cast<quant::UniformQuantizedType>(
unwrap(type)).getScale();
162 return cast<quant::UniformQuantizedType>(
unwrap(type)).getZeroPoint();
166 return cast<quant::UniformQuantizedType>(
unwrap(type)).isFixedPoint();
174 return isa<quant::UniformQuantizedPerAxisType>(
unwrap(type));
182 unsigned flags, MlirType storageType, MlirType expressedType,
184 int32_t quantizedDimension,
int64_t storageTypeMin,
189 quantizedDimension, storageTypeMin, storageTypeMax));
197 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
203 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
209 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
210 .getZeroPoints()[pos];
214 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
215 .getQuantizedDimension();
219 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type)).isFixedPoint();
227 return isa<quant::UniformQuantizedSubChannelType>(
unwrap(type));
235 unsigned flags, MlirType storageType, MlirType expressedType,
236 MlirAttribute scalesAttr, MlirAttribute zeroPointsAttr,
intptr_t nDims,
237 int32_t *quantizedDimensions,
int64_t *blockSizes,
int64_t storageTypeMin,
239 auto scales = dyn_cast<mlir::DenseElementsAttr>(
unwrap(scalesAttr));
240 auto zeroPoints = dyn_cast<mlir::DenseElementsAttr>(
unwrap(zeroPointsAttr));
242 if (!scales || !zeroPoints) {
247 flags,
unwrap(storageType),
unwrap(expressedType), scales, zeroPoints,
258 return cast<quant::UniformQuantizedSubChannelType>(
unwrap(type))
265 return cast<quant::UniformQuantizedSubChannelType>(
unwrap(type))
266 .getQuantizedDimensions()[pos];
271 return cast<quant::UniformQuantizedSubChannelType>(
unwrap(type))
272 .getBlockSizes()[pos];
277 cast<quant::UniformQuantizedSubChannelType>(
unwrap(type)).getScales());
281 return wrap(cast<quant::UniformQuantizedSubChannelType>(
unwrap(type))
290 return isa<quant::CalibratedQuantizedType>(
unwrap(type));
308 return cast<quant::CalibratedQuantizedType>(
unwrap(type)).getMin();
312 return cast<quant::CalibratedQuantizedType>(
unwrap(type)).getMax();
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)
static Value min(ImplicitLocOpBuilder &builder, Value value, Value bound)
double mlirUniformQuantizedTypeGetScale(MlirType type)
Returns the scale of the given uniform quantized type.
MlirType mlirQuantizedTypeCastToExpressedType(MlirType type)
Casts from a type based on a quantized type to a corresponding typed based on the expressed type.
double mlirUniformQuantizedPerAxisTypeGetScale(MlirType type, intptr_t pos)
Returns pos-th scale of the given quantized per-axis type.
MlirStringRef mlirUniformQuantizedTypeGetName(void)
MlirTypeID mlirUniformQuantizedTypeGetTypeID(void)
bool mlirTypeIsAUniformQuantizedSubChannelType(MlirType type)
Returns true if the given type is a UniformQuantizedSubChannel.
bool mlirQuantizedTypeIsCompatibleExpressedType(MlirType type, MlirType candidate)
Returns true if the candidate type is compatible with the given quantized type.
MlirType mlirCalibratedQuantizedTypeGet(MlirType expressedType, double min, double max)
Creates an instance of CalibratedQuantizedType with the given parameters in the same context as expre...
MlirTypeID mlirCalibratedQuantizedTypeGetTypeID(void)
double mlirCalibratedQuantizedTypeGetMax(MlirType type)
Returns the max value of the given calibrated quantized type.
MlirType mlirQuantizedTypeGetStorageType(MlirType type)
Returns the underlying type used to store the values.
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 gi...
bool mlirTypeIsAUniformQuantizedType(MlirType type)
Returns true if the given type is a UniformQuantizedType.
MlirAttribute mlirUniformQuantizedSubChannelTypeGetZeroPoints(MlirType type)
Returns the zero-points of the quantized type.
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 ...
bool mlirQuantizedTypeIsSigned(MlirType type)
Returns true if the given type is signed, false otherwise.
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 ...
MlirType mlirQuantizedTypeCastToStorageType(MlirType type)
Casts from a type based on a quantized type to a corresponding typed based on the storage type.
int64_t mlirUniformQuantizedTypeGetZeroPoint(MlirType type)
Returns the zero point of the given uniform quantized type.
int32_t mlirUniformQuantizedPerAxisTypeGetQuantizedDimension(MlirType type)
Returns the index of the quantized dimension in the given quantized per-axis type.
MlirStringRef mlirUniformQuantizedSubChannelTypeGetName(void)
unsigned mlirQuantizedTypeGetSignedFlag()
Returns the bit flag used to indicate signedness of a quantized type.
int32_t mlirUniformQuantizedSubChannelTypeGetQuantizedDimension(MlirType type, intptr_t pos)
Returns the quantized dimension at the given position.
MlirType mlirQuantizedTypeGetExpressedType(MlirType type)
Gets the original type approximated by the given quantized type.
MlirStringRef mlirCalibratedQuantizedTypeGetName(void)
MlirTypeID mlirUniformQuantizedSubChannelTypeGetTypeID(void)
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 s...
unsigned mlirQuantizedTypeGetStorageTypeIntegralWidth(MlirType type)
Returns the integral bitwidth that the storage type of the given quantized type can represent exactly...
int64_t mlirQuantizedTypeGetStorageTypeMin(MlirType type)
Returns the minimum value that the storage type of the given quantized type can take.
bool mlirTypeIsAUniformQuantizedPerAxisType(MlirType type)
Returns true if the given type is a UniformQuantizedPerAxisType.
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...
int64_t mlirQuantizedTypeGetStorageTypeMax(MlirType type)
Returns the maximum value that the storage type of the given quantized type can take.
bool mlirUniformQuantizedPerAxisTypeIsFixedPoint(MlirType type)
Returns true if the given uniform quantized per-axis type is fixed-point.
MlirType mlirQuantizedTypeGetQuantizedElementType(MlirType type)
Returns the element type of the given quantized type as another quantized type.
MlirAttribute mlirUniformQuantizedSubChannelTypeGetScales(MlirType type)
Returns the scales of the quantized type.
intptr_t mlirUniformQuantizedPerAxisTypeGetNumDims(MlirType type)
Returns the number of axes in the given quantized per-axis type.
MlirTypeID mlirAnyQuantizedTypeGetTypeID(void)
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 storageT...
bool mlirTypeIsAAnyQuantizedType(MlirType type)
Returns true if the given type is an AnyQuantizedType.
int64_t mlirUniformQuantizedSubChannelTypeGetBlockSize(MlirType type, intptr_t pos)
Returns the block size at the given position.
double mlirCalibratedQuantizedTypeGetMin(MlirType type)
Returns the min value of the given calibrated quantized type.
unsigned mlirQuantizedTypeGetFlags(MlirType type)
Gets the flags associated with the given quantized type.
MlirTypeID mlirUniformQuantizedPerAxisTypeGetTypeID(void)
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.
int64_t mlirUniformQuantizedPerAxisTypeGetZeroPoint(MlirType type, intptr_t pos)
Returns pos-th zero point of the given quantized per-axis type.
intptr_t mlirUniformQuantizedSubChannelTypeGetNumBlockSizes(MlirType type)
Returns the number of block sizes provided in type.
bool mlirUniformQuantizedTypeIsFixedPoint(MlirType type)
Returns true if the given uniform quantized type is fixed-point.
MlirStringRef mlirUniformQuantizedPerAxisTypeGetName(void)
int64_t mlirQuantizedTypeGetDefaultMinimumForInteger(bool isSigned, unsigned integralWidth)
Returns the minimum possible value stored by a quantized type.
bool mlirTypeIsACalibratedQuantizedType(MlirType type)
Returns true if the given type is a CalibratedQuantizedType.
MlirStringRef mlirAnyQuantizedTypeGetName(void)
int64_t mlirQuantizedTypeGetDefaultMaximumForInteger(bool isSigned, unsigned integralWidth)
Returns the maximum possible value stored by a quantized type.
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Name, Namespace, ClassName)
static TypeID getTypeID()
static AnyQuantizedType get(unsigned flags, Type storageType, Type expressedType, int64_t storageTypeMin, int64_t storageTypeMax)
Gets an instance of the type with all parameters specified but not checked.
static constexpr StringLiteral name
static constexpr StringLiteral name
static CalibratedQuantizedType get(Type expressedType, double min, double max)
Gets an instance of the type with all parameters specified but not checked.
static Type castToStorageType(Type quantizedType)
Casts from a type based on a QuantizedType to a corresponding type based on the storageType (returns ...
static Type castToExpressedType(Type quantizedType)
Casts from a type based on QuantizedType to a corresponding type based on the expressedType (returns ...
static QuantizedType getQuantizedElementType(Type primitiveOrContainerType)
Returns the element type as a QuantizedType or nullptr if it is not a quantized type.
static int64_t getDefaultMaximumForInteger(bool isSigned, unsigned integralWidth)
Gets the maximum possible stored by a storageType.
static int64_t getDefaultMinimumForInteger(bool isSigned, unsigned integralWidth)
Gets the minimum possible stored by a storageType.
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
MLIR_CAPI_EXPORTED bool mlirTypeIsAQuantizedType(MlirType type)
Returns true if the given type is a quantization dialect type.
Include the generated interface declarations.
A pointer to a sized fragment of a string, not necessarily null-terminated.