blob: dcc488dd0753949a450d07779670c94a4e9f61fc [file] [log] [blame] [view]
Scott Toddb2e34de2019-10-25 15:20:45 -07001# Getting Started
2
Scott Todd715ab432020-01-10 14:54:08 -08003This document provides an overview of IREE's systems, including entry points to
4get started exploring IREE's capabilities.
Scott Toddb2e34de2019-10-25 15:20:45 -07005
6For 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 Todd715ab432020-01-10 14:54:08 -080010## Project Code Layout
Scott Toddb2e34de2019-10-25 15:20:45 -070011
Scott Todd715ab432020-01-10 14:54:08 -080012[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 Toddb2e34de2019-10-25 15:20:45 -070031
32* Common types and utilities used throughout IREE
33
Scott Todd715ab432020-01-10 14:54:08 -080034[iree/compiler/](../iree/compiler/)
Scott Toddb2e34de2019-10-25 15:20:45 -070035
Scott Todd715ab432020-01-10 14:54:08 -080036* IREE's MLIR dialects, LLVM compiler passes, module translation code, etc.
Scott Toddb2e34de2019-10-25 15:20:45 -070037
Scott Todd715ab432020-01-10 14:54:08 -080038[iree/hal/](../iree/hal/)
Scott Toddb2e34de2019-10-25 15:20:45 -070039
Scott Todd715ab432020-01-10 14:54:08 -080040* **H**ardware **A**bstraction **L**ayer for IREE's runtime, with
41 implementations for hardware and software backends
Scott Toddb2e34de2019-10-25 15:20:45 -070042
Scott Todd715ab432020-01-10 14:54:08 -080043[iree/schemas/](../iree/schemas/)
Scott Toddb2e34de2019-10-25 15:20:45 -070044
45* Shared data storage format definitions, primarily using
46 [FlatBuffers](https://google.github.io/flatbuffers/)
47
Scott Todd715ab432020-01-10 14:54:08 -080048[iree/tools/](../iree/tools/)
Scott Toddb2e34de2019-10-25 15:20:45 -070049
Scott Todd715ab432020-01-10 14:54:08 -080050* Assorted tools used to optimize, translate, and evaluate IREE
Scott Toddb2e34de2019-10-25 15:20:45 -070051
Scott Todd715ab432020-01-10 14:54:08 -080052[iree/vm/](../iree/vm/)
Scott Toddb2e34de2019-10-25 15:20:45 -070053
Scott Todd715ab432020-01-10 14:54:08 -080054* Bytecode **V**irtual **M**achine used to work with IREE modules and invoke
55 IREE functions
Scott Toddb2e34de2019-10-25 15:20:45 -070056
57## Working with IREE's Components
58
59IREE ingests MLIR in a high-level dialect like
60[XLA/HLO](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/xla),
61after which it can perform its own compiler passes to eventually translate the
62IR into an 'IREE module', which can be executed via IREE's runtime. IREE
63contains programs for running each step in that pipeline under various
64configurations (e.g. for tests, with a debugger attached, etc.).
65
66### iree-opt
67
68The `iree-opt` program invokes
Scott Todd715ab432020-01-10 14:54:08 -080069[MlirOptMain](https://github.com/llvm/llvm-project/blob/master/mlir/lib/Support/MlirOptMain.cpp)
Scott Toddb2e34de2019-10-25 15:20:45 -070070to run some set of IREE's optimization passes on a provided .mlir input file.
71Test .mlir files that are checked in typically include a `RUN` block at the top
72of the file that specifies which passes should be performed and if `FileCheck`
73should be used to test the generated output.
74
75For example, to run some passes on the
Scott Todd715ab432020-01-10 14:54:08 -080076[reshape.mlir](../iree/compiler/Translation/SPIRV/XLAToSPIRV/test/reshape.mlir)
77test file with Bazel on Linux, use this command:
Scott Toddb2e34de2019-10-25 15:20:45 -070078
79```shell
80$ bazel run //iree/tools:iree-opt -- \
81 -split-input-file \
Scott Todd715ab432020-01-10 14:54:08 -080082 -iree-index-computation \
Scott Toddb2e34de2019-10-25 15:20:45 -070083 -simplify-spirv-affine-exprs=false \
Scott Todd715ab432020-01-10 14:54:08 -080084 -convert-iree-to-spirv \
Scott Toddb2e34de2019-10-25 15:20:45 -070085 -verify-diagnostics \
Scott Todd715ab432020-01-10 14:54:08 -080086 $PWD/iree/compiler/Translation/SPIRV/XLAToSPIRV/test/reshape.mlir
Scott Toddb2e34de2019-10-25 15:20:45 -070087```
88
89### iree-translate
90
Scott Todd715ab432020-01-10 14:54:08 -080091The `iree-translate` program translates from a .mlir input file into an IREE
92module.
Scott Toddb2e34de2019-10-25 15:20:45 -070093
Scott Todd715ab432020-01-10 14:54:08 -080094For example, to translate `gather.mlir` to an IREE module with Bazel on Linux,
95use this command:
Scott Toddb2e34de2019-10-25 15:20:45 -070096
97```shell
98$ bazel run //iree/tools:iree-translate -- \
Scott Todd715ab432020-01-10 14:54:08 -080099 -iree-mlir-to-vm-bytecode-module \
100 $PWD/test/e2e/xla/gather.mlir \
Scott Toddb2e34de2019-10-25 15:20:45 -0700101 -o /tmp/module.fb
102```
103
Scott Todd715ab432020-01-10 14:54:08 -0800104Custom translations may also be layered on top of `iree-translate` - see
105[iree/samples/custom_modules/dialect](../iree/samples/custom_modules/dialect)
106for a sample.
Scott Toddb2e34de2019-10-25 15:20:45 -0700107
108### iree-run-mlir
109
110The `iree-run-mlir` program takes a .mlir file as input, translates it to an
111IREE bytecode module, and executes the module.
112
113For example, to execute the contents of a test .mlir file, use this command:
114
115```shell
Scott Todd715ab432020-01-10 14:54:08 -0800116$ bazel run //iree/tools:iree-run-mlir -- $PWD/test/e2e/xla/reverse.mlir
117```
118
119### iree-dump-module
120
121The `iree-dump-module` program prints the contents of an IREE module FlatBuffer
122file.
123
124For example:
125
126```shell
127$ bazel run //iree/tools:iree-dump-module -- /tmp/module.fb
Scott Toddb2e34de2019-10-25 15:20:45 -0700128```