Do we have PDL interpreter?

Hi everyone,

I am new to PDL. I want to have a quick taste on how to perform pattern rewriting on MLIR. From online document, I found we have a dialect PDL to define rewrite patterns; also there is another dialect called PDL_interp looks like a lowered PDL.

However, given we have such nice dialects, I couldn’t find a document about how to executing them. For example, I have a simple MLIR file in arith dilect with only one add operation. Besides, I have another PDL file to replace the add with sub. What tools should I call the apply the PDL pattern on the arith file?

Thanks in advance >w<!

Was literally just talking about this with @jpienaar; it’s under the name test-pdl-bytecode-pass.

3 Likes

Woooow, you are so great! Thanks for letting me know that.
I guess my next step is maybe call a lowering -convert-pdl-to-pdl-interp, combine both into one file, and use milr-opt -test-pdl-bytecode-pass.
Does it sound reasonable?

Yes, although I think we should definitely improve the examples here :slight_smile:

PDL you can also look at what PDLL generates, it generates patterns where under the hood as part of regular pattern application (as one would with greedy pattern driver etc) it invokes the interpreter on the “combined” pattern tree. But its very indirect that that’s a bytecode interpreter :slight_smile: And this was much more formulated with expectation that someone is doing something combined and so its bit more low level. That of course doesn’t mean we shouldn’t look at a driver for simple case.

(I was working on a simple Python example here for another reason, but had to switch in some other work and haven’t completed yet)

1 Like

Thanks for the following up.

Currently our research work uses PDL internally(Our previous research https://www.youtube.com/watch?v=gZdHrve9p40 ).

More specifically, we create a dialect named smt to model operations in SMT Solvers. By lowering operations from other dialects to smt dialect, and further send them to SMT Solvers, we can verify MLIR programs.

One direct benefit is you can get translation validation for free. For example, I have an arith function, and by applying PDL, I get another arith function. Just by checking the equivalence of both arith functions, we can know if the PDL pattern preserves the same semantics. Besides, we also have other prototype works in hand using PDL, and MLIR fuzzers if you want to test any passes.

Anyway, thank you for making it more user-friendly :slight_smile: