Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 1 | # Getting Started |
| 2 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 3 | This document provides an overview of IREE's systems, including entry points to |
| 4 | get started exploring IREE's capabilities. |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 5 | |
| 6 | For information on how to set up a development environment, see |
| 7 | [Getting Started on Windows](getting_started_on_windows.md) and |
| 8 | [Getting Started on Linux](getting_started_on_linux.md). |
| 9 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 10 | ## Project Code Layout |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 11 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 12 | [iree/](../iree/) |
| 13 | |
| 14 | * Core IREE project |
| 15 | |
| 16 | [integrations/](../integrations/) |
| 17 | |
| 18 | * Integrations between IREE and other frameworks, such as TensorFlow |
| 19 | |
| 20 | [bindings/](../bindings/) |
| 21 | |
| 22 | * Language and platform bindings, such as Python |
| 23 | |
| 24 | [colab/](../colab/) |
| 25 | |
| 26 | * Colab notebooks for interactively using IREE's Python bindings |
| 27 | |
| 28 | ## IREE Code Layout |
| 29 | |
| 30 | [iree/base/](../iree/base/) |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 31 | |
| 32 | * Common types and utilities used throughout IREE |
| 33 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 34 | [iree/compiler/](../iree/compiler/) |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 35 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 36 | * IREE's MLIR dialects, LLVM compiler passes, module translation code, etc. |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 37 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 38 | [iree/hal/](../iree/hal/) |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 39 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 40 | * **H**ardware **A**bstraction **L**ayer for IREE's runtime, with |
| 41 | implementations for hardware and software backends |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 42 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 43 | [iree/schemas/](../iree/schemas/) |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 44 | |
| 45 | * Shared data storage format definitions, primarily using |
| 46 | [FlatBuffers](https://google.github.io/flatbuffers/) |
| 47 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 48 | [iree/tools/](../iree/tools/) |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 49 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 50 | * Assorted tools used to optimize, translate, and evaluate IREE |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 51 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 52 | [iree/vm/](../iree/vm/) |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 53 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 54 | * Bytecode **V**irtual **M**achine used to work with IREE modules and invoke |
| 55 | IREE functions |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 56 | |
| 57 | ## Working with IREE's Components |
| 58 | |
| 59 | IREE ingests MLIR in a high-level dialect like |
| 60 | [XLA/HLO](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/xla), |
| 61 | after which it can perform its own compiler passes to eventually translate the |
| 62 | IR into an 'IREE module', which can be executed via IREE's runtime. IREE |
| 63 | contains programs for running each step in that pipeline under various |
| 64 | configurations (e.g. for tests, with a debugger attached, etc.). |
| 65 | |
| 66 | ### iree-opt |
| 67 | |
| 68 | The `iree-opt` program invokes |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 69 | [MlirOptMain](https://github.com/llvm/llvm-project/blob/master/mlir/lib/Support/MlirOptMain.cpp) |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 70 | to run some set of IREE's optimization passes on a provided .mlir input file. |
| 71 | Test .mlir files that are checked in typically include a `RUN` block at the top |
| 72 | of the file that specifies which passes should be performed and if `FileCheck` |
| 73 | should be used to test the generated output. |
| 74 | |
| 75 | For example, to run some passes on the |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 76 | [reshape.mlir](../iree/compiler/Translation/SPIRV/XLAToSPIRV/test/reshape.mlir) |
| 77 | test file with Bazel on Linux, use this command: |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 78 | |
| 79 | ```shell |
| 80 | $ bazel run //iree/tools:iree-opt -- \ |
| 81 | -split-input-file \ |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 82 | -iree-index-computation \ |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 83 | -simplify-spirv-affine-exprs=false \ |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 84 | -convert-iree-to-spirv \ |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 85 | -verify-diagnostics \ |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 86 | $PWD/iree/compiler/Translation/SPIRV/XLAToSPIRV/test/reshape.mlir |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 87 | ``` |
| 88 | |
| 89 | ### iree-translate |
| 90 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 91 | The `iree-translate` program translates from a .mlir input file into an IREE |
| 92 | module. |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 93 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 94 | For example, to translate `gather.mlir` to an IREE module with Bazel on Linux, |
| 95 | use this command: |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 96 | |
| 97 | ```shell |
| 98 | $ bazel run //iree/tools:iree-translate -- \ |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 99 | -iree-mlir-to-vm-bytecode-module \ |
| 100 | $PWD/test/e2e/xla/gather.mlir \ |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 101 | -o /tmp/module.fb |
| 102 | ``` |
| 103 | |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 104 | Custom translations may also be layered on top of `iree-translate` - see |
| 105 | [iree/samples/custom_modules/dialect](../iree/samples/custom_modules/dialect) |
| 106 | for a sample. |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 107 | |
| 108 | ### iree-run-mlir |
| 109 | |
| 110 | The `iree-run-mlir` program takes a .mlir file as input, translates it to an |
| 111 | IREE bytecode module, and executes the module. |
| 112 | |
| 113 | For example, to execute the contents of a test .mlir file, use this command: |
| 114 | |
| 115 | ```shell |
Scott Todd | 715ab43 | 2020-01-10 14:54:08 -0800 | [diff] [blame] | 116 | $ bazel run //iree/tools:iree-run-mlir -- $PWD/test/e2e/xla/reverse.mlir |
| 117 | ``` |
| 118 | |
| 119 | ### iree-dump-module |
| 120 | |
| 121 | The `iree-dump-module` program prints the contents of an IREE module FlatBuffer |
| 122 | file. |
| 123 | |
| 124 | For example: |
| 125 | |
| 126 | ```shell |
| 127 | $ bazel run //iree/tools:iree-dump-module -- /tmp/module.fb |
Scott Todd | b2e34de | 2019-10-25 15:20:45 -0700 | [diff] [blame] | 128 | ``` |