-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[mlir] Call hash_combine_range with ranges (NFC) #136512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_hash_combine_range_mlir
Apr 20, 2025
Merged
[mlir] Call hash_combine_range with ranges (NFC) #136512
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_hash_combine_range_mlir
Apr 20, 2025
+17
−22
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-mlir-spirv @llvm/pr-subscribers-mlir Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/136512.diff 8 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h b/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
index 3f206cd1e545a..8d7f1436fdc60 100644
--- a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
+++ b/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
@@ -260,7 +260,7 @@ class FloatPolynomial : public PolynomialBase<FloatPolynomial, FloatMonomial> {
// 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>
diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h
index 292938e46c27e..41434269d555b 100644
--- a/mlir/include/mlir/IR/BlockSupport.h
+++ b/mlir/include/mlir/IR/BlockSupport.h
@@ -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())
diff --git a/mlir/include/mlir/IR/TypeRange.h b/mlir/include/mlir/IR/TypeRange.h
index 3fb58d78617c0..e098370ae6e58 100644
--- a/mlir/include/mlir/IR/TypeRange.h
+++ b/mlir/include/mlir/IR/TypeRange.h
@@ -72,7 +72,7 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base<
/// 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.
diff --git a/mlir/lib/Dialect/Quant/IR/TypeDetail.h b/mlir/lib/Dialect/Quant/IR/TypeDetail.h
index bb38b1a2a91e2..a43bce354c324 100644
--- a/mlir/lib/Dialect/Quant/IR/TypeDetail.h
+++ b/mlir/lib/Dialect/Quant/IR/TypeDetail.h
@@ -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;
}
diff --git a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
index 1f708c2ae37ad..71122f8e20512 100644
--- a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
+++ b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
@@ -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 {
diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
index cb348b28c876a..dffb13c3a7923 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
@@ -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,
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index a56fca25e1697..962207059c8aa 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -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;
diff --git a/mlir/unittests/IR/OpPropertiesTest.cpp b/mlir/unittests/IR/OpPropertiesTest.cpp
index b4a633a2c62e6..4759735d99605 100644
--- a/mlir/unittests/IR/OpPropertiesTest.cpp
+++ b/mlir/unittests/IR/OpPropertiesTest.cpp
@@ -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".
|
@llvm/pr-subscribers-mlir-vector Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/136512.diff 8 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h b/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
index 3f206cd1e545a..8d7f1436fdc60 100644
--- a/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
+++ b/mlir/include/mlir/Dialect/Polynomial/IR/Polynomial.h
@@ -260,7 +260,7 @@ class FloatPolynomial : public PolynomialBase<FloatPolynomial, FloatMonomial> {
// 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>
diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h
index 292938e46c27e..41434269d555b 100644
--- a/mlir/include/mlir/IR/BlockSupport.h
+++ b/mlir/include/mlir/IR/BlockSupport.h
@@ -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())
diff --git a/mlir/include/mlir/IR/TypeRange.h b/mlir/include/mlir/IR/TypeRange.h
index 3fb58d78617c0..e098370ae6e58 100644
--- a/mlir/include/mlir/IR/TypeRange.h
+++ b/mlir/include/mlir/IR/TypeRange.h
@@ -72,7 +72,7 @@ class TypeRange : public llvm::detail::indexed_accessor_range_base<
/// 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.
diff --git a/mlir/lib/Dialect/Quant/IR/TypeDetail.h b/mlir/lib/Dialect/Quant/IR/TypeDetail.h
index bb38b1a2a91e2..a43bce354c324 100644
--- a/mlir/lib/Dialect/Quant/IR/TypeDetail.h
+++ b/mlir/lib/Dialect/Quant/IR/TypeDetail.h
@@ -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;
}
diff --git a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
index 1f708c2ae37ad..71122f8e20512 100644
--- a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
+++ b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
@@ -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 {
diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
index cb348b28c876a..dffb13c3a7923 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
@@ -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,
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index a56fca25e1697..962207059c8aa 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -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;
diff --git a/mlir/unittests/IR/OpPropertiesTest.cpp b/mlir/unittests/IR/OpPropertiesTest.cpp
index b4a633a2c62e6..4759735d99605 100644
--- a/mlir/unittests/IR/OpPropertiesTest.cpp
+++ b/mlir/unittests/IR/OpPropertiesTest.cpp
@@ -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".
|
tgymnich
approved these changes
Apr 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.