[Mlir-commits] [mlir] [mlir] Add Python bindings to enable default passmanager timing (PR #149087)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jul 16 05:38:45 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Martin Erhart (maerhart)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/149087.diff
3 Files Affected:
- (modified) mlir/include/mlir-c/Pass.h (+4)
- (modified) mlir/lib/Bindings/Python/Pass.cpp (+6)
- (modified) mlir/lib/CAPI/IR/Pass.cpp (+4)
``````````diff
diff --git a/mlir/include/mlir-c/Pass.h b/mlir/include/mlir-c/Pass.h
index 8fd8e9956a65a..0d2e19ee7fb0a 100644
--- a/mlir/include/mlir-c/Pass.h
+++ b/mlir/include/mlir-c/Pass.h
@@ -88,6 +88,10 @@ MLIR_CAPI_EXPORTED void mlirPassManagerEnableIRPrinting(
MLIR_CAPI_EXPORTED void
mlirPassManagerEnableVerifier(MlirPassManager passManager, bool enable);
+/// Enable pass timing.
+MLIR_CAPI_EXPORTED void
+mlirPassManagerEnableTiming(MlirPassManager passManager);
+
/// Nest an OpPassManager under the top-level PassManager, the nested
/// passmanager will only run on operations matching the provided name.
/// The returned OpPassManager will be destroyed when the parent is destroyed.
diff --git a/mlir/lib/Bindings/Python/Pass.cpp b/mlir/lib/Bindings/Python/Pass.cpp
index 858c3bd5745fe..8d84864b9db4d 100644
--- a/mlir/lib/Bindings/Python/Pass.cpp
+++ b/mlir/lib/Bindings/Python/Pass.cpp
@@ -112,6 +112,12 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) {
mlirPassManagerEnableVerifier(passManager.get(), enable);
},
"enable"_a, "Enable / disable verify-each.")
+ .def(
+ "enable_timing",
+ [](PyPassManager &passManager) {
+ mlirPassManagerEnableTiming(passManager.get());
+ },
+ "Enable pass timing.")
.def_static(
"parse",
[](const std::string &pipeline, DefaultingPyMlirContext context) {
diff --git a/mlir/lib/CAPI/IR/Pass.cpp b/mlir/lib/CAPI/IR/Pass.cpp
index 883b7e8bb832d..3c499c3e4974d 100644
--- a/mlir/lib/CAPI/IR/Pass.cpp
+++ b/mlir/lib/CAPI/IR/Pass.cpp
@@ -75,6 +75,10 @@ void mlirPassManagerEnableVerifier(MlirPassManager passManager, bool enable) {
unwrap(passManager)->enableVerifier(enable);
}
+void mlirPassManagerEnableTiming(MlirPassManager passManager) {
+ unwrap(passManager)->enableTiming();
+}
+
MlirOpPassManager mlirPassManagerGetNestedUnder(MlirPassManager passManager,
MlirStringRef operationName) {
return wrap(&unwrap(passManager)->nest(unwrap(operationName)));
``````````
</details>
https://github.com/llvm/llvm-project/pull/149087
More information about the Mlir-commits
mailing list