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));
117 MlirType expressedType, int64_t storageTypeMin,
118 int64_t storageTypeMax) {
121 storageTypeMin, storageTypeMax));
129 return isa<quant::UniformQuantizedType>(
unwrap(type));
133 MlirType expressedType,
double scale,
134 int64_t zeroPoint, int64_t storageTypeMin,
135 int64_t storageTypeMax) {
137 flags,
unwrap(storageType),
unwrap(expressedType), scale, zeroPoint,
138 storageTypeMin, storageTypeMax));
142 return cast<quant::UniformQuantizedType>(
unwrap(type)).getScale();
146 return cast<quant::UniformQuantizedType>(
unwrap(type)).getZeroPoint();
150 return cast<quant::UniformQuantizedType>(
unwrap(type)).isFixedPoint();
158 return isa<quant::UniformQuantizedPerAxisType>(
unwrap(type));
162 unsigned flags, MlirType storageType, MlirType expressedType,
163 intptr_t nDims,
double *scales, int64_t *zeroPoints,
164 int32_t quantizedDimension, int64_t storageTypeMin,
165 int64_t storageTypeMax) {
169 quantizedDimension, storageTypeMin, storageTypeMax));
173 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
179 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
185 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
186 .getZeroPoints()[pos];
190 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
191 .getQuantizedDimension();
195 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type)).isFixedPoint();
203 return isa<quant::UniformQuantizedSubChannelType>(
unwrap(type));
207 unsigned flags, MlirType storageType, MlirType expressedType,
208 MlirAttribute scalesAttr, MlirAttribute zeroPointsAttr, intptr_t nDims,
209 int32_t *quantizedDimensions, int64_t *blockSizes, int64_t storageTypeMin,
210 int64_t storageTypeMax) {
211 auto scales = dyn_cast<mlir::DenseElementsAttr>(
unwrap(scalesAttr));
212 auto zeroPoints = dyn_cast<mlir::DenseElementsAttr>(
unwrap(zeroPointsAttr));
214 if (!scales || !zeroPoints) {
219 flags,
unwrap(storageType),
unwrap(expressedType), scales, zeroPoints,
226 return cast<quant::UniformQuantizedSubChannelType>(
unwrap(type))
233 return cast<quant::UniformQuantizedSubChannelType>(
unwrap(type))
234 .getQuantizedDimensions()[pos];
239 return cast<quant::UniformQuantizedSubChannelType>(
unwrap(type))
240 .getBlockSizes()[pos];
245 cast<quant::UniformQuantizedSubChannelType>(
unwrap(type)).getScales());
249 return wrap(cast<quant::UniformQuantizedSubChannelType>(
unwrap(type))
258 return isa<quant::CalibratedQuantizedType>(
unwrap(type));
268 return cast<quant::CalibratedQuantizedType>(
unwrap(type)).getMin();
272 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.
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...
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.
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.
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.
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.
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 mlirTypeIsAQuantizedType(MlirType type)
Returns true if the given type is a quantization dialect type.
bool mlirUniformQuantizedTypeIsFixedPoint(MlirType type)
Returns true if the given uniform quantized type is fixed-point.
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.
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 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 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.
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Include the generated interface declarations.