23 return isa<quant::QuantizedType>(
unwrap(type));
31 unsigned integralWidth) {
37 unsigned integralWidth) {
43 return wrap(cast<quant::QuantizedType>(
unwrap(type)).getExpressedType());
47 return cast<quant::QuantizedType>(
unwrap(type)).getFlags();
51 return cast<quant::QuantizedType>(
unwrap(type)).isSigned();
55 return wrap(cast<quant::QuantizedType>(
unwrap(type)).getStorageType());
59 return cast<quant::QuantizedType>(
unwrap(type)).getStorageTypeMin();
63 return cast<quant::QuantizedType>(
unwrap(type)).getStorageTypeMax();
67 return cast<quant::QuantizedType>(
unwrap(type)).getStorageTypeIntegralWidth();
72 return cast<quant::QuantizedType>(
unwrap(type))
73 .isCompatibleExpressedType(
unwrap(candidate));
82 return wrap(cast<quant::QuantizedType>(
unwrap(type))
83 .castFromStorageType(
unwrap(candidate)));
88 cast<quant::QuantizedType>(
unwrap(type))));
93 return wrap(cast<quant::QuantizedType>(
unwrap(type))
94 .castFromExpressedType(
unwrap(candidate)));
102 MlirType candidate) {
103 return wrap(cast<quant::QuantizedType>(
unwrap(type))
104 .castExpressedToStorageType(
unwrap(candidate)));
112 return isa<quant::AnyQuantizedType>(
unwrap(type));
116 MlirType expressedType, int64_t storageTypeMin,
117 int64_t storageTypeMax) {
120 storageTypeMin, storageTypeMax));
128 return isa<quant::UniformQuantizedType>(
unwrap(type));
132 MlirType expressedType,
double scale,
133 int64_t zeroPoint, int64_t storageTypeMin,
134 int64_t storageTypeMax) {
136 flags,
unwrap(storageType),
unwrap(expressedType), scale, zeroPoint,
137 storageTypeMin, storageTypeMax));
141 return cast<quant::UniformQuantizedType>(
unwrap(type)).getScale();
145 return cast<quant::UniformQuantizedType>(
unwrap(type)).getZeroPoint();
149 return cast<quant::UniformQuantizedType>(
unwrap(type)).isFixedPoint();
157 return isa<quant::UniformQuantizedPerAxisType>(
unwrap(type));
161 unsigned flags, MlirType storageType, MlirType expressedType,
162 intptr_t nDims,
double *scales, int64_t *zeroPoints,
163 int32_t quantizedDimension, int64_t storageTypeMin,
164 int64_t storageTypeMax) {
168 quantizedDimension, storageTypeMin, storageTypeMax));
172 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
178 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
184 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
185 .getZeroPoints()[pos];
189 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type))
190 .getQuantizedDimension();
194 return cast<quant::UniformQuantizedPerAxisType>(
unwrap(type)).isFixedPoint();
202 return isa<quant::CalibratedQuantizedType>(
unwrap(type));
212 return cast<quant::CalibratedQuantizedType>(
unwrap(type)).getMin();
216 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 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.
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.
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.
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.
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.
int64_t mlirUniformQuantizedPerAxisTypeGetZeroPoint(MlirType type, intptr_t pos)
Returns pos-th zero point of the given quantized per-axis 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.