[Mlir-commits] [mlir] Add Python bindings for operation structural equivalence and hashing (PR #216357)
Maksim Levental
llvmlistbot at llvm.org
Fri Aug 14 15:54:43 PDT 2026
================
@@ -3946,6 +3957,34 @@ void populateIRCore(nb::module_ &m) {
return mlirOperationHashValue(self.getOperation().get());
},
"Returns the hash value of the operation.")
+ .def(
+ "is_structurally_equivalent",
+ [](PyOperationBase &self, PyOperationBase &other,
+ PyOperationEquivalenceFlags flags) {
+ self.getOperation().checkValid();
+ other.getOperation().checkValid();
+ return mlirOperationIsStructurallyEquivalent(
+ self.getOperation().get(), other.getOperation().get(),
+ static_cast<uint32_t>(flags));
+ },
+ "other"_a, "flags"_a = PyOperationEquivalenceFlags::None,
+ R"(Checks whether two operations are structurally equivalent.
+
+The IGNORE_LOCATIONS, IGNORE_DISCARDABLE_ATTRS, IGNORE_PROPERTIES, and
+IGNORE_COMMUTATIVITY flags ignore locations, discardable attributes, properties,
+and commutativity, respectively. The predicate recursively compares regions.)")
----------------
makslevental wrote:
```suggestion
"Checks whether two operations are structurally equivalent.
The predicate recursively compares regions.")
```
type hints will already clearly spell out the possibilities for the enum.
https://github.com/llvm/llvm-project/pull/216357
More information about the Mlir-commits
mailing list