[Mlir-commits] [mlir] [MLIR][Python] Add effect and speculatability specifiers for Python-defined ops (PR #216773)

Maksim Levental llvmlistbot at llvm.org
Fri Aug 21 11:06:57 PDT 2026


================
@@ -2685,6 +2685,28 @@ void PyDynamicOpTraits::IsIsolatedFromAbove::bind(nb::module_ &m) {
       nb::arg("context").none() = nb::none());
 }
 
+bool PyDynamicOpTraits::RecursiveMemoryEffects::attach(const nb::object &opName,
+                                                       PyMlirContext &context) {
+  MlirDynamicOpTrait trait = mlirDynamicOpTraitRecursiveMemoryEffectsCreate();
+  return attachOpTrait(opName, trait, context);
+}
+
+void PyDynamicOpTraits::RecursiveMemoryEffects::bind(nb::module_ &m) {
+  nb::class_<PyDynamicOpTraits::RecursiveMemoryEffects, PyDynamicOpTrait> cls(
+      m, "RecursiveMemoryEffectsTrait");
+  cls.attr(typeIDAttr) =
----------------
makslevental wrote:

i never noticed you used this pattern elsewhere in the file. yes i meant `def_prop_ro_static` since that's what we used elsewhere 
https://github.com/llvm/llvm-project/blob/83d12c2af9c05d9792a9031854ab454c2be170db/mlir/lib/Bindings/Python/IRCore.cpp#L3797-L3806

was there a reason you did it like this (by setting the class attribute)? They're probably roughly similar but of course doing it this way you open up the possibility that someone could reset it to something else (but why would they 🤷). 

https://github.com/llvm/llvm-project/pull/216773


More information about the Mlir-commits mailing list