onnx-mlir
onnx-mlir copied to clipboard
Command line options and Environment variables
Decisions: We need both command line options and environment variable for many of the compiler options.
Here is how we can keep sanity
- Options to ONNX-MLIR are self described using the
--help
flag. When an env variable is also listed (and they are needed for many of the options), we should list the env name. Priority is option line command first, then env variable. - To the extent possible, the name of the option and the env variable should be identical (env variable may have a common prefix,
OM
orONNX_MLIR
?). For short name, maybe we can have the-v
and--verbose
option, if its easy to do. - We should have a centralized way to process all the env variables that are used in onnx-mlir.
An interesting observation was made that ONNX-MLIR is both a driver (where we control all of the option/command/env var) as well as a program interface, that folks can invoke from something non-LLVM based, for example. We should start making this distinction clearer: command line and env var are a mean to set options that change the behavior of the ONNX-MLIR, regardless of if its called within the LLVM framework or the program interface.
Summary of discussion between Ettore, Gong, and Alex(me)
Options for onnx-mlir-opt should be considered too.
Good point, it is possible in the PR #1167.
I found that adding a custom ONNX_MLIR_XXX for each XXX option such as MTRIPLE, CPU, ARCH, VERBOSE... was going require to much effort, and in addition that is not how things are done in LLVM. LLVM offer already support for "CFLAGS" like variables where one can simply add any normal command line option, separated by spaces. I though that this would be more convenient for the user as you then only need to remember one env var, namely ONNX_MLIR_FLAG.
Through the ONNX_MLIR_OPT_FLAGS and the command line options, you have access to all options as well for onnx-mlir-opt. And through the interface directly, you can set all of the options that can also be set in ONNX_MLIR for the enum OptionKind {...}
.
I decided not to share the same default env var between onnx-mlir and onnx-mlir-opt because they have different options.
This issue has migrated to implementation questions in this new issue #1155