Skip to content

Commit 60250c1

Browse files
authored
Revert "[mlir]: Added properties/attributes ignore flags to OperationEquivalence" (#142319)
Reverts #141664 See #141664 (comment)
1 parent 002c0ab commit 60250c1

File tree

3 files changed

+8
-50
lines changed

3 files changed

+8
-50
lines changed

mlir/include/mlir/IR/OperationSupport.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,14 +1322,7 @@ struct OperationEquivalence {
13221322
// When provided, the location attached to the operation are ignored.
13231323
IgnoreLocations = 1,
13241324

1325-
// When provided, the discardable attributes attached to the operation are
1326-
// ignored.
1327-
IgnoreDiscardableAttrs = 2,
1328-
1329-
// When provided, the properties attached to the operation are ignored.
1330-
IgnoreProperties = 4,
1331-
1332-
LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IgnoreProperties)
1325+
LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IgnoreLocations)
13331326
};
13341327

13351328
/// Compute a hash for the given operation.

mlir/lib/IR/OperationSupport.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -680,14 +680,9 @@ llvm::hash_code OperationEquivalence::computeHash(
680680
// - Operation Name
681681
// - Attributes
682682
// - Result Types
683-
DictionaryAttr dictAttrs;
684-
if (!(flags & Flags::IgnoreDiscardableAttrs))
685-
dictAttrs = op->getRawDictionaryAttrs();
686-
llvm::hash_code hashProperties;
687-
if (!(flags & Flags::IgnoreProperties))
688-
hashProperties = op->hashProperties();
689-
llvm::hash_code hash = llvm::hash_combine(
690-
op->getName(), dictAttrs, op->getResultTypes(), hashProperties);
683+
llvm::hash_code hash =
684+
llvm::hash_combine(op->getName(), op->getRawDictionaryAttrs(),
685+
op->getResultTypes(), op->hashProperties());
691686

692687
// - Location if required
693688
if (!(flags & Flags::IgnoreLocations))
@@ -841,19 +836,14 @@ OperationEquivalence::isRegionEquivalentTo(Region *lhs, Region *rhs,
841836
return true;
842837

843838
// 1. Compare the operation properties.
844-
if (!(flags & IgnoreDiscardableAttrs) &&
845-
lhs->getRawDictionaryAttrs() != rhs->getRawDictionaryAttrs())
846-
return false;
847-
848839
if (lhs->getName() != rhs->getName() ||
840+
lhs->getRawDictionaryAttrs() != rhs->getRawDictionaryAttrs() ||
849841
lhs->getNumRegions() != rhs->getNumRegions() ||
850842
lhs->getNumSuccessors() != rhs->getNumSuccessors() ||
851843
lhs->getNumOperands() != rhs->getNumOperands() ||
852-
lhs->getNumResults() != rhs->getNumResults())
853-
return false;
854-
if (!(flags & IgnoreProperties) &&
855-
!(lhs->getName().compareOpProperties(lhs->getPropertiesStorage(),
856-
rhs->getPropertiesStorage())))
844+
lhs->getNumResults() != rhs->getNumResults() ||
845+
!lhs->getName().compareOpProperties(lhs->getPropertiesStorage(),
846+
rhs->getPropertiesStorage()))
857847
return false;
858848
if (!(flags & IgnoreLocations) && lhs->getLoc() != rhs->getLoc())
859849
return false;

mlir/unittests/IR/OperationSupportTest.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ TEST(OperandStorageTest, PopulateDefaultAttrs) {
315315
TEST(OperationEquivalenceTest, HashWorksWithFlags) {
316316
MLIRContext context;
317317
context.getOrLoadDialect<test::TestDialect>();
318-
OpBuilder b(&context);
319318

320319
auto *op1 = createOp(&context);
321320
// `op1` has an unknown loc.
@@ -326,36 +325,12 @@ TEST(OperationEquivalenceTest, HashWorksWithFlags) {
326325
op, OperationEquivalence::ignoreHashValue,
327326
OperationEquivalence::ignoreHashValue, flags);
328327
};
329-
// Check ignore location.
330328
EXPECT_EQ(getHash(op1, OperationEquivalence::IgnoreLocations),
331329
getHash(op2, OperationEquivalence::IgnoreLocations));
332330
EXPECT_NE(getHash(op1, OperationEquivalence::None),
333331
getHash(op2, OperationEquivalence::None));
334-
op1->setLoc(NameLoc::get(StringAttr::get(&context, "foo")));
335-
// Check ignore discardable dictionary attributes.
336-
SmallVector<NamedAttribute> newAttrs = {
337-
b.getNamedAttr("foo", b.getStringAttr("f"))};
338-
op1->setAttrs(newAttrs);
339-
EXPECT_EQ(getHash(op1, OperationEquivalence::IgnoreDiscardableAttrs),
340-
getHash(op2, OperationEquivalence::IgnoreDiscardableAttrs));
341-
EXPECT_NE(getHash(op1, OperationEquivalence::None),
342-
getHash(op2, OperationEquivalence::None));
343332
op1->destroy();
344333
op2->destroy();
345-
346-
// Check ignore properties.
347-
auto req1 = b.getI32IntegerAttr(10);
348-
Operation *opWithProperty1 = b.create<test::OpAttrMatch1>(
349-
b.getUnknownLoc(), req1, nullptr, nullptr, req1);
350-
auto req2 = b.getI32IntegerAttr(60);
351-
Operation *opWithProperty2 = b.create<test::OpAttrMatch1>(
352-
b.getUnknownLoc(), req2, nullptr, nullptr, req2);
353-
EXPECT_NE(getHash(op1, OperationEquivalence::None),
354-
getHash(op2, OperationEquivalence::None));
355-
EXPECT_EQ(getHash(opWithProperty1, OperationEquivalence::IgnoreProperties),
356-
getHash(opWithProperty2, OperationEquivalence::IgnoreProperties));
357-
opWithProperty1->destroy();
358-
opWithProperty2->destroy();
359334
}
360335

361336
} // namespace

0 commit comments

Comments
 (0)