[Mlir-commits] [mlir] a8b6afb - [MLIR][Python][NFC] Refine the docstring of `PassManager.add(callable, ..)` (#173945)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Dec 29 19:29:36 PST 2025


Author: Twice
Date: 2025-12-30T11:29:32+08:00
New Revision: a8b6afbf3094a09515f0d7949c156544649d5984

URL: https://github.com/llvm/llvm-project/commit/a8b6afbf3094a09515f0d7949c156544649d5984
DIFF: https://github.com/llvm/llvm-project/commit/a8b6afbf3094a09515f0d7949c156544649d5984.diff

LOG: [MLIR][Python][NFC] Refine the docstring of `PassManager.add(callable, ..)` (#173945)

This PR expands the docstring for `PassManager.run(callable, ..)` by
adding descriptions for each parameter, making it easier for users to
understand. No functional change.

Added: 
    

Modified: 
    mlir/lib/Bindings/Python/Pass.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Bindings/Python/Pass.cpp b/mlir/lib/Bindings/Python/Pass.cpp
index 572afa902746d..cdf01fff28cf2 100644
--- a/mlir/lib/Bindings/Python/Pass.cpp
+++ b/mlir/lib/Bindings/Python/Pass.cpp
@@ -224,7 +224,19 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) {
           },
           "run"_a, "name"_a.none() = nb::none(), "argument"_a.none() = "",
           "description"_a.none() = "", "op_name"_a.none() = "",
-          "Add a python-defined pass to the pass manager.")
+          R"(
+            Add a python-defined pass to the current pipeline of the pass manager.
+
+            Args:
+              run: A callable with signature ``(op: ir.Operation, pass_: ExternalPass) -> None``.
+                   Called when the pass executes. It receives the operation to be processed and
+                   the current ``ExternalPass`` instance.
+                   Use ``pass_.signal_pass_failure()`` to signal failure.
+              name: The name of the pass. Defaults to ``run.__name__``.
+              argument: The command-line argument for the pass. Defaults to empty.
+              description: The description of the pass. Defaults to empty.
+              op_name: The name of the operation this pass operates on.
+                       It will be a generic operation pass if not specified.)")
       .def(
           "run",
           [](PyPassManager &passManager, PyOperationBase &op) {


        


More information about the Mlir-commits mailing list