This repository was archived by the owner on Oct 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,18 @@ mlirPassManagerEnableVerifier(MlirPassManager passManager, bool enable);
9292MLIR_CAPI_EXPORTED void
9393mlirPassManagerEnableTiming (MlirPassManager passManager );
9494
95+ /// Enumerated type of pass display modes.
96+ /// Mainly used in mlirPassManagerEnableStatistics.
97+ typedef enum {
98+ MLIR_PASS_DISPLAY_MODE_LIST ,
99+ MLIR_PASS_DISPLAY_MODE_PIPELINE ,
100+ } MlirPassDisplayMode ;
101+
102+ /// Enable pass statistics.
103+ MLIR_CAPI_EXPORTED void
104+ mlirPassManagerEnableStatistics (MlirPassManager passManager ,
105+ MlirPassDisplayMode displayMode );
106+
95107/// Nest an OpPassManager under the top-level PassManager, the nested
96108/// passmanager will only run on operations matching the provided name.
97109/// The returned OpPassManager will be destroyed when the parent is destroyed.
Original file line number Diff line number Diff line change @@ -57,6 +57,13 @@ class PyPassManager {
5757
5858// / Create the `mlir.passmanager` here.
5959void mlir::python::populatePassManagerSubmodule (nb::module_ &m) {
60+ // ----------------------------------------------------------------------------
61+ // Mapping of enumerated types
62+ // ----------------------------------------------------------------------------
63+ nb::enum_<MlirPassDisplayMode>(m, " PassDisplayMode" )
64+ .value (" LIST" , MLIR_PASS_DISPLAY_MODE_LIST)
65+ .value (" PIPELINE" , MLIR_PASS_DISPLAY_MODE_PIPELINE);
66+
6067 // ----------------------------------------------------------------------------
6168 // Mapping of MlirExternalPass
6269 // ----------------------------------------------------------------------------
@@ -139,6 +146,14 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) {
139146 mlirPassManagerEnableTiming (passManager.get ());
140147 },
141148 " Enable pass timing." )
149+ .def (
150+ " enable_statistics" ,
151+ [](PyPassManager &passManager, MlirPassDisplayMode displayMode) {
152+ mlirPassManagerEnableStatistics (passManager.get (), displayMode);
153+ },
154+ " displayMode" _a =
155+ MlirPassDisplayMode::MLIR_PASS_DISPLAY_MODE_PIPELINE,
156+ " Enable pass statistics." )
142157 .def_static (
143158 " parse" ,
144159 [](const std::string &pipeline, DefaultingPyMlirContext context) {
Original file line number Diff line number Diff line change 1313#include " mlir/CAPI/Support.h"
1414#include " mlir/CAPI/Utils.h"
1515#include " mlir/Pass/PassManager.h"
16+ #include " llvm/Support/ErrorHandling.h"
1617#include < optional>
1718
1819using namespace mlir ;
@@ -79,6 +80,20 @@ void mlirPassManagerEnableTiming(MlirPassManager passManager) {
7980 unwrap (passManager)->enableTiming ();
8081}
8182
83+ void mlirPassManagerEnableStatistics (MlirPassManager passManager,
84+ MlirPassDisplayMode displayMode) {
85+ PassDisplayMode mode;
86+ switch (displayMode) {
87+ case MLIR_PASS_DISPLAY_MODE_LIST:
88+ mode = PassDisplayMode::List;
89+ break ;
90+ case MLIR_PASS_DISPLAY_MODE_PIPELINE:
91+ mode = PassDisplayMode::Pipeline;
92+ break ;
93+ }
94+ unwrap (passManager)->enableStatistics (mode);
95+ }
96+
8297MlirOpPassManager mlirPassManagerGetNestedUnder (MlirPassManager passManager,
8398 MlirStringRef operationName) {
8499 return wrap (&unwrap (passManager)->nest (unwrap (operationName)));
You can’t perform that action at this time.
0 commit comments