blob: e530b24c52cc8e057a443bb5c7815090d2b40d99 [file] [log] [blame] [view]
Scott Toddb2e34de2019-10-25 15:20:45 -07001# Getting Started
2
3This document provides an overview of the systems in IREE, including entry
4points to get started exploring IREE's capabilities.
5
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
10## Code Layout
11
12[base/](../iree/base/)
13
14* Common types and utilities used throughout IREE
15
16[compiler/](../iree/compiler/)
17
18* IREE's MLIR dialect, LLVM compiler passes, IREE module translation, etc.
19
20[hal/](../iree/hal/)
21
22* **H**ardware **A**bstraction **L**ayer for IREE's runtime, containing
23 implementations for different hardware and software backends
24
25[rt/](../iree/rt/)
26
27* **R**un**t**ime API for interfacing with IREE
28
29[schemas/](../iree/schemas/)
30
31* Shared data storage format definitions, primarily using
32 [FlatBuffers](https://google.github.io/flatbuffers/)
33
34[tools/](../iree/tools/)
35
36* Assorted tools used to optimize, translate, and evaluate IREE, including
37 IREE's debugger
38
39[vm/](../iree/vm/)
40
41* Bytecode **V**irtual **M**achine used to work with IREE modules and provide
42 an interface for hosting applications to invoke IREE functions
43
44## Working with IREE's Components
45
46IREE ingests MLIR in a high-level dialect like
47[XLA/HLO](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/xla),
48after which it can perform its own compiler passes to eventually translate the
49IR into an 'IREE module', which can be executed via IREE's runtime. IREE
50contains programs for running each step in that pipeline under various
51configurations (e.g. for tests, with a debugger attached, etc.).
52
53### iree-opt
54
55The `iree-opt` program invokes
56[MlirOptMain](https://github.com/tensorflow/mlir/blob/master/lib/Support/MlirOptMain.cpp)
57to run some set of IREE's optimization passes on a provided .mlir input file.
58Test .mlir files that are checked in typically include a `RUN` block at the top
59of the file that specifies which passes should be performed and if `FileCheck`
60should be used to test the generated output.
61
62For example, to run some passes on the
63[reshape.mlir](../iree/compiler/Translation/SPIRV/test/reshape.mlir) test file
64with Bazel on Linux, use this command:
65
66```shell
67$ bazel run //iree/tools:iree-opt -- \
68 -split-input-file \
69 -convert-iree-to-spirv \
70 -simplify-spirv-affine-exprs=false \
71 -verify-diagnostics \
72 $PWD/iree/compiler/Translation/SPIRV/test/reshape.mlir
73```
74
75### iree-translate
76
77The `iree-translate` program invokes
78[mlir-translate](https://github.com/tensorflow/mlir/blob/master/tools/mlir-translate/mlir-translate.cpp)
79to translate from a .mlir input file into an IREE module.
80
81For example, to translate `simple_compute_test.mlir` to an IREE module with
82Bazel on Linux, use this command:
83
84```shell
85$ bazel run //iree/tools:iree-translate -- \
86 -mlir-to-iree-module \
87 $PWD/iree/samples/hal/simple_compute_test.mlir \
88 -o /tmp/module.fb
89```
90
91### run_module
92
93The `run_module` program takes an already translated IREE module as input and
94executes an exported main function using the provided inputs.
95
96This program can be used in sequence with `iree-translate` to translate a .mlir
97file to an IREE module and then execute it. Here is an example command that runs
98the `simple_mul` function in `simple_compute_test.mlir`.
99
100```shell
101$ bazel build -c opt //iree/tools:iree-translate //iree/tools:run_module
102$ ./bazel-bin/iree/tools/run_module \
103 --main_module=/tmp/module.fb \
104 --main_function=simple_mul \
105 --input_values="4xf32=1 2 3 4
106 4xf32=5 6 7 8"
107```
108
109### iree-run-mlir
110
111The `iree-run-mlir` program takes a .mlir file as input, translates it to an
112IREE bytecode module, and executes the module.
113
114For example, to execute the contents of a test .mlir file, use this command:
115
116```shell
117$ bazel run //iree/tools:iree-run-mlir -- $PWD/test/e2e/scalars.mlir
118```