Add "test-transform-dialect-interpreter" to pass manager in MLIR python binding

I’m trying to add test-transform-dialect-interpreter to a pass manager using MLIR Python binding:

passes="builtin.module(test-transform-dialect-interpreter)"
pm = PassManager.parse(passes)
pm.run(mod.operation)

However, test-transform-dialect-interpreter is not a registered pass, the above Python file comes with the following error:

error: 'test-transform-dialect-interpreter' does not refer to a registered pass or pass pipeline.

The above pipeline can work using the mlir-opt:

./build/bin/mlir-opt -pass-pipeline="builtin.module(test-transform-dialect-interpreter)"

Does anyone know how to add this in MLIR Python binding? Thanks!

Test passes are intended for testing and therefore (mainly) not exposed to the bindings. You can use the non-test transform-interpreter pass instead. The only difference is that the entry point is an explicit symbol, typically a transform.named_sequence called __transform_main by default, which can be overridden through pass options.

Putting on my “I’m a pedant” hat, it’s not that those passes aren’t exposed to the bindings (we don’t have a way to selectively filter passes that the bindings can see), it’s that those passes aren’t by default linked into anything (not mlir-opt, not AggregateCAPI, etc). If you do decide you want them, you need to rebuild LLVM+MLIR accordingly mlir-wheels/patches/register_test_pass.patch at main · makslevental/mlir-wheels · GitHub. But I agree with Alex, just use transform-interpreter (roughly like this).