Page MenuHomePhabricator

[MLIR][PYTHON] Provide opt level for ExecutionEngine Python binding

Authored by bondhugula on May 15 2021, 5:04 AM.



Provide an option to specify optimization level when creating an
ExecutionEngine via the MLIR JIT Python binding. Not only is the
specified optimization level used for code generation, but all LLVM
optimization passes at the optimization level are also run prior to
machine code generation (akin to the mlir-cpu-runner tool).

Default opt level continues to remain at level two (-O2).

Contributions in part from Prashant Kumar <> as well.

Diff Detail

Event Timeline

bondhugula created this revision.May 15 2021, 5:04 AM
bondhugula requested review of this revision.May 15 2021, 5:04 AM
bondhugula edited the summary of this revision. (Show Details)May 15 2021, 5:12 AM

Update commit summary.

stellaraccident accepted this revision.May 15 2021, 10:44 AM

Thanks for the patch! I'm accepting this to help with timezones but would like my comments addressed/further discussed before landing.


I think as a general rule, we're not trying to carry forward unsigned into new APIs. For a general quantity (not on the order of pointer/system memory sized), prefer int. Here and elsewhere in this patch.


You can write this as:

.def(py::init<>([](PyModule &module, int optLevel) {
}, py::arg("module"), py::arg("opt_level") = 2,
"My docstring")

For trivial cases of defaulting arguments like this, it is much better to have a python level default arg vs an overload.


When you remove this overload and adapt the docstring, note that any python visible args should be in snake_case.

This revision is now accepted and ready to land.May 15 2021, 10:44 AM
mehdi_amini accepted this revision.May 15 2021, 4:44 PM
bondhugula marked 2 inline comments as done.

Address comments from @stellaraccident.


Thanks very much! Updated.

bondhugula marked an inline comment as done.

unsigned -> int for optLevel.

@stellaraccident Leaving this for your second look.