Skip to content

Commit 616e4c4

Browse files
authored
[mlir] Add Python bindings to enable default passmanager timing (#149087)
1 parent f995bc8 commit 616e4c4

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

mlir/include/mlir-c/Pass.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ MLIR_CAPI_EXPORTED void mlirPassManagerEnableIRPrinting(
8888
MLIR_CAPI_EXPORTED void
8989
mlirPassManagerEnableVerifier(MlirPassManager passManager, bool enable);
9090

91+
/// Enable pass timing.
92+
MLIR_CAPI_EXPORTED void
93+
mlirPassManagerEnableTiming(MlirPassManager passManager);
94+
9195
/// Nest an OpPassManager under the top-level PassManager, the nested
9296
/// passmanager will only run on operations matching the provided name.
9397
/// The returned OpPassManager will be destroyed when the parent is destroyed.

mlir/lib/Bindings/Python/Pass.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) {
112112
mlirPassManagerEnableVerifier(passManager.get(), enable);
113113
},
114114
"enable"_a, "Enable / disable verify-each.")
115+
.def(
116+
"enable_timing",
117+
[](PyPassManager &passManager) {
118+
mlirPassManagerEnableTiming(passManager.get());
119+
},
120+
"Enable pass timing.")
115121
.def_static(
116122
"parse",
117123
[](const std::string &pipeline, DefaultingPyMlirContext context) {

mlir/lib/CAPI/IR/Pass.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ void mlirPassManagerEnableVerifier(MlirPassManager passManager, bool enable) {
7575
unwrap(passManager)->enableVerifier(enable);
7676
}
7777

78+
void mlirPassManagerEnableTiming(MlirPassManager passManager) {
79+
unwrap(passManager)->enableTiming();
80+
}
81+
7882
MlirOpPassManager mlirPassManagerGetNestedUnder(MlirPassManager passManager,
7983
MlirStringRef operationName) {
8084
return wrap(&unwrap(passManager)->nest(unwrap(operationName)));

0 commit comments

Comments
 (0)