-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --iree-opt-numeric-precision-reduction option. (#8010)
* Prefixes other high level optimization options with "--iree-opt". * Adds optimization-options.md and backfills with existing options. * Wire up numeric precision reduction passes.
- Loading branch information
1 parent
8dffa35
commit ab1c882
Showing
6 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Optimization Options | ||
|
||
This page documents various supported flags for optimizing IREE programs. Each | ||
is presented with its English name, flag to enable/disable, and default state. | ||
|
||
These flags can be passed to the: | ||
|
||
* `ireec` command line tool | ||
* `extra_args=["--flag"]` argument to `iree.compiler.tools` Python wrappers | ||
* In-process Python compiler API | ||
`iree.compiler.transforms.ireec.CompilerOptions("--flag", "--flag2")` | ||
constructor | ||
* `ireeCompilerOptionsSetFlags()` compiler C API function | ||
|
||
## High level program optimizations | ||
|
||
### Constant evaluation (`--iree-opt-const-eval` (off)) | ||
|
||
Performs compile-time evaluation of any global initializers which produce | ||
the initial values for global constants, storing the global directly in the | ||
program as constant data. This extracts such constant program fragments and | ||
recursively compiles them, using the runtime to evaluate the results. | ||
|
||
Note that this only has any effect on computations in module initializer | ||
functions, not free-standing operations in the program which may produce | ||
constant-derived results. See `--iree-opt-const-expr-hoisting` for options to | ||
optimize these. | ||
|
||
### Constant expression hoisting (`--iree-opt-const-expr-hoisting` (off)) | ||
|
||
Identifies all trees of constant expressions in the program and uses a | ||
heuristic to determine which would be profitable to hoist into global | ||
initializers for evaluation at module load. Together with | ||
`--iree-opt-const-eval`, this will convert eligible trees of expressions to | ||
purely static data embedded in the module. | ||
|
||
The heuristic is currently relatively primitive, using static information to | ||
disable hoisting of leaf operations which are metadata only (i.e. | ||
broadcasts, etc) or are expected to fold away as part of operator fusion. | ||
Notably, the current heuristic is likely to pessimize module size in the case of | ||
complicated programs with trees of constant, large tensors. | ||
|
||
### Numeric precision reduction (`--iree-opt-numeric-precision-reduction` (off)) | ||
|
||
Analyzes program constant data and program flow to identify math operations | ||
which can be safely evaluated with reduced precision (currently with a minimum | ||
of 8bit integers but being extended to infer any bit depth) and inserts | ||
appropriate casts. In conjunction with *Constant Expression Hoisting*, | ||
*Constant Evaluation* and other automatic optimizations, this can produce | ||
programs where large amounts (up to the whole) have had their numeric operations | ||
and constant data rewritten to lower precision types. | ||
|
||
This feature is actively evolving and will be the subject of dedicated | ||
documentation when ready. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters