Closed jinchenglee closed 4 weeks ago
Seems only a single option is allowed/supported.
$~/experimental/onnx-mlir-example$ onnx-mlir -mtriple=riscv64-unknown-elf -mllvm="--disable-simplify-libcalls -O2" --EmitObj ./nn.onnx
[1/6] Mon Sep 23 15:35:49 2024 (0s) Importing ONNX Model to MLIR Module from "nn.onnx"
[2/6] Mon Sep 23 15:35:49 2024 (0s) Compiling and Optimizing MLIR Module
[3/6] Mon Sep 23 15:35:49 2024 (0s) Translating MLIR Module to LLVM and Generating LLVM Optimized Bitcode
opt: Unknown command line argument '--disable-simplify-libcalls -O2'. Try: 'opt --help'
opt: Did you mean '--disable-simplify-libcalls'?
opt -O0 --mtriple=riscv64-unknown-elf --code-model small --disable-simplify-libcalls -O2 -o ./nn.bc ./nn.unoptimized.bc
Error message:
Program path: ~/git_repo/llvm-project/build/bin/opt
Command execution failed.
$:~/experimental/onnx-mlir-example$ onnx-mlir -mtriple=riscv64-unknown-elf -mllvm="--disable-simplify-libcalls" --EmitObj ./nn.onnx
[1/6] Mon Sep 23 15:36:40 2024 (0s) Importing ONNX Model to MLIR Module from "nn.onnx"
[2/6] Mon Sep 23 15:36:40 2024 (0s) Compiling and Optimizing MLIR Module
[3/6] Mon Sep 23 15:36:40 2024 (0s) Translating MLIR Module to LLVM and Generating LLVM Optimized Bitcode
[4/6] Mon Sep 23 15:36:40 2024 (0s) Generating Object from LLVM Bitcode
[5/6] Mon Sep 23 15:36:40 2024 (0s) Compilation completed
I have seen the system being fragile with multiple options in a string, not entirely sure why.
One workaround is to add support for multiple instances of -mllvm=<single option>
.
Do you want me to add this feature?
I have seen the system being fragile with multiple options in a string, not entirely sure why. One workaround is to add support for multiple instances of
-mllvm=<single option>
.Do you want me to add this feature?
That would be nice. Thanks.
The reason is that strings have to be passed separately in the argv[][] for the command. There is another small issue for the example here: -O0 is created by default. If -O2 is passed the mllvm, I got error for "multiple -O#". I am going create a PR to fix this issue of multiple options in mllvm.
Thanks @chentong319
@jinchenglee Which step do you intend to use these options, opt or llc? The current implementation has another issue is that the -mllvm
is used in both opt and llc. But they may support different options. I need to introduce new options for onnx-mlir.
I'm just exploring and besides I'm pretty greenhorn about LLVM toolsets. It seems to me it would be better to separate them as the tools (llc and opt) are different from beginning?
@jinchenglee There are three options in onnx-mlir to pass options to opt and/or llc
mllvm
: only one is used. passed to both opt and llcXopt
: multiple is allowed. passed to only optXllc
: multiple is allowed. passed to only llcI merged a new PR to handle the issue with mllvm. I added example of how to use Xopt and Xllc. Hope this PR2955 solved your issue.
@jinchenglee can we close this issue?
@jinchenglee can we close this issue?
Sorry, I don't yet have time to try these yet. But for what this ticket is asking for, it's safe to close. If any issues, I or anyone can reopen it. Thanks.
For example, I can compile my binary using
clang -target riscv64-unknown-elf -fno-builtin-printf -fno-lto -O2 -c example.c -o example.o
, how may I pass down the additional options through onnx-mlir? This might be a dumb question as I'm new to LLVM toolsets.I tried
$ onnx-mlir -mtriple=riscv64-unknown-elf -mllvm="-fno-builtin-printf -fno-lto -O2" --EmitObj ./nn.onnx
: