[mlir] Call hash_combine_range with ranges (NFC) (#136512)

This commit is contained in:
Kazu Hirata 2025-04-20 16:36:35 -07:00 committed by GitHub
parent b01e25deba
commit 5e834b9ec7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 17 additions and 22 deletions

View File

@ -260,7 +260,7 @@ public:
// Make Polynomials hashable.
template <class D, typename T>
inline ::llvm::hash_code hash_value(const PolynomialBase<D, T> &arg) {
return ::llvm::hash_combine_range(arg.terms.begin(), arg.terms.end());
return ::llvm::hash_combine_range(arg.terms);
}
template <class D, typename T>

View File

@ -185,7 +185,7 @@ struct DenseMapInfo<mlir::SuccessorRange> {
return mlir::SuccessorRange(pointer, 0);
}
static unsigned getHashValue(mlir::SuccessorRange value) {
return llvm::hash_combine_range(value.begin(), value.end());
return llvm::hash_combine_range(value);
}
static bool isEqual(mlir::SuccessorRange lhs, mlir::SuccessorRange rhs) {
if (rhs.getBase() == getEmptyKey().getBase())

View File

@ -72,7 +72,7 @@ private:
/// Make TypeRange hashable.
inline ::llvm::hash_code hash_value(TypeRange arg) {
return ::llvm::hash_combine_range(arg.begin(), arg.end());
return ::llvm::hash_combine_range(arg);
}
/// Emit a type range to the given output stream.

View File

@ -207,11 +207,10 @@ struct UniformQuantizedPerAxisTypeStorage : public QuantizedTypeStorage {
unsigned getHashValue() const {
int64_t *scalesCast = llvm::bit_cast<int64_t *>(scales.data());
ArrayRef<int64_t> scalesBits(scalesCast, scales.size());
return llvm::hash_combine(
flags, storageType, expressedType,
llvm::hash_combine_range(scalesBits.begin(), scalesBits.end()),
llvm::hash_combine_range(zeroPoints.begin(), zeroPoints.end()),
storageTypeMin, storageTypeMax);
return llvm::hash_combine(flags, storageType, expressedType,
llvm::hash_combine_range(scalesBits),
llvm::hash_combine_range(zeroPoints),
storageTypeMin, storageTypeMax);
}
};
@ -318,11 +317,9 @@ struct UniformQuantizedSubChannelTypeStorage : public QuantizedTypeStorage {
}
// Hash the quantized dimensions and block sizes.
hash = llvm::hash_combine(
hash,
llvm::hash_combine_range(quantizedDimensions.begin(),
quantizedDimensions.end()),
llvm::hash_combine_range(blockSizes.begin(), blockSizes.end()));
hash = llvm::hash_combine(hash,
llvm::hash_combine_range(quantizedDimensions),
llvm::hash_combine_range(blockSizes));
return hash;
}

View File

@ -79,9 +79,8 @@ static llvm::hash_code computeHash(SymbolOpInterface symbolOp) {
return attr.getName() != SymbolTable::getSymbolAttrName();
});
return llvm::hash_combine(
symbolOp->getName(),
llvm::hash_combine_range(range.begin(), range.end()));
return llvm::hash_combine(symbolOp->getName(),
llvm::hash_combine_range(range));
}
namespace mlir {

View File

@ -238,7 +238,7 @@ struct OffsetMapInfo {
static SmallVector<int64_t> getTombstoneKey() { return {int64_t(-2)}; }
static unsigned getHashValue(const SmallVector<int64_t> &v) {
return static_cast<unsigned>(llvm::hash_combine_range(v.begin(), v.end()));
return static_cast<unsigned>(llvm::hash_combine_range(v));
}
static bool isEqual(const SmallVector<int64_t> &lhs,

View File

@ -106,7 +106,7 @@ struct ValueVectorMapInfo {
static ValueVector getEmptyKey() { return ValueVector{Value()}; }
static ValueVector getTombstoneKey() { return ValueVector{Value(), Value()}; }
static ::llvm::hash_code getHashValue(const ValueVector &val) {
return ::llvm::hash_combine_range(val.begin(), val.end());
return ::llvm::hash_combine_range(val);
}
static bool isEqual(const ValueVector &LHS, const ValueVector &RHS) {
return LHS == RHS;

View File

@ -96,10 +96,9 @@ inline llvm::hash_code computeHash(const TestProperties &prop) {
// We hash `b` which is a float using its underlying array of char:
unsigned char const *p = reinterpret_cast<unsigned char const *>(&prop.b);
ArrayRef<unsigned char> bBytes{p, sizeof(prop.b)};
return llvm::hash_combine(
prop.a, llvm::hash_combine_range(bBytes.begin(), bBytes.end()),
llvm::hash_combine_range(prop.array.begin(), prop.array.end()),
StringRef(*prop.label));
return llvm::hash_combine(prop.a, llvm::hash_combine_range(bBytes),
llvm::hash_combine_range(prop.array),
StringRef(*prop.label));
}
/// A custom operation for the purpose of showcasing how to use "properties".