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

Maksim Levental llvmlistbot at llvm.org
Mon Sep 8 10:33:41 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:

Not the best thing ever but it doesn't blow up (and also I don't see anyone using a lambda here...).

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


More information about the Mlir-commits mailing list