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);
260 #endif // TYPE_DETAIL_H_ Definition: InferTypeOpInterface.cpp:20
Definition: TypeDetail.h:45
Definition: TypeDetail.h:23
Base storage class appearing in a Type.
Definition: TypeSupport.h:33
Definition: StorageUniquer.h:89
static unsigned hashKey(const KeyTy &key)
Definition: TypeDetail.h:92
int64_t storageTypeMax
Definition: TypeDetail.h:42
static AnyQuantizedTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)
Construction.
Definition: TypeDetail.h:86
Type storageType
Definition: TypeDetail.h:33
Type storageType
Definition: TypeDetail.h:52
unsigned flags
Definition: TypeDetail.h:51
T * allocate()
Allocate an instance of the provided type.
Definition: StorageUniquer.h:109
KeyTy(unsigned flags, Type storageType, Type expressedType, int64_t storageTypeMin, int64_t storageTypeMax)
Definition: TypeDetail.h:47
QuantizedTypeStorage(unsigned flags, Type storageType, Type expressedType, int64_t storageTypeMin, int64_t storageTypeMax)
Definition: TypeDetail.h:24
AnyQuantizedTypeStorage(const KeyTy &key)
Definition: TypeDetail.h:77
Definition: TypeDetail.h:46
unsigned flags
Flags corresponding to the bitmapped enum QuantizationFlags::FlagValue.
Definition: TypeDetail.h:30
Type expressedType
Definition: TypeDetail.h:36
unsigned getHashValue() const
Definition: TypeDetail.h:71
static bool genericIsEqual(const T &lhs, const U &rhs)
Definition: TypeDetail.h:60
bool operator==(const KeyTy &other) const
Definition: TypeDetail.h:67
ArrayRef< T > copyInto(ArrayRef< T > elements)
Definition: StorageUniquer.h:93
Type expressedType
Definition: TypeDetail.h:53
int64_t storageTypeMax
Definition: TypeDetail.h:55
int64_t storageTypeMin
Definition: TypeDetail.h:54
int64_t storageTypeMin
Definition: TypeDetail.h:39
bool operator==(const KeyTy &key) const
Definition: TypeDetail.h:81