Skip to content

Commit 1defb11

Browse files
committed
testing and review fixes
Signed-off-by: Rob Elliott <[email protected]>
1 parent 5de8f8a commit 1defb11

File tree

2 files changed

+78
-22
lines changed

2 files changed

+78
-22
lines changed

backends/arm/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ExecuTorch Arm/TOSA Delegate
1+
# ExecuTorch Arm&reg; Delegate for TOSA devices
22

33
This subtree contains the Arm(R) Delegate implementation for ExecuTorch.
44

@@ -7,26 +7,26 @@ through an AoT flow which targets multiple Arm IP using the TOSA standard.
77

88
For more information on TOSA see https://www.mlplatform.org/tosa/tosa_spec.html
99

10-
The expected flows are:
10+
**The expected flows are:**
1111
* torch.nn.module -> TOSA for development and validation of model export
1212
* torch.nn.module -> TOSA/VGF for flows supporting a JiT compilation step.
1313
* torch.nn.module -> TOSA -> command_stream for fully AoT flows e.g. embedded.
1414

15-
Currently device support is for:
16-
* TOSA to Ethos(TM)-U55/65/85 via the ethos-u-vela compilation stack.
15+
**Currently device support is for:**
16+
* TOSA to Ethos&trade;-U55/65/85 via the ethos-u-vela compilation stack.
1717
* This is cross-compiled to the appropriate target CPU
1818
* There is a seperate arm_executor_runner for bare-metal platforms
19-
* TOSA to VGF via the model-converter for devices supporting the ML SDK for Vulkan(R)
20-
* The VGF graph represents TOSA directly in a SPIR-V(TM) standardized form.
19+
* TOSA to VGF via the model-converter for devices supporting the ML SDK for Vulkan&reg;
20+
* The VGF graph represents TOSA directly in a SPIR-V&trade; standardized form.
2121
* As the VGF delegate runs on Vulkan, it's required to be built with the Vulkan delegate also present.
2222

23-
Currently supported development platforms are:
23+
**Currently supported development platforms are:**
2424
* For ahead of time tooling
2525
* Linux aarch64
2626
* Linux x86_64
2727
* macOS with Apple silicon
2828
* Bare metal builds For the Ethos-U target and Cortex-M targets
29-
* Full testing is available in tree for the Corstone(TM) FVPs
29+
* Full testing is available in tree for the Corstone&trade; FVPs
3030
* This is a reference implementation for porting to silicon targets
3131
* Linux target support For VGF capable targets
3232
* This flow re-uses the common executor_runner
@@ -66,7 +66,7 @@ Other:
6666

6767
## Testing
6868

69-
The unit tests and related support scripts will test TOSA, Ethos-U and VGF behaviour based on the installed tools. It is expected that the relevant environment preperation has been performed as outlined in the guide available here https://docs.pytorch.org/executorch/main/tutorial-arm.html
69+
The tests and related support scripts will test TOSA, Ethos-U and VGF behaviour based on the installed tools. It is expected that the relevant environment preperation has been performed as outlined in the guide available here https://docs.pytorch.org/executorch/main/tutorial-arm.html
7070

7171
After setup you can run unit tests with the test_arm_baremetal.sh script.
7272

docs/source/tutorial-arm.md

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Arm(R) Backend Tutorial
1+
# Arm&reg; Backend Tutorial
22

33
<!----This will show a grid card on the page----->
44
::::{grid} 2
@@ -26,10 +26,10 @@ You may encounter some rough edges and features which may be documented or plann
2626

2727
```{tip}
2828
If you are already familiar with this delegate, you may want to jump directly to the examples:
29-
* [https://github.com/pytorch/executorch/tree/main/examples/arm](https://github.com/pytorch/executorch/tree/main/examples/arm)
30-
* [https://github.com/pytorch/executorch/blob/main/examples/arm/ethos_u_minimal_example.ipynb](Compilation for Ethos-U)
31-
* [https://github.com/pytorch/executorch/blob/main/examples/arm/vgf_minimal_example.ipynb](Compilation for VGF/ML-SDK)
32-
* [https://github.com/pytorch/executorch/blob/main/examples/arm/aot_arm_compiler.py](A commandline compiler for example models)
29+
* [Examples in the ExecuTorch repository](https://github.com/pytorch/executorch/tree/main/examples/arm)
30+
* [Compilation for Ethos-U](https://github.com/pytorch/executorch/blob/main/examples/arm/ethos_u_minimal_example.ipynb)
31+
* [Compilation for VGF/ML-SDK](https://github.com/pytorch/executorch/blob/main/examples/arm/vgf_minimal_example.ipynb)
32+
* [A commandline compiler for example models](https://github.com/pytorch/executorch/blob/main/examples/arm/aot_arm_compiler.py)
3333
```
3434

3535
## Prerequisites
@@ -69,7 +69,6 @@ For VGF run:
6969
```
7070
It is possible to install both sets of dependencies if you omit the disable options.
7171

72-
Upon successful execution, you can directly go to [the next step](#convert-the-pytorch-model-to-the-pte-file).
7372

7473
### Notes:
7574

@@ -203,27 +202,50 @@ graph_module_edge.exported_program = to_backend(
203202

204203
Similar to the non-delegate flow, the same script will server as a helper utility to help generate the `.pte` file. Notice the `--delegate` option to enable the `to_backend` call.
205204

205+
For Ethos targets:
206206
```bash
207207
python3 -m examples.arm.aot_arm_compiler --model_name="add" --delegate
208+
# This targets the default of ethos-u55-128, see --help for further targets
208209
# should produce ./add_arm_delegate_ethos-u55-128.pte
209210
```
210211

211-
### Delegated Quantized Workflow
212-
Generating the `.pte` file can be done using the aot_arm_compiler:
212+
For basic post-training quantization:
213213
```bash
214214
python3 -m examples.arm.aot_arm_compiler --model_name="mv2" --delegate --quantize
215+
# This targets the default of ethos-u55-128, see --help for further targets
215216
# should produce ./mv2_arm_delegate_ethos-u55-128.pte
216217
```
217218

219+
220+
For VGF targets:
221+
```bash
222+
python3 -m examples.arm.aot_arm_compiler --model_name="add" --target=vgf --delegate
223+
# should produce ./add_arm_delegate_vgf.pte
224+
```
225+
226+
For basic post-training quantization:
227+
```bash
228+
python3 -m examples.arm.aot_arm_compiler --model_name="mv2" --target=vgf --delegate --quantize
229+
# should produce ./mv2_arm_delegate_vgf.pte
230+
```
231+
232+
To capture intermediates such as VGF for lower level integration, invoke with the "-i" option:
233+
```bash
234+
python3 -m examples.arm.aot_arm_compiler --model_name="mv2" --target=vgf --delegate --quantize -i ./mv2_output
235+
# should produce ./mv2_arm_delegate_vgf.pte and intermediates in ./mv2_out/
236+
```
237+
218238
<br />
219239

220-
At the end of this, you should have three different `.pte` files.
240+
At the end of this, you should have a number of different `.pte` files.
221241

222-
- The first one contains the [SoftmaxModule](#softmaxmodule), without any backend delegates.
223-
- The second one contains the [AddModule](#addmodule), with Arm Ethos-U backend delegate enabled.
224-
- The third one contains the [quantized MV2Model](#mv2module), with the Arm Ethos-U backend delegate enabled as well.
242+
- the SoftmaxModule, without any backend delegates.
243+
- the AddModule, targeting the Arm Ethos-U backend.
244+
- the Quantized MV2Model, targeting the Arm Ethos-U backend.
245+
- the AddModule, targeting the VGF backend.
246+
- the Quantized MV2Model, targeting the VGF backend.
225247

226-
Now let's try to run these `.pte` files on a Corstone-300 and Corstone-320 platforms in a bare-metal environment.
248+
Now let's try to run these `.pte` files on a target.
227249

228250
## Getting a Bare-Metal Executable
229251

@@ -391,6 +413,40 @@ I [executorch:arm_executor_runner.cpp:179]
391413
The `run.sh` script provides various options to select a particular FVP target, use desired models, select portable kernels and can be explored using the `--help` argument
392414
```
393415
416+
## Running on the VGF backend with the standard executor_runner for Linux
417+
418+
Follow typical [Building ExecuTorch with CMake](using-executorch-building-from-source.md) flow to build the linux target, ensuring that the VGF delegate is enabled.
419+
420+
```bash
421+
-DEXECUTORCH_BUILD_VGF=ON
422+
```
423+
424+
A full example buld line is:
425+
```
426+
cmake bash \
427+
-DCMAKE_INSTALL_PREFIX=cmake-out \
428+
-DCMAKE_BUILD_TYPE=Release \
429+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
430+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
431+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
432+
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
433+
-DEXECUTORCH_BUILD_XNNPACK=OFF \
434+
-DEXECUTORCH_BUILD_VULKAN=ON \
435+
-DEXECUTORCH_BUILD_VGF=ON \
436+
-DEXECUTORCH_ENABLE_LOGGING=ON \
437+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
438+
-DPYTHON_EXECUTABLE=python \
439+
-Bcmake-out .
440+
cmake --build cmake-out -j25 --target install --config Release
441+
```
442+
443+
You can then invoke the executor runner on the host machine, which will use the VGF delegate, and requires the vulkan layer drivers we installed with setup.sh.
444+
445+
```bash
446+
./cmake-out/executor_runner -model_path add_arm_delegate_vgf.pte
447+
```
448+
449+
394450
## Takeaways
395451
In this tutorial you have learnt how to use the ExecuTorch software to both export a standard model from PyTorch and to run it on the compact and fully functioned ExecuTorch runtime, enabling a smooth path for offloading models from PyTorch to Arm based platforms.
396452

0 commit comments

Comments
 (0)