onnx-mlir icon indicating copy to clipboard operation
onnx-mlir copied to clipboard

Mixing compiler and pass options

Open manbearian opened this issue 2 years ago • 16 comments

Hi, folks: @tungld, @sstamenova, and @etiotto.

I'm looking at PR #1269 and how its interacting with my team's usage of onnx-mlir. We use the passes of ONNX-MLIR without picking up the onnx-mlir/onnx-mlir-opt binaries.

After this change we're running into issues because linking withe some of the passes now pulls in all of the command-line options for onnx-mlir, which we don't want.

i've looked at couple of options for this and i'd like to either a) move the pass-specific flags to a single lib (e.g., so we have PassOptions and CompilerOptions as sperate things) b) locate the pass specific flags into the passes themselves. c) remove the idea of pass specific flags and have that information passed to the passes on their construction

Option (a) seems like the least invasive while option (b) seems like the most flexible.

Thoughts?

manbearian avatar Apr 14 '22 19:04 manbearian

To rephrase your situation, you want to use some of the onnx-mlir passes but are not planning to use either the onnx-mlir or onnx-mlir-opt drivers. And you are stating that when you do that, you have options that are added (via the llvm support for options) that are not desired.

AlexandreEichenberger avatar Apr 14 '22 19:04 AlexandreEichenberger

Hi, @AlexandreEichenberger , thanks for responding. Your rephrasing captures the issue well. To give a concrete example, and make this less abstract: i have some name clashes which are the major issue (otherwise hiding them would be fine). For example, as you might imagine, my tool also has an -mtriple option.

The onnx-mlir sources make a clear distinction between pass options and tool options; unfortunately, after the aforementioned PR, they're now included together.

manbearian avatar Apr 14 '22 19:04 manbearian

I implemented option (b); let me know what you think.

manbearian avatar Apr 14 '22 20:04 manbearian

These pass options are actually not "real" pass options. They are actually compiler options and passes access them globally.

tungld avatar Apr 15 '22 15:04 tungld

This is one example of how to define a pass option: https://github.com/onnx/onnx-mlir/blob/main/src/Conversion/ONNXToKrnl/ConvertONNXToKrnl.cpp#L172

tungld avatar Apr 15 '22 15:04 tungld

@tungld , yes that is correct. a different design might be to pass the command-line options to the passes; i can take that route as well if its more appealing to folks. its a bit more invasive though.

manbearian avatar Apr 15 '22 17:04 manbearian

My PR #1348 is green now. Any thoughts from folk on if this is the right direction or one of the other 3 options?

a) move the pass-specific flags to a single lib (e.g., so we have PassOptions and CompilerOptions as sperate things) what is implemented ==> b) locate the pass specific flags into the passes themselves. c) remove the idea of pass specific flags and have that information passed to the passes on their construction d) add actual pass options and remove pass-specific command-line options

manbearian avatar Apr 15 '22 19:04 manbearian

@manbearian I am fine that PR #1348 can be a short-term solution to make your usage of onnx-mIir work. For a long term solution, I would prefer to make the passes self-contains by having their own options. Information should be passed via construction.

tungld avatar Apr 18 '22 04:04 tungld

i'll look at the alternative change. i might be able to get it done today; no promises though.

manbearian avatar Apr 18 '22 16:04 manbearian

@tungld, please take a look at PR #1363 and let me know if this what you're thinking.

manbearian avatar Apr 18 '22 19:04 manbearian

please take a look at PR https://github.com/onnx/onnx-mlir/pull/1363 and let me know if this what you're thinking.

@manbearian Thank you for quickly implementing the idea! Yes, it is what I am thinking about. I would go with PR #1363.

tungld avatar Apr 19 '22 00:04 tungld

Thanks, @tungld. I'll get it cleaned up ASAP.

manbearian avatar Apr 19 '22 02:04 manbearian

@AlexandreEichenberger , i see you also approved #1348 . What's your take on #1348 vs #1363. i think i agree with @tungld that the latter is better.

manbearian avatar Apr 19 '22 16:04 manbearian

I now realize that they were two versions for the same original issue. After reviewing the concepts behind #1363, you convinced me that that one is better. Thanks for having followed up on @tungld 's suggestions, much appreciated.

AlexandreEichenberger avatar Apr 19 '22 22:04 AlexandreEichenberger

@AlexandreEichenberger or @tungld , thanks for the feedback. Can one of you please drive the commit to completion? i don't have permission to run tests or merge changes

manbearian avatar Apr 19 '22 23:04 manbearian

I believe we have some restrictions to run CIs on our internal machines, once its approved and ran successfully, I think you can merge it. But we can do that too.

AlexandreEichenberger avatar Apr 19 '22 23:04 AlexandreEichenberger