MLIR  20.0.0git
QuantTypes.h
Go to the documentation of this file.
1 //===- QuantTypes.h - Quantization Ops and Types ----------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef MLIR_DIALECT_QUANT_IR_QUANTTYPES_H
10 #define MLIR_DIALECT_QUANT_IR_QUANTTYPES_H
11 
12 #include "mlir/IR/Attributes.h"
13 #include "mlir/IR/Builders.h"
14 #include "mlir/IR/BuiltinTypes.h"
15 #include "mlir/IR/Dialect.h"
16 #include "mlir/IR/OpDefinition.h"
17 #include "mlir/IR/Types.h"
18 #include "llvm/Support/MathExtras.h"
19 
20 namespace mlir {
21 namespace quant {
22 namespace detail {
23 
29 
30 } // namespace detail
31 
32 /// Enumeration of bit-mapped flags related to quantized types.
33 namespace QuantizationFlags {
34 enum FlagValue {
35  // Indicates that the storage type should be interpreted as a signed
36  // integer. The default is to interpret it as an unsigned value.
37  Signed = 1,
38 };
39 } // namespace QuantizationFlags
40 
41 /// Base class for all quantized types known to this dialect.
42 /// All quantized types have:
43 /// - storageType: The (narrower) numeric type that is being used to
44 /// approximate some expressed type.
45 /// - expressedType: The type that is being approximated.
46 ///
47 /// The base class provides generic support for manipulating the types based
48 /// on these fields.
49 class QuantizedType : public Type {
50 public:
52  using Type::Type;
53 
54  /// The maximum number of bits supported for storage types.
55  static constexpr unsigned MaxStorageBits = 32;
56 
57  static LogicalResult
59  Type storageType, Type expressedType, int64_t storageTypeMin,
60  int64_t storageTypeMax);
61 
62  /// Support method to enable LLVM-style type casting.
63  static bool classof(Type type);
64 
65  /// Gets the minimum possible stored by a storageType. storageTypeMin must
66  /// be greater than or equal to this value.
68  unsigned integralWidth) {
69  if (isSigned) {
70  return llvm::minIntN(integralWidth);
71  }
72  return 0;
73  }
74 
75  /// Gets the maximum possible stored by a storageType. storageTypeMax must
76  /// be less than or equal to this value.
78  unsigned integralWidth) {
79  if (isSigned) {
80  return llvm::maxIntN(integralWidth);
81  }
82  return llvm::maxUIntN(integralWidth);
83  }
84 
85  /// Gets the original expressed type that this quantized type approximates.
86  /// Note that this presumes that the quantized type was always derived from
87  /// a floating point type, which in the broadest definition, is not true (i.e.
88  /// it could be some form of integral, fixed type or affine type in its own
89  /// right); however, at the high level, no examples of such usage are
90  /// presently known and the restriction serves some useful purposes (such as
91  /// always being able to reverse a transformation or measure error). In most
92  /// cases, this will be f32.
93  Type getExpressedType() const;
94 
95  /// Gets the flags associated with this type. Typically a more specific
96  /// accessor is appropriate.
97  unsigned getFlags() const;
98 
99  // Convenience helpers.
100  /// Whether the storage type should be interpreted as a signed quantity
101  /// (true) or an unsigned value (false).
102  bool isSigned() const {
103  return (getFlags() & QuantizationFlags::Signed) ==
105  }
106 
107  /// Gets the underlying type used for to store values. Note that this may
108  /// be signed or unsigned. Use the isSigned() accessor to differentiate.
109  Type getStorageType() const;
110 
111  /// The minimum value that storageType can take.
112  int64_t getStorageTypeMin() const;
113 
114  /// The maximum value that storageType can take.
115  int64_t getStorageTypeMax() const;
116 
117  /// Return whether the storage type has explicit min or max boundaries
118  /// different from the minimum and maximum representable values.
119  bool hasStorageTypeBounds() const;
120 
121  /// Gets the integral bit width that the underlying storage type can exactly
122  /// represent. For integral storage types, this will just be their width.
123  unsigned getStorageTypeIntegralWidth() const;
124 
125  /// Returns whether the candidateExpressedType is a match for this
126  /// QuantizedType. This will be true if the candidate type is either a
127  /// primitive type or a container type whose element type equals this
128  /// QuantizedType's expressed type.
129  /// Examples of compatible candidateExpressedType:
130  /// !quant.uniform<i8:f32, 1.0> =~ f32
131  /// !quant.uniform<i8:f32, 1.0> =~ tensor<4xf32>
132  bool isCompatibleExpressedType(Type candidateExpressedType);
133 
134  /// Returns the element type as a QuantizedType or nullptr if it is not
135  /// a quantized type. If the type is primitive, returns that. If it is a
136  /// container (vector/tensor), return the element type.
137  /// Examples:
138  /// !quant.uniform<i8:f32, 1.0> -> !quant.uniform<i8:f32, 1.0>
139  /// tensor<4x!quant.uniform<i8:f32, 1.0> -> quant.uniform<i8:f32, 1.0>
140  static QuantizedType getQuantizedElementType(Type primitiveOrContainerType);
141 
142  /// Casts from a type based on the storageType to a corresponding type based
143  /// on this type (returns nullptr if the cast is not valid).
144  /// Examples:
145  /// i8 -> !quant.uniform<i8:f32, 1.0>
146  /// tensor<4xi8> -> tensor<4x!quant.uniform<i8:f32, 1.0}>>
147  /// vector<4xi8> -> vector<4x!quant.uniform<i8:f32, 1.0>>
148  Type castFromStorageType(Type candidateType);
149 
150  /// Casts from a type based on a QuantizedType to a corresponding type based
151  /// on the storageType (returns nullptr if the cast is not valid).
152  /// This is the inverse of castFromStorageType().
153  static Type castToStorageType(Type quantizedType);
154 
155  /// Casts from a type based on the expressedType to a corresponding type based
156  /// on this type (returns nullptr if the cast is not valid).
157  /// Examples:
158  /// f32 -> !quant.uniform<i8:f32, 1.0>
159  /// tensor<4xf32> -> tensor<4x!quant.uniform<i8:f32, 1.0>>
160  /// vector<4xf32> -> vector<4x!quant.uniform<i8:f32, 1.0>>
161  Type castFromExpressedType(Type candidateType);
162 
163  /// Casts from a type based on QuantizedType to a corresponding type based
164  /// on the expressedType (returns nullptr if the cast is not valid).
165  /// This is the inverse of castFromExpressedType.
166  static Type castToExpressedType(Type quantizedType);
167 
168  /// Casts from a type based on the expressedType to the equivalent type
169  /// based on storageType by way of this QuantizedType. Equivalent to:
170  /// QuantizedType::castToStorageType(castFromExpressedType(candidateType))
171  /// (but with validity checks).
172  /// Example (for this = !quant.uniform<i8:f32, 1.0>):
173  /// tensor<4xf32> -> tensor<4xi8>
174  Type castExpressedToStorageType(Type candidateType);
175 
176 private:
177  /// Hide the following methods inherited from `Type`. It is almost certainly
178  /// a bug to call them from a `QuantizedType` object. Users should call
179  /// `getStorageType` or `getExpressedType` to get the underlying types
180  /// they want to inspect.
181  using Type::isBF16;
182  using Type::isF16;
183  using Type::isF32;
184  using Type::isF64;
185  using Type::isIndex;
186  using Type::isInteger;
187 };
188 
189 /// A quantized type that maps storage to/from expressed types in an
190 /// unspecified way.
191 ///
192 /// Typical syntax:
193 /// quant.any<i8:f32>
194 /// quant.any<i8>
195 /// quant.any<i8<-16,15>>
196 ///
197 /// Note that for the any type, the expressed type is optional.
199  : public Type::TypeBase<AnyQuantizedType, QuantizedType,
200  detail::AnyQuantizedTypeStorage> {
201 public:
202  using Base::Base;
203  using Base::getChecked;
204 
205  static constexpr StringLiteral name = "quant.any";
206 
207  /// Gets an instance of the type with all parameters specified but not
208  /// checked.
209  static AnyQuantizedType get(unsigned flags, Type storageType,
210  Type expressedType, int64_t storageTypeMin,
211  int64_t storageTypeMax);
212 
213  /// Gets an instance of the type with all specified parameters checked.
214  /// Returns a nullptr convertible type on failure.
215  static AnyQuantizedType
217  Type storageType, Type expressedType, int64_t storageTypeMin,
218  int64_t storageTypeMax);
219 
220  /// Verifies construction invariants and issues errors/warnings.
221  static LogicalResult
223  Type storageType, Type expressedType, int64_t storageTypeMin,
224  int64_t storageTypeMax);
225 };
226 
227 /// Represents a family of uniform, quantized types.
228 ///
229 /// Each instance of this type expresses a mapping between real values (most
230 /// often expressed in floating point f32) and quantized values (either fixed
231 /// point or affine).
232 ///
233 /// The relationship is:
234 /// real_value = scale * (quantized_value - zero_point)
235 ///
236 /// It is used as part of high level graph transformations that have the goal
237 /// of re-expressing parts of a computation in terms of this common form for
238 /// more efficient execution at runtime. In addition, it is designed to be
239 /// expressive enough to facilitate lowering to precise types and operations
240 /// in target hardware.
241 ///
242 /// As a high-level type, focused on intermediate passes, this type holds
243 /// opinions consistent with high-level usage. If lowering math kernels below
244 /// the high level arithmetic ops (i.e. to LLVM IR or hardware specific
245 /// instruction sets), it is expected that the information expressed here
246 /// will be used to drive low level codegen and target specific type selection,
247 /// but this type will likely be erased in the process.
248 ///
249 /// Syntax synopsis:
250 /// Per-layer, all parameters expressed:
251 /// !quant<uniform[StorageType:ExpressedType]{Scale:ZeroPoint}>
252 /// Per-layer, optional parameters omitted:
253 /// !quant<uniform[StorageType]{Scale}>
254 ///
255 /// StorageType: 'i'|'u' NumBits
256 /// ExpressedType: 'f16', 'f32', 'bf16', 'f64'
257 /// Scale: A legal double value
258 /// ZeroPoint: An integer value
260  : public Type::TypeBase<UniformQuantizedType, QuantizedType,
261  detail::UniformQuantizedTypeStorage> {
262 public:
263  using Base::Base;
264  using Base::getChecked;
265 
266  static constexpr StringLiteral name = "quant.uniform";
267 
268  /// Gets an instance of the type with all parameters specified but not
269  /// checked.
270  static UniformQuantizedType get(unsigned flags, Type storageType,
271  Type expressedType, double scale,
272  int64_t zeroPoint, int64_t storageTypeMin,
273  int64_t storageTypeMax);
274 
275  /// Gets an instance of the type with all specified parameters checked.
276  /// Returns a nullptr convertible type on failure.
277  static UniformQuantizedType
279  Type storageType, Type expressedType, double scale,
280  int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax);
281 
282  /// Verifies construction invariants and issues errors/warnings.
283  static LogicalResult
285  Type storageType, Type expressedType, double scale,
286  int64_t zeroPoint, int64_t storageTypeMin,
287  int64_t storageTypeMax);
288 
289  /// Gets the scale term. The scale designates the difference between the real
290  /// values corresponding to consecutive quantized values differing by 1.
291  double getScale() const;
292 
293  /// Gets the storage value corresponding to the real value 0 in the affine
294  /// equation.
295  int64_t getZeroPoint() const;
296 
297  // Fixed point values are real numbers divided by a scale.
298  // Currently, only signed storage types are treated as fixed point.
299  // A fixed point value can be obtained from an affine value by subtracting
300  // the zeroPoint.
301  // In the future, this may be explicit versus implied by type and zeroPoint.
302  bool isFixedPoint() const { return isSigned() && getZeroPoint() == 0; }
303 };
304 
305 /// Represents per-axis (also known as per-channel quantization).
306 ///
307 /// Syntax synopsis:
308 /// Per-axis, all parameters expressed:
309 /// !quant<uniform[StorageType:ExpressedType:QuantizedDim]{QuantParams}>
310 /// Per-axis, optional parameters omitted:
311 /// !quant<uniform[StorageType]{Scale}>
312 ///
313 /// StorageType: 'i'|'u' NumBits
314 /// ExpressedType: 'f16', 'f32', 'bf16', 'f64'
315 /// QuantizedDim: An integer value
316 /// QuantParams: (Scale ':' ZeroPoint)+
317 /// Scale: A legal double value
318 /// ZeroPoint: An integer value
320  : public Type::TypeBase<UniformQuantizedPerAxisType, QuantizedType,
321  detail::UniformQuantizedPerAxisTypeStorage> {
322 public:
323  using Base::Base;
324  using Base::getChecked;
325 
326  static constexpr StringLiteral name = "quant.uniform_per_axis";
327 
328  /// Gets an instance of the type with all parameters specified but not
329  /// checked.
331  get(unsigned flags, Type storageType, Type expressedType,
332  ArrayRef<double> scales, ArrayRef<int64_t> zeroPoints,
333  int32_t quantizedDimension, int64_t storageTypeMin,
334  int64_t storageTypeMax);
335 
336  /// Gets an instance of the type with all specified parameters checked.
337  /// Returns a nullptr convertible type on failure.
340  Type storageType, Type expressedType, ArrayRef<double> scales,
341  ArrayRef<int64_t> zeroPoints, int32_t quantizedDimension,
342  int64_t storageTypeMin, int64_t storageTypeMax);
343 
344  /// Verifies construction invariants and issues errors/warnings.
345  static LogicalResult
347  Type storageType, Type expressedType,
348  ArrayRef<double> scales, ArrayRef<int64_t> zeroPoints,
349  int32_t quantizedDimension, int64_t storageTypeMin,
350  int64_t storageTypeMax);
351 
352  /// Gets the quantization scales. The scales designate the difference between
353  /// the real values corresponding to consecutive quantized values differing
354  /// by 1. The ith scale corresponds to the ith slice in the
355  /// quantized_dimension.
356  ArrayRef<double> getScales() const;
357 
358  /// Gets the storage values corresponding to the real value 0 in the affine
359  /// equation. The ith zero point corresponds to the ith slice in the
360  /// quantized_dimension.
362 
363  /// Specifies the dimension of the Tensor's shape that the scales and
364  /// zero_points correspond to. For example, a tensor t, with dims=[4, 3, 2, 1]
365  /// with quantization params:
366  /// scales=[1.0, 2.0, 3.0], zeroPoints=[1, 2, 3], quantizedDimension=1
367  /// will be quantized across the second dimension of t.
368  /// t[:, 0, :, :] will have scale[0]=1.0, zero_point[0]=1
369  /// t[:, 1, :, :] will have scale[1]=2.0, zero_point[0]=2
370  /// t[:, 2, :, :] will have scale[2]=3.0, zero_point[0]=3
371  int32_t getQuantizedDimension() const;
372 
373  /// Fixed point values are real numbers divided by a scale.
374  /// Currently, only signed storage types are treated as fixed point.
375  /// A fixed point value can be obtained from an affine value by subtracting
376  /// the zeroPoint.
377  /// In the future, this may be explicit versus implied by type and zeroPoint.
378  bool isFixedPoint() const {
379  if (!isSigned())
380  return false;
381  return !llvm::is_contained(getZeroPoints(), 0);
382  }
383 };
384 
385 /// A quantized type that infers its range from given min/max values.
386 ///
387 /// Typical syntax:
388 /// quant.calibrated<f32<-0.922,0.981>>
390  : public Type::TypeBase<CalibratedQuantizedType, QuantizedType,
391  detail::CalibratedQuantizedTypeStorage> {
392 public:
393  using Base::Base;
394  using Base::getChecked;
395 
396  static constexpr StringLiteral name = "quant.calibrated";
397 
398  /// Gets an instance of the type with all parameters specified but not
399  /// checked.
400  static CalibratedQuantizedType get(Type expressedType, double min,
401  double max);
402 
403  /// Gets an instance of the type with all specified parameters checked.
404  /// Returns a nullptr convertible type on failure.
407  double min, double max);
408 
409  /// Verifies construction invariants and issues errors/warnings.
410  static LogicalResult
412  Type expressedType, double min, double max);
413  double getMin() const;
414  double getMax() const;
415 };
416 
417 } // namespace quant
418 } // namespace mlir
419 
420 #endif // MLIR_DIALECT_QUANT_IR_QUANTTYPES_H
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)
static Value min(ImplicitLocOpBuilder &builder, Value value, Value bound)
This class represents a diagnostic that is inflight and set to be reported.
Definition: Diagnostics.h:314
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition: Types.h:74
bool isF64() const
Definition: Types.cpp:60
bool isIndex() const
Definition: Types.cpp:64
constexpr Type()=default
bool isF32() const
Definition: Types.cpp:59
bool isInteger() const
Return true if this is an integer type (with the specified width).
Definition: Types.cpp:66
bool isF16() const
Definition: Types.cpp:57
bool isBF16() const
Definition: Types.cpp:56
Utility class for implementing users of storage classes uniqued by a StorageUniquer.
A quantized type that maps storage to/from expressed types in an unspecified way.
Definition: QuantTypes.h:200
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.
Definition: QuantTypes.cpp:245
static constexpr StringLiteral name
Definition: QuantTypes.h:205
static LogicalResult verifyInvariants(function_ref< InFlightDiagnostic()> emitError, unsigned flags, Type storageType, Type expressedType, int64_t storageTypeMin, int64_t storageTypeMax)
Verifies construction invariants and issues errors/warnings.
Definition: QuantTypes.cpp:264
static AnyQuantizedType getChecked(function_ref< InFlightDiagnostic()> emitError, unsigned flags, Type storageType, Type expressedType, int64_t storageTypeMin, int64_t storageTypeMax)
Gets an instance of the type with all specified parameters checked.
Definition: QuantTypes.cpp:254
A quantized type that infers its range from given min/max values.
Definition: QuantTypes.h:391
static constexpr StringLiteral name
Definition: QuantTypes.h:396
static LogicalResult verifyInvariants(function_ref< InFlightDiagnostic()> emitError, Type expressedType, double min, double max)
Verifies construction invariants and issues errors/warnings.
Definition: QuantTypes.cpp:425
static CalibratedQuantizedType get(Type expressedType, double min, double max)
Gets an instance of the type with all parameters specified but not checked.
Definition: QuantTypes.cpp:413
static CalibratedQuantizedType getChecked(function_ref< InFlightDiagnostic()> emitError, Type expressedType, double min, double max)
Gets an instance of the type with all specified parameters checked.
Definition: QuantTypes.cpp:418
Base class for all quantized types known to this dialect.
Definition: QuantTypes.h:49
Type getExpressedType() const
Gets the original expressed type that this quantized type approximates.
Definition: QuantTypes.cpp:109
static constexpr unsigned MaxStorageBits
The maximum number of bits supported for storage types.
Definition: QuantTypes.h:55
bool hasStorageTypeBounds() const
Return whether the storage type has explicit min or max boundaries different from the minimum and max...
Definition: QuantTypes.cpp:92
static Type castToStorageType(Type quantizedType)
Casts from a type based on a QuantizedType to a corresponding type based on the storageType (returns ...
Definition: QuantTypes.cpp:155
Type castExpressedToStorageType(Type candidateType)
Casts from a type based on the expressedType to the equivalent type based on storageType by way of th...
Definition: QuantTypes.cpp:237
static Type castToExpressedType(Type quantizedType)
Casts from a type based on QuantizedType to a corresponding type based on the expressedType (returns ...
Definition: QuantTypes.cpp:210
bool isSigned() const
Whether the storage type should be interpreted as a signed quantity (true) or an unsigned value (fals...
Definition: QuantTypes.h:102
static QuantizedType getQuantizedElementType(Type primitiveOrContainerType)
Returns the element type as a QuantizedType or nullptr if it is not a quantized type.
Definition: QuantTypes.cpp:122
unsigned getFlags() const
Gets the flags associated with this type.
Definition: QuantTypes.cpp:39
int64_t getStorageTypeMax() const
The maximum value that storageType can take.
Definition: QuantTypes.cpp:88
static int64_t getDefaultMaximumForInteger(bool isSigned, unsigned integralWidth)
Gets the maximum possible stored by a storageType.
Definition: QuantTypes.h:77
unsigned getStorageTypeIntegralWidth() const
Gets the integral bit width that the underlying storage type can exactly represent.
Definition: QuantTypes.cpp:103
static bool classof(Type type)
Support method to enable LLVM-style type casting.
Definition: QuantTypes.cpp:43
Type castFromStorageType(Type candidateType)
Casts from a type based on the storageType to a corresponding type based on this type (returns nullpt...
Definition: QuantTypes.cpp:131
int64_t getStorageTypeMin() const
The minimum value that storageType can take.
Definition: QuantTypes.cpp:84
static int64_t getDefaultMinimumForInteger(bool isSigned, unsigned integralWidth)
Gets the minimum possible stored by a storageType.
Definition: QuantTypes.h:67
Type getStorageType() const
Gets the underlying type used for to store values.
Definition: QuantTypes.cpp:80
Type castFromExpressedType(Type candidateType)
Casts from a type based on the expressedType to a corresponding type based on this type (returns null...
Definition: QuantTypes.cpp:182
bool isCompatibleExpressedType(Type candidateExpressedType)
Returns whether the candidateExpressedType is a match for this QuantizedType.
Definition: QuantTypes.cpp:113
static LogicalResult verifyInvariants(function_ref< InFlightDiagnostic()> emitError, unsigned flags, Type storageType, Type expressedType, int64_t storageTypeMin, int64_t storageTypeMax)
Definition: QuantTypes.cpp:48
Represents per-axis (also known as per-channel quantization).
Definition: QuantTypes.h:321
static constexpr StringLiteral name
Definition: QuantTypes.h:326
static UniformQuantizedPerAxisType getChecked(function_ref< InFlightDiagnostic()> emitError, unsigned flags, Type storageType, Type expressedType, ArrayRef< double > scales, ArrayRef< int64_t > zeroPoints, int32_t quantizedDimension, int64_t storageTypeMin, int64_t storageTypeMax)
Gets an instance of the type with all specified parameters checked.
Definition: QuantTypes.cpp:348
bool isFixedPoint() const
Fixed point values are real numbers divided by a scale.
Definition: QuantTypes.h:378
static UniformQuantizedPerAxisType get(unsigned flags, Type storageType, Type expressedType, ArrayRef< double > scales, ArrayRef< int64_t > zeroPoints, int32_t quantizedDimension, int64_t storageTypeMin, int64_t storageTypeMax)
Gets an instance of the type with all parameters specified but not checked.
Definition: QuantTypes.cpp:338
int32_t getQuantizedDimension() const
Specifies the dimension of the Tensor's shape that the scales and zero_points correspond to.
Definition: QuantTypes.cpp:409
ArrayRef< int64_t > getZeroPoints() const
Gets the storage values corresponding to the real value 0 in the affine equation.
Definition: QuantTypes.cpp:405
ArrayRef< double > getScales() const
Gets the quantization scales.
Definition: QuantTypes.cpp:401
static LogicalResult verifyInvariants(function_ref< InFlightDiagnostic()> emitError, unsigned flags, Type storageType, Type expressedType, ArrayRef< double > scales, ArrayRef< int64_t > zeroPoints, int32_t quantizedDimension, int64_t storageTypeMin, int64_t storageTypeMax)
Verifies construction invariants and issues errors/warnings.
Definition: QuantTypes.cpp:358
Represents a family of uniform, quantized types.
Definition: QuantTypes.h:261
double getScale() const
Gets the scale term.
Definition: QuantTypes.cpp:332
int64_t getZeroPoint() const
Gets the storage value corresponding to the real value 0 in the affine equation.
Definition: QuantTypes.cpp:334
static constexpr StringLiteral name
Definition: QuantTypes.h:266
static LogicalResult verifyInvariants(function_ref< InFlightDiagnostic()> emitError, unsigned flags, Type storageType, Type expressedType, double scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax)
Verifies construction invariants and issues errors/warnings.
Definition: QuantTypes.cpp:301
static UniformQuantizedType getChecked(function_ref< InFlightDiagnostic()> emitError, unsigned flags, Type storageType, Type expressedType, double scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax)
Gets an instance of the type with all specified parameters checked.
Definition: QuantTypes.cpp:292
static UniformQuantizedType get(unsigned flags, Type storageType, Type expressedType, double scale, int64_t zeroPoint, int64_t storageTypeMin, int64_t storageTypeMax)
Gets an instance of the type with all parameters specified but not checked.
Definition: QuantTypes.cpp:283
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.