[all-commits] [llvm/llvm-project] e5114a: [MLIR][Python] Add python bindings for IRDL dialec...
Twice via All-commits
all-commits at lists.llvm.org
Thu Sep 18 19:11:01 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e5114a2016557fc0dd6014b838e91ca025e23b29
https://github.com/llvm/llvm-project/commit/e5114a2016557fc0dd6014b838e91ca025e23b29
Author: Twice <twice at apache.org>
Date: 2025-09-19 (Fri, 19 Sep 2025)
Changed paths:
M mlir/include/mlir/Dialect/IRDL/IR/IRDLAttributes.td
M mlir/include/mlir/Dialect/IRDL/IR/IRDLOps.td
M mlir/include/mlir/Dialect/IRDL/IR/IRDLTypes.td
A mlir/lib/Bindings/Python/DialectIRDL.cpp
M mlir/python/CMakeLists.txt
A mlir/python/mlir/dialects/IRDLOps.td
A mlir/python/mlir/dialects/irdl.py
A mlir/test/python/dialects/irdl.py
Log Message:
-----------
[MLIR][Python] Add python bindings for IRDL dialect (#158488)
In this PR we add basic python bindings for IRDL dialect, so that python
users can create and load IRDL dialects in python. This allows users, to
some extent, to define dialects in Python without having to modify
MLIR’s CMake/TableGen/C++ code and rebuild, making prototyping more
convenient.
A basic example is shown below (and also in the added test case):
```python
# create a module with IRDL dialects
module = Module.create()
with InsertionPoint(module.body):
dialect = irdl.DialectOp("irdl_test")
with InsertionPoint(dialect.body):
op = irdl.OperationOp("test_op")
with InsertionPoint(op.body):
f32 = irdl.is_(TypeAttr.get(F32Type.get()))
irdl.operands_([f32], ["input"], [irdl.Variadicity.single])
# load the module
irdl.load_dialects(module)
# use the op defined in IRDL
m = Module.parse("""
module {
%a = arith.constant 1.0 : f32
"irdl_test.test_op"(%a) : (f32) -> ()
}
""")
```
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list