[Mlir-commits] [mlir] 16ef4ed - [MLIR][Python] Ensure traits are attached when `load(register=False)` (#181174)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Feb 12 08:41:39 PST 2026


Author: Twice
Date: 2026-02-13T00:41:32+08:00
New Revision: 16ef4ed48fd751c33bbb0cbca42b448991b0391f

URL: https://github.com/llvm/llvm-project/commit/16ef4ed48fd751c33bbb0cbca42b448991b0391f
DIFF: https://github.com/llvm/llvm-project/commit/16ef4ed48fd751c33bbb0cbca42b448991b0391f.diff

LOG: [MLIR][Python] Ensure traits are attached when `load(register=False)` (#181174)

Currently, when calling `.load(register=False)`, `op._attach_traits()`
isn’t executed. This PR ensures traits are attached regardless of
whether `register` is `True` or `False`.

Added: 
    

Modified: 
    mlir/python/mlir/dialects/ext.py

Removed: 
    


################################################################################
diff  --git a/mlir/python/mlir/dialects/ext.py b/mlir/python/mlir/dialects/ext.py
index d80e9eed6a483..ac1b3065336e8 100644
--- a/mlir/python/mlir/dialects/ext.py
+++ b/mlir/python/mlir/dialects/ext.py
@@ -27,17 +27,18 @@
 
 __all__ = [
     "Dialect",
+    "Operation",
     "Operand",
     "Result",
+    "Region",
     "register_dialect",
     "register_operation",
-    "Region",
-    "Operation",
 ]
 
 Operand = ir.Value
 Result = ir.OpResult
 Region = ir.Region
+
 register_dialect = _cext.register_dialect
 register_operation = _cext.register_operation
 
@@ -528,10 +529,12 @@ def load(cls, register=True, reload=False) -> None:
 
         irdl.load_dialects(cls._mlir_module)
 
+        for op in cls.operations:
+            op._attach_traits()
+
         if register:
             register_dialect(cls)
 
             register_dialect_operation = register_operation(cls)
             for op in cls.operations:
-                op._attach_traits()
                 register_dialect_operation(op)


        


More information about the Mlir-commits mailing list