-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[MLIR][Python] Expose PassManager::enableStatistics
to CAPI and Python
#162591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,13 @@ class PyPassManager { | |
|
||
/// Create the `mlir.passmanager` here. | ||
void mlir::python::populatePassManagerSubmodule(nb::module_ &m) { | ||
//---------------------------------------------------------------------------- | ||
// Mapping of enumerated types | ||
//---------------------------------------------------------------------------- | ||
nb::enum_<MlirPassDisplayMode>(m, "PassDisplayMode") | ||
.value("LIST", MLIR_PASS_DISPLAY_MODE_LIST) | ||
.value("PIPELINE", MLIR_PASS_DISPLAY_MODE_PIPELINE); | ||
|
||
//---------------------------------------------------------------------------- | ||
// Mapping of MlirExternalPass | ||
//---------------------------------------------------------------------------- | ||
|
@@ -138,6 +145,14 @@ void mlir::python::populatePassManagerSubmodule(nb::module_ &m) { | |
mlirPassManagerEnableTiming(passManager.get()); | ||
}, | ||
"Enable pass timing.") | ||
.def( | ||
"enable_statistics", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming not: "enable statistics" calls for a boolean argument. I'd consider something like set pass display mode instead, or a pass display mode property if there is a way to fetch back the current value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It indeed looks good but I think currently we cannot do it before some modification to the C++ API. I'll try to look into the C++ APIs and see if we can change later : ) Currently these names are just C++ ones with underscores. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also suggest to rename the C++ function. It may have been There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me take this task and see what we can do : ) |
||
[](PyPassManager &passManager, MlirPassDisplayMode displayMode) { | ||
mlirPassManagerEnableStatistics(passManager.get(), displayMode); | ||
}, | ||
"displayMode"_a = | ||
MlirPassDisplayMode::MLIR_PASS_DISPLAY_MODE_PIPELINE, | ||
"Enable pass statistics.") | ||
.def_static( | ||
"parse", | ||
[](const std::string &pipeline, DefaultingPyMlirContext context) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to disable statistics?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the answer is no if we don't change the C++ API. (see https://mlir.llvm.org/doxygen/classmlir_1_1PassManager.html)
In C++, the only public API for statistics is like
void enableStatistics(PassDisplayMode displayMode)
and internally it is assigned to astd::optional<PassDisplayMode>
, and thebool(optional)
can indicate if it is enabled.