[Mlir-commits] [mlir] [mlir][python] Fixup the constantTypes of pdl.TypesOp (PR #75812)

Jiefeng Wang llvmlistbot at llvm.org
Wed Dec 20 05:53:06 PST 2023


jiefwo wrote:

> I don't think there is an issue to start with, and if there is, the proposed change is not a solution.

The issue I'm experiencing is that I write a python script to transform a function in MLIR. This python script invokes `pdl.TypesOp` to generate pdl match and rewrite operations. Since the generated pdl operations using `[]` for `pdl.TypesOp`, the transformation fails when matching patterns. I have to append a line with `result_types.constantTypes = None` to workaround this issue as follows.

```python
  pdl_pattern = pdl.PatternOp(benefit=1, name=pdl_pattern_name)
  with ir.InsertionPoint(pdl_pattern.body):
    operands = pdl.OperandsOp()
    result_types = pdl.TypesOp()
    result_types.constantTypes = None
    pdl_op = pdl.OperationOp(op_to_match_name,
                             args=[operands],
                             types=[result_types])
    for constraints_builder in constraints_builder_list:
      constraints_builder(pdl_op, operands, result_types)
    pdl.RewriteOp(pdl_op, 'transform.dialect')
```

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


More information about the Mlir-commits mailing list