-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Revert "[mlir]: Added properties/attributes ignore flags to OperationEquivalence" #142319
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
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
…Equivale…" This reverts commit c5f3018.
@llvm/pr-subscribers-mlir-core Author: Vitaly Buka (vitalybuka) ChangesReverts llvm/llvm-project#141664 Full diff: https://github.com/llvm/llvm-project/pull/142319.diff 3 Files Affected:
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index 65e6d4f64e36c..0046d977c68f4 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -1322,14 +1322,7 @@ struct OperationEquivalence {
// When provided, the location attached to the operation are ignored.
IgnoreLocations = 1,
- // When provided, the discardable attributes attached to the operation are
- // ignored.
- IgnoreDiscardableAttrs = 2,
-
- // When provided, the properties attached to the operation are ignored.
- IgnoreProperties = 4,
-
- LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IgnoreProperties)
+ LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IgnoreLocations)
};
/// Compute a hash for the given operation.
diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp
index b591b50f2d0dc..7c9e6c89d4d8e 100644
--- a/mlir/lib/IR/OperationSupport.cpp
+++ b/mlir/lib/IR/OperationSupport.cpp
@@ -680,14 +680,9 @@ llvm::hash_code OperationEquivalence::computeHash(
// - Operation Name
// - Attributes
// - Result Types
- DictionaryAttr dictAttrs;
- if (!(flags & Flags::IgnoreDiscardableAttrs))
- dictAttrs = op->getRawDictionaryAttrs();
- llvm::hash_code hashProperties;
- if (!(flags & Flags::IgnoreProperties))
- hashProperties = op->hashProperties();
- llvm::hash_code hash = llvm::hash_combine(
- op->getName(), dictAttrs, op->getResultTypes(), hashProperties);
+ llvm::hash_code hash =
+ llvm::hash_combine(op->getName(), op->getRawDictionaryAttrs(),
+ op->getResultTypes(), op->hashProperties());
// - Location if required
if (!(flags & Flags::IgnoreLocations))
@@ -841,19 +836,14 @@ OperationEquivalence::isRegionEquivalentTo(Region *lhs, Region *rhs,
return true;
// 1. Compare the operation properties.
- if (!(flags & IgnoreDiscardableAttrs) &&
- lhs->getRawDictionaryAttrs() != rhs->getRawDictionaryAttrs())
- return false;
-
if (lhs->getName() != rhs->getName() ||
+ lhs->getRawDictionaryAttrs() != rhs->getRawDictionaryAttrs() ||
lhs->getNumRegions() != rhs->getNumRegions() ||
lhs->getNumSuccessors() != rhs->getNumSuccessors() ||
lhs->getNumOperands() != rhs->getNumOperands() ||
- lhs->getNumResults() != rhs->getNumResults())
- return false;
- if (!(flags & IgnoreProperties) &&
- !(lhs->getName().compareOpProperties(lhs->getPropertiesStorage(),
- rhs->getPropertiesStorage())))
+ lhs->getNumResults() != rhs->getNumResults() ||
+ !lhs->getName().compareOpProperties(lhs->getPropertiesStorage(),
+ rhs->getPropertiesStorage()))
return false;
if (!(flags & IgnoreLocations) && lhs->getLoc() != rhs->getLoc())
return false;
diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp
index b18512817969e..bac2b72b68deb 100644
--- a/mlir/unittests/IR/OperationSupportTest.cpp
+++ b/mlir/unittests/IR/OperationSupportTest.cpp
@@ -315,7 +315,6 @@ TEST(OperandStorageTest, PopulateDefaultAttrs) {
TEST(OperationEquivalenceTest, HashWorksWithFlags) {
MLIRContext context;
context.getOrLoadDialect<test::TestDialect>();
- OpBuilder b(&context);
auto *op1 = createOp(&context);
// `op1` has an unknown loc.
@@ -326,36 +325,12 @@ TEST(OperationEquivalenceTest, HashWorksWithFlags) {
op, OperationEquivalence::ignoreHashValue,
OperationEquivalence::ignoreHashValue, flags);
};
- // Check ignore location.
EXPECT_EQ(getHash(op1, OperationEquivalence::IgnoreLocations),
getHash(op2, OperationEquivalence::IgnoreLocations));
EXPECT_NE(getHash(op1, OperationEquivalence::None),
getHash(op2, OperationEquivalence::None));
- op1->setLoc(NameLoc::get(StringAttr::get(&context, "foo")));
- // Check ignore discardable dictionary attributes.
- SmallVector<NamedAttribute> newAttrs = {
- b.getNamedAttr("foo", b.getStringAttr("f"))};
- op1->setAttrs(newAttrs);
- EXPECT_EQ(getHash(op1, OperationEquivalence::IgnoreDiscardableAttrs),
- getHash(op2, OperationEquivalence::IgnoreDiscardableAttrs));
- EXPECT_NE(getHash(op1, OperationEquivalence::None),
- getHash(op2, OperationEquivalence::None));
op1->destroy();
op2->destroy();
-
- // Check ignore properties.
- auto req1 = b.getI32IntegerAttr(10);
- Operation *opWithProperty1 = b.create<test::OpAttrMatch1>(
- b.getUnknownLoc(), req1, nullptr, nullptr, req1);
- auto req2 = b.getI32IntegerAttr(60);
- Operation *opWithProperty2 = b.create<test::OpAttrMatch1>(
- b.getUnknownLoc(), req2, nullptr, nullptr, req2);
- EXPECT_NE(getHash(op1, OperationEquivalence::None),
- getHash(op2, OperationEquivalence::None));
- EXPECT_EQ(getHash(opWithProperty1, OperationEquivalence::IgnoreProperties),
- getHash(opWithProperty2, OperationEquivalence::IgnoreProperties));
- opWithProperty1->destroy();
- opWithProperty2->destroy();
}
} // namespace
|
@llvm/pr-subscribers-mlir Author: Vitaly Buka (vitalybuka) ChangesReverts llvm/llvm-project#141664 Full diff: https://github.com/llvm/llvm-project/pull/142319.diff 3 Files Affected:
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index 65e6d4f64e36c..0046d977c68f4 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -1322,14 +1322,7 @@ struct OperationEquivalence {
// When provided, the location attached to the operation are ignored.
IgnoreLocations = 1,
- // When provided, the discardable attributes attached to the operation are
- // ignored.
- IgnoreDiscardableAttrs = 2,
-
- // When provided, the properties attached to the operation are ignored.
- IgnoreProperties = 4,
-
- LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IgnoreProperties)
+ LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IgnoreLocations)
};
/// Compute a hash for the given operation.
diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp
index b591b50f2d0dc..7c9e6c89d4d8e 100644
--- a/mlir/lib/IR/OperationSupport.cpp
+++ b/mlir/lib/IR/OperationSupport.cpp
@@ -680,14 +680,9 @@ llvm::hash_code OperationEquivalence::computeHash(
// - Operation Name
// - Attributes
// - Result Types
- DictionaryAttr dictAttrs;
- if (!(flags & Flags::IgnoreDiscardableAttrs))
- dictAttrs = op->getRawDictionaryAttrs();
- llvm::hash_code hashProperties;
- if (!(flags & Flags::IgnoreProperties))
- hashProperties = op->hashProperties();
- llvm::hash_code hash = llvm::hash_combine(
- op->getName(), dictAttrs, op->getResultTypes(), hashProperties);
+ llvm::hash_code hash =
+ llvm::hash_combine(op->getName(), op->getRawDictionaryAttrs(),
+ op->getResultTypes(), op->hashProperties());
// - Location if required
if (!(flags & Flags::IgnoreLocations))
@@ -841,19 +836,14 @@ OperationEquivalence::isRegionEquivalentTo(Region *lhs, Region *rhs,
return true;
// 1. Compare the operation properties.
- if (!(flags & IgnoreDiscardableAttrs) &&
- lhs->getRawDictionaryAttrs() != rhs->getRawDictionaryAttrs())
- return false;
-
if (lhs->getName() != rhs->getName() ||
+ lhs->getRawDictionaryAttrs() != rhs->getRawDictionaryAttrs() ||
lhs->getNumRegions() != rhs->getNumRegions() ||
lhs->getNumSuccessors() != rhs->getNumSuccessors() ||
lhs->getNumOperands() != rhs->getNumOperands() ||
- lhs->getNumResults() != rhs->getNumResults())
- return false;
- if (!(flags & IgnoreProperties) &&
- !(lhs->getName().compareOpProperties(lhs->getPropertiesStorage(),
- rhs->getPropertiesStorage())))
+ lhs->getNumResults() != rhs->getNumResults() ||
+ !lhs->getName().compareOpProperties(lhs->getPropertiesStorage(),
+ rhs->getPropertiesStorage()))
return false;
if (!(flags & IgnoreLocations) && lhs->getLoc() != rhs->getLoc())
return false;
diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp
index b18512817969e..bac2b72b68deb 100644
--- a/mlir/unittests/IR/OperationSupportTest.cpp
+++ b/mlir/unittests/IR/OperationSupportTest.cpp
@@ -315,7 +315,6 @@ TEST(OperandStorageTest, PopulateDefaultAttrs) {
TEST(OperationEquivalenceTest, HashWorksWithFlags) {
MLIRContext context;
context.getOrLoadDialect<test::TestDialect>();
- OpBuilder b(&context);
auto *op1 = createOp(&context);
// `op1` has an unknown loc.
@@ -326,36 +325,12 @@ TEST(OperationEquivalenceTest, HashWorksWithFlags) {
op, OperationEquivalence::ignoreHashValue,
OperationEquivalence::ignoreHashValue, flags);
};
- // Check ignore location.
EXPECT_EQ(getHash(op1, OperationEquivalence::IgnoreLocations),
getHash(op2, OperationEquivalence::IgnoreLocations));
EXPECT_NE(getHash(op1, OperationEquivalence::None),
getHash(op2, OperationEquivalence::None));
- op1->setLoc(NameLoc::get(StringAttr::get(&context, "foo")));
- // Check ignore discardable dictionary attributes.
- SmallVector<NamedAttribute> newAttrs = {
- b.getNamedAttr("foo", b.getStringAttr("f"))};
- op1->setAttrs(newAttrs);
- EXPECT_EQ(getHash(op1, OperationEquivalence::IgnoreDiscardableAttrs),
- getHash(op2, OperationEquivalence::IgnoreDiscardableAttrs));
- EXPECT_NE(getHash(op1, OperationEquivalence::None),
- getHash(op2, OperationEquivalence::None));
op1->destroy();
op2->destroy();
-
- // Check ignore properties.
- auto req1 = b.getI32IntegerAttr(10);
- Operation *opWithProperty1 = b.create<test::OpAttrMatch1>(
- b.getUnknownLoc(), req1, nullptr, nullptr, req1);
- auto req2 = b.getI32IntegerAttr(60);
- Operation *opWithProperty2 = b.create<test::OpAttrMatch1>(
- b.getUnknownLoc(), req2, nullptr, nullptr, req2);
- EXPECT_NE(getHash(op1, OperationEquivalence::None),
- getHash(op2, OperationEquivalence::None));
- EXPECT_EQ(getHash(opWithProperty1, OperationEquivalence::IgnoreProperties),
- getHash(opWithProperty2, OperationEquivalence::IgnoreProperties));
- opWithProperty1->destroy();
- opWithProperty2->destroy();
}
} // namespace
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
mlir:core
MLIR Core Infrastructure
mlir
skip-precommit-approval
PR for CI feedback, not intended for review
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.
Reverts #141664
See #141664 (comment)