[Mlir-commits] [mlir] [MLIR][Python] Support Python-defined passes in MLIR (PR #156000)

Maksim Levental llvmlistbot at llvm.org
Sun Sep 7 16:30:35 PDT 2025


makslevental wrote:

Sorry for taking so long to review! 

Firstly, I want to repeat/reiterate/state that I'm fully in support of this functionality (and I believe many others are as well). Coincidentally, at $DAYJOB we want to provide/support something very similar to our users very soon. So thank you very much for the implementation!

Secondly, I'd like to propose a slightly different alternative: https://github.com/llvm/llvm-project/pull/157369. The core of the difference being that instead of providing an API based on classes (`PyPass`, `PyPassBase`) we just provide an API that expects the user to supply a `run` function. IMHO this greatly simplifies the design/API, but more importantly it simplifies the lifetime concerns; the pass itself is wholly owned by the pass manager (as is expected on the C++ side) and only the lifetime of the `nb::callable` needs matching `inc_ref`/`dec_ref`s.

@PragmaTwice take a look - let me know what you think. If you agree/like the alternative, feel free to just copy-paste into this PR (no need to merge or whatever).

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


More information about the Mlir-commits mailing list