summaryrefslogtreecommitdiff
path: root/mlir/test/python/python_test_ops.td
diff options
context:
space:
mode:
authorTwice <twice@apache.org>2025-09-19 10:10:39 +0800
committerGitHub <noreply@github.com>2025-09-19 10:10:39 +0800
commite5114a2016557fc0dd6014b838e91ca025e23b29 (patch)
treeb4b648ce4ace040ae590a92c79bab34a8d41c502 /mlir/test/python/python_test_ops.td
parentb26b40b22320ab8b684bfe2575fdbda1c6f2e4ee (diff)
[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) -> () } """) ```
Diffstat (limited to 'mlir/test/python/python_test_ops.td')
0 files changed, 0 insertions, 0 deletions