[Mlir-commits] [mlir] [MLIR][Python] Impl XOpInterface(s) from Python, with X=Transform and X=MemoryEffects (PR #176920)

Rolf Morel llvmlistbot at llvm.org
Wed Jan 28 05:24:57 PST 2026


================
@@ -451,21 +459,20 @@ def _emit_module(cls) -> ir.Module:
         return m
 
     @classmethod
-    def load(cls) -> None:
-        if hasattr(cls, "_mlir_module"):
-            raise RuntimeError(f"Dialect {cls.name} is already loaded.")
-
-        mlir_module = cls._emit_module()
+    def load(cls, register=True, reload=False) -> None:
+        if hasattr(cls, "_mlir_module") and not reload:
+            return
 
+        cls._mlir_module = cls._emit_module()
         pm = PassManager()
         pm.add("canonicalize, cse")
-        pm.run(mlir_module.operation)
-
-        irdl.load_dialects(mlir_module)
+        pm.run(cls._mlir_module.operation)
 
-        _cext.register_dialect(cls)
+        irdl.load_dialects(cls._mlir_module)
 
-        for op in cls.operations:
-            _cext.register_operation(cls)(op)
+        if register:
----------------
rolfmorel wrote:

My thinking was that I wouldn't need to expose `register_dialect` and `register_dialect_operation` if I just call `.load(register=True)` for the first `@run` test and `.load(register=False)` for the later ones. For whatever reason, that wasn't working for me (complaints about ops not being known to the context for the later tests).

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


More information about the Mlir-commits mailing list