[Mlir-commits] [mlir] [mlir][python] Fixup the constantTypes of pdl.TypesOp (PR #75812)
Jiefeng Wang
llvmlistbot at llvm.org
Tue Dec 19 03:52:08 PST 2023
jiefwo wrote:
After this commit [[MLIR][python bindings] Add some AttrBuilder and port _exts to use them.](https://reviews.llvm.org/D149287), this python script produces mlir as follows. It's `%0 = types : []` rather than `%0 = types` which may result in PDL interpreter failure.
The checks `# CHECK: %0 = types` in `llvm-project/mlir/test/python/dialects/pdl_ops.py` only match the result partially, not the whole line, so this test still passes.
```python
from mlir.ir import *
from mlir.dialects.pdl import *
def constructAndPrintInModule(f):
print("\nTEST:", f.__name__)
with Context(), Location.unknown():
module = Module.create()
with InsertionPoint(module.body):
f()
print(module)
return f
@constructAndPrintInModule
def test_operation_results():
valueRange = RangeType.get(ValueType.get())
pattern = PatternOp(1, "operation_results")
with InsertionPoint(pattern.body):
types = TypesOp()
inputOp = OperationOp(types=[types])
results = ResultsOp(valueRange, inputOp)
root = OperationOp(args=[results])
RewriteOp(root, name="rewriter")
```
```mlir
TEST: test_operation_results
module {
pdl.pattern @operation_results : benefit(1) {
%0 = types : []
%1 = operation -> (%0 : !pdl.range<type>)
%2 = results of %1
%3 = operation(%2 : !pdl.range<value>)
rewrite %3 with "rewriter"
}
}
```
https://github.com/llvm/llvm-project/pull/75812
More information about the Mlir-commits
mailing list