10 #define TYPE_DETAIL_H_ 15 #include "llvm/ADT/DenseMap.h" 16 #include "llvm/ADT/Hashing.h" 17 #include "llvm/ADT/bit.h" 26 : flags(flags), storageType(storageType), expressedType(expressedType),
27 storageTypeMin(storageTypeMin), storageTypeMax(storageTypeMax) {}
49 : flags(flags), storageType(storageType), expressedType(expressedType),
50 storageTypeMin(storageTypeMin), storageTypeMax(storageTypeMax) {}
59 template <
typename T,
typename U>
61 return lhs.flags == rhs.flags && lhs.storageType == rhs.storageType &&
62 lhs.expressedType == rhs.expressedType &&
63 lhs.storageTypeMin == rhs.storageTypeMin &&
64 lhs.storageTypeMax == rhs.storageTypeMax;
68 return genericIsEqual(*
this, other);
72 return llvm::hash_combine(flags, storageType, expressedType,
73 storageTypeMin, storageTypeMax);
82 return KeyTy::genericIsEqual(*
this, key);
99 : flags(flags), storageType(storageType), expressedType(expressedType),
100 scale(scale), zeroPoint(zeroPoint), storageTypeMin(storageTypeMin),
101 storageTypeMax(storageTypeMax) {}
118 template <
typename T,
typename U>
120 return lhs.flags == rhs.flags && lhs.storageType == rhs.storageType &&
121 lhs.expressedType == rhs.expressedType && lhs.scale == rhs.scale &&
122 lhs.zeroPoint == rhs.zeroPoint &&
123 lhs.storageTypeMin == rhs.storageTypeMin &&
124 lhs.storageTypeMax == rhs.storageTypeMax;
128 return genericIsEqual(*
this, other);
132 int64_t scaleBits = llvm::bit_cast<int64_t>(scale);
133 return llvm::hash_combine(flags, storageType, expressedType, scaleBits,
134 zeroPoint, storageTypeMin, storageTypeMax);
141 scale(key.scale), zeroPoint(key.zeroPoint) {}
144 return KeyTy::genericIsEqual(*
this, key);
166 : flags(flags), storageType(storageType), expressedType(expressedType),
167 scales(scales), zeroPoints(zeroPoints),
168 quantizedDimension(quantizedDimension),
169 storageTypeMin(storageTypeMin), storageTypeMax(storageTypeMax) {}
191 template <
typename T,
typename U>
193 return lhs.flags == rhs.flags && lhs.storageType == rhs.storageType &&
194 lhs.expressedType == rhs.expressedType &&
195 lhs.getScales() == rhs.getScales() &&
196 lhs.getZeroPoints() == rhs.getZeroPoints() &&
197 lhs.quantizedDimension == rhs.quantizedDimension &&
198 lhs.storageTypeMin == rhs.storageTypeMin &&
199 lhs.storageTypeMax == rhs.storageTypeMax;
203 return genericIsEqual(*
this, other);
207 int64_t *scalesCast = llvm::bit_cast<int64_t *>(scales.data());
209 return llvm::hash_combine(
210 flags, storageType, expressedType,
211 llvm::hash_combine_range(scalesBits.begin(), scalesBits.end()),
212 llvm::hash_combine_range(zeroPoints.begin(), zeroPoints.end()),
213 storageTypeMin, storageTypeMax);
223 scaleElements(scales.data()), zeroPointElements(zeroPoints.data()),
224 quantParamsSize(scales.size()),
225 quantizedDimension(key.quantizedDimension) {}
228 return KeyTy::genericIsEqual(*
this, key);
259 : expressedType(expressedType), min(min), max(max) {}
268 template <
typename T,
typename U>
270 return lhs.expressedType == rhs.expressedType && lhs.min == rhs.min &&
275 return genericIsEqual(*
this, other);
279 int64_t minBits = llvm::bit_cast<
double>(
min);
280 int64_t maxBits = llvm::bit_cast<
double>(
max);
281 return llvm::hash_combine(expressedType, minBits, maxBits);
290 return KeyTy::genericIsEqual(*
this, key);
310 #endif // TYPE_DETAIL_H_ Include the generated interface declarations.
static unsigned hashKey(const KeyTy &key)
Base storage class appearing in a Type.
bool operator==(const KeyTy &key) const
This is a utility allocator used to allocate memory for instances of derived types.
static unsigned hashKey(const KeyTy &key)
bool operator==(const KeyTy &other) const
static AnyQuantizedTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
Construction.
T * allocate()
Allocate an instance of the provided type.
static CalibratedQuantizedTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
Construction.
KeyTy(unsigned flags, Type storageType, Type expressedType, int64_t storageTypeMin, int64_t storageTypeMax)
CalibratedQuantizedTypeStorage(const KeyTy &key)
static bool genericIsEqual(const T &lhs, const U &rhs)
QuantizedTypeStorage(unsigned flags, Type storageType, Type expressedType, int64_t storageTypeMin, int64_t storageTypeMax)
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
static Value min(ImplicitLocOpBuilder &builder, Value value, Value bound)
AnyQuantizedTypeStorage(const KeyTy &key)
unsigned flags
Flags corresponding to the bitmapped enum QuantizationFlags::FlagValue.
unsigned getHashValue() const
unsigned getHashValue() const
static bool genericIsEqual(const T &lhs, const U &rhs)
bool operator==(const KeyTy &other) const
ArrayRef< T > copyInto(ArrayRef< T > elements)
Copy the specified array of elements into memory managed by our bump pointer allocator.
KeyTy(Type expressedType, double min, double max)
bool operator==(const KeyTy &key) const
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)