[Mlir-commits] [mlir] [MLIR][Python] Add python bindings for IRDL dialect (PR #158488)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Sep 14 07:29:56 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r origin/main...HEAD mlir/python/mlir/dialects/irdl.py mlir/test/python/dialects/irdl.py
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- python/mlir/dialects/irdl.py 2025-09-14 14:16:38.000000 +0000
+++ python/mlir/dialects/irdl.py 2025-09-14 14:29:30.181944 +0000
@@ -12,10 +12,11 @@
get_op_results_or_values as _get_values,
_cext as _ods_cext,
)
from ..extras.meta import region_op
+
@_ods_cext.register_operation(_Dialect, replace=True)
class DialectOp(DialectOp):
"""Specialization for the dialect op class."""
def __init__(self, sym_name, *, loc=None, ip=None):
@@ -23,10 +24,11 @@
self.regions[0].blocks.append()
@property
def body(self):
return self.regions[0].blocks[0]
+
@_ods_cext.register_operation(_Dialect, replace=True)
class OperationOp(OperationOp):
"""Specialization for the operation op class."""
@@ -36,8 +38,11 @@
@property
def body(self):
return self.regions[0].blocks[0]
+
@register_attribute_builder("VariadicityArrayAttr")
def _variadicity_array_attr(x, context):
- return _ods_cext.ir.Attribute.parse(f"#irdl<variadicity_array [{', '.join(str(i) for i in x)}]>")
+ return _ods_cext.ir.Attribute.parse(
+ f"#irdl<variadicity_array [{', '.join(str(i) for i in x)}]>"
+ )
--- test/python/dialects/irdl.py 2025-09-14 14:16:38.000000 +0000
+++ test/python/dialects/irdl.py 2025-09-14 14:29:30.197003 +0000
@@ -33,13 +33,15 @@
# CHECK: }
module.dump()
irdl.load_dialects(module)
- m = Module.parse("""
+ m = Module.parse(
+ """
module {
%a = arith.constant 1.0 : f32
"irdl_test.test_op"(%a) : (f32) -> ()
}
- """)
+ """
+ )
# CHECK: "irdl_test.test_op"(%cst) : (f32) -> ()
m.dump()
``````````
</details>
https://github.com/llvm/llvm-project/pull/158488
More information about the Mlir-commits
mailing list