Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.

Commit 88b0f4a

Browse files
authored
[MLIR][Python] enhance python ir printing with pringing flags (#117836)
Close llvm/llvm-project#65854
1 parent 0151e49 commit 88b0f4a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Pass.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,33 @@ void mlir::python::populatePassManagerSubmodule(py::module &m) {
7676
"enable_ir_printing",
7777
[](PyPassManager &passManager, bool printBeforeAll,
7878
bool printAfterAll, bool printModuleScope, bool printAfterChange,
79-
bool printAfterFailure,
79+
bool printAfterFailure, std::optional<int64_t> largeElementsLimit,
80+
bool enableDebugInfo, bool printGenericOpForm,
8081
std::optional<std::string> optionalTreePrintingPath) {
82+
MlirOpPrintingFlags flags = mlirOpPrintingFlagsCreate();
83+
if (largeElementsLimit)
84+
mlirOpPrintingFlagsElideLargeElementsAttrs(flags,
85+
*largeElementsLimit);
86+
if (enableDebugInfo)
87+
mlirOpPrintingFlagsEnableDebugInfo(flags, /*enable=*/true,
88+
/*prettyForm=*/false);
89+
if (printGenericOpForm)
90+
mlirOpPrintingFlagsPrintGenericOpForm(flags);
8191
std::string treePrintingPath = "";
8292
if (optionalTreePrintingPath.has_value())
8393
treePrintingPath = optionalTreePrintingPath.value();
8494
mlirPassManagerEnableIRPrinting(
8595
passManager.get(), printBeforeAll, printAfterAll,
86-
printModuleScope, printAfterChange, printAfterFailure,
96+
printModuleScope, printAfterChange, printAfterFailure, flags,
8797
mlirStringRefCreate(treePrintingPath.data(),
8898
treePrintingPath.size()));
99+
mlirOpPrintingFlagsDestroy(flags);
89100
},
90101
"print_before_all"_a = false, "print_after_all"_a = true,
91102
"print_module_scope"_a = false, "print_after_change"_a = false,
92103
"print_after_failure"_a = false,
104+
"large_elements_limit"_a = py::none(), "enable_debug_info"_a = false,
105+
"print_generic_op_form"_a = false,
93106
"tree_printing_dir_path"_a = py::none(),
94107
"Enable IR printing, default as mlir-print-ir-after-all.")
95108
.def(

0 commit comments

Comments
 (0)