You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/Options.md
+7-17
Original file line number
Diff line number
Diff line change
@@ -5,26 +5,16 @@
5
5
Command-line options can be used to alter the default behavior of onnx-mlir, or onnx-mlir-opt, and help user experimenting, debugging or performance tuning. We implemented command-line in ONNX-MLIR based on the command-line utility provided by LLVM. We did not define `Option` or `ListOption` with MLIR pass classes(see discussion).
6
6
7
7
## Organize Options
8
-
Refer [llvm document](https://llvm.org/docs/CommandLine.html) for basic idea of how to define an option. In ONNX-MLIR, options are put into groups (`llvm::cl::OptionCategory`).
9
-
One group of options are only used by onnx-mlir to configure its input or output. These options are defined in src/main.cpp and src/Compiler/CompilerUtils.cpp within OnnxMlirOptions category.
10
-
The rest of options may be used by both onnx-mlir and onnx-mlir-opt to control the behavior of a pass or passes. So far, only one group is defined as an example.
8
+
Refer [llvm document](https://llvm.org/docs/CommandLine.html) for basic idea of how to define an option. In ONNX-MLIR, options are put into groups (`llvm::cl::OptionCategory`). All command-line options for onnx-mlir are in the `OnnxMlirOptions` group.
11
9
12
10
## Code structure
13
-
The head file for options is `src/Support/OMOptions.hpp`. This file should contain the declaration of groups used by both onnx-mlir and onnx-mlir-opt, and options that may be shared by different passes.
14
-
The definition of group and shared options are in `src/Support/OMOptions.cpp`.
11
+
Command-line options should be placed in `src/Compiler/CompilerOptions.cpp` and declared in `src/Compiler/CompilerOptions.hpp`.
15
12
16
13
## Define an option
17
-
* Add a declaration of the option in 'src/Support/OMOptions.hpp`
18
-
* In `src/SupportOMOptions.cpp`, define the option with the desirable llvm::cl class and option group
19
-
* For the file to use this option, make sure `src/Support/OMOptions.hpp`is included.
20
-
* Add OMSupport to the list of libraries in CMakefile.txt
14
+
- Add a declaration of the option in `src/Compiler/CompilerOptions.hpp`
15
+
- In `src/Compiler/CompilerOptions.cpp`, define the option
16
+
- Do **not** include `src/Compiler/CompilerOptions.hpp`in new source files; it should only be used in the onnx-mlir and onnn-mlir-opt command-line tools.
17
+
- Do create 'Pass Options' to pass information to specific passses and transformations
21
18
22
19
## Define an option local to a transformation
23
-
If an option is only used in one transformation, it can be defined locally in the file for the transformation. In the file for transformation:
24
-
* Include `src/Support/OMOtions.hpp`
25
-
* Define the option with the desirable llvm::cl class and option group
26
-
* Add OMSupport to the list of libraries in CMakefile.txt
27
-
28
-
## Discussion
29
-
### MLIR Option support
30
-
MLIR allows to define options within the pass class definition. However, the document said you have to define the same options for PassPipeline and pass a lambda function to assign the options. I thought that this requirement complicated code. I am open to using MLIR if someone know how to easily implement it and know its advantages.
0 commit comments