Skip to content

Commit ee5ffe3

Browse files
digantdesaifacebook-github-bot
authored andcommitted
ET][Docs] Update setup_et and examples/README.md to use executor_runner
Summary: As title Reviewed By: mergennachin, kimishpatel, dbort Differential Revision: D47890317 fbshipit-source-id: feb9e2d654686262bd71071d2165432fd31012d9
1 parent 8d28f1c commit ee5ffe3

File tree

2 files changed

+62
-15
lines changed

2 files changed

+62
-15
lines changed

docs/website/docs/tutorials/00_setting_up_executorch.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ Or via python interpreter:
6161
>>> open("add.ff", "wb").write(exir.capture(m, m.get_random_inputs()).to_edge().to_executorch().buffer)
6262
```
6363

64-
If exporting mobilenet v2/v3, run `install_requirements.sh`.
65-
66-
```bash
67-
bash examples/install_requirements.sh
68-
69-
python3 -m examples.export.export_example --model_name="mv2"
70-
```
71-
7264
## Runtime Setup
7365

7466
**Step 1: Install buck2**
@@ -85,10 +77,10 @@ You may want to copy the `buck2` binary into your `$PATH` so you can run it as `
8577

8678
**Step 2: Build a binary**
8779

88-
`size_test_all_ops` is a binary including all the operators and backends
80+
`executor_runner` is an example wrapper around executorch runtime which includes all the operators and backends
8981

9082
```bash
91-
/tmp/buck2 build //test:size_test_all_ops --show-output
83+
/tmp/buck2 build //examples/executor_runner:executor_runner --show-output
9284
```
9385

9486
The `--show-output` flag will print the path to the executable if you want to run it directly.
@@ -102,14 +94,19 @@ conda install -c conda-forge lld
10294

10395
```bash
10496
# add.ff is the program generated from export_example.py during AOT Setup Step 3
105-
/tmp/buck2 run //test:size_test_all_ops -- add.ff
97+
/tmp/buck2 run //examples/executor_runner:executor_runner -- --model_path add.ff
10698

10799
# To run a delegated model
108-
/tmp/buck2 run //test:size_test_all_ops -- composite_model.ff
100+
/tmp/buck2 run //examples/executor_runner:executor_runner -- --model_path composite_model.ff
109101
```
110102

111103
or execute the binary directly from the `--show-output` path shown when building.
112104

113105
```bash
114-
./buck-out/.../size_test_all_ops add.ff
106+
./buck-out/.../executor_runner --model_path add.ff
115107
```
108+
109+
## More examples
110+
111+
The `executorch/examples` directory contains useful scripts with a guide to lower and run
112+
popular models like MobileNetv2 on Executorch.

examples/README.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,59 @@
1+
# Examples
2+
3+
This dir contains scripts and other helper utilities to illustrate an end-to-end workflow to run a torch.nn.module on the Executorch runtime.
4+
It also includes a list of modules, from a simple `Add` to a full model like `MobileNetv2` and `MobileNetv3`, with more to come.
5+
6+
7+
## Directory structure
8+
```bash
9+
examples
10+
├── executor_runner # This is an example C++ wrapper around the ET runtime
11+
├── export # Python helper scripts to illustrate export workflow
12+
├── models # Contains a set of simple to PyTorch models
13+
└── README.md # This file
14+
```
15+
16+
## Using the examples
17+
18+
We will walk through an example model to generate a binary file from a python torch.nn.module
19+
from the `models` dir using scripts from the `export` dir. Then we will run on these binary
20+
model files on the Executorch (ET) runtime. For that we will use `executor_runner`. It is a simple
21+
wrapper for the Executorch runtime to serve as an example. Although simple, it is capable of loading
22+
and executing previously exported binary file(s).
23+
24+
25+
1. Following the setup guide in [Setting up ExecuTorch from GitHub](/docs/website/docs/tutorials/00_setting_up_executorch.md)
26+
you should be able to get the basic development environment for Executorch working.
27+
28+
2. Using the script `export/export_example.py` generate a model binary file by selecting a
29+
model name from the list of available models in the `models` dir.
30+
31+
32+
```bash
33+
cd executorch # To the top level dir
34+
35+
bash examples/install_requirements.sh
36+
37+
python3 -m examples.export.export_example --model_name="mv2" # for MobileNetv2
38+
39+
# This should generate ./mv2.ff file, if successful.
40+
```
41+
42+
3. Once we have the model binary (ff) file, then let's run it with Executorch runtime using the `executor_runner`.
43+
44+
```bash
45+
buck2 run examples/executor_runner:executor_runner -- --model_path mv2.ff
46+
```
47+
48+
For MobileNetv3, change the model name and the corrosponding binary filename from "mv2" to "mv3".
49+
150
## Dependencies
251

352
Various models listed in this directory have dependencies on some other packages, e.g. torchvision, torchaudio.
453
In order to make sure model's listed in examples are importable, e.g. via
5-
```
54+
55+
```python
656
from executorch.examples.models.mobilenet_v3d import MV3Model
757
m = MV3Model.get_model()
858
```
9-
we need to have appropriate packages installed. You should install these deps via install_requirements.sh
59+
we need to have appropriate packages installed. You should install these deps via install_requirements.sh.

0 commit comments

Comments
 (0)