[Mlir-commits] [mlir] [MLIR][Python] Support Python-defined passes in MLIR (PR #156000)
Maksim Levental
llvmlistbot at llvm.org
Mon Sep 8 10:32:58 PDT 2025
================
@@ -157,6 +159,45 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) {
"pipeline"_a,
"Add textual pipeline elements to the pass manager. Throws a "
"ValueError if the pipeline can't be parsed.")
+ .def(
+ "add",
+ [](PyPassManager &passManager, const nb::callable &run,
+ std::optional<std::string> &name, const std::string &argument,
+ const std::string &description, const std::string &opName) {
+ if (!name.has_value()) {
+ name = nb::cast<std::string>(
+ nb::borrow<nb::str>(run.attr("__name__")));
----------------
makslevental wrote:
```python
>>> x = lambda: "bob"
>>> x.__name__
'<lambda>'
```
https://github.com/llvm/llvm-project/pull/156000
More information about the Mlir-commits
mailing list