Skip to content

Commit 7978364

Browse files
committed
Arm backend: Update documentation
Signed-off-by: Rob Elliott <[email protected]> Change-Id: Iec267af557921ef3780a7acc8c8a3a447fbfd5c7
1 parent 835cdaa commit 7978364

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

docs/source/executorch-arm-delegate-tutorial.md

+24-18
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,19 @@ cd core_platform
173173
git reset --hard 204210b1074071532627da9dc69950d058a809f4
174174
git am -3 <path_to>/executorch/examples/arm/ethos-u-setup/core_platform/patches/*.patch
175175
cd ../.. # To the top-level development dir
176-
177-
# Let's now patch the vela compiler
178-
cd ethos-u-vela
179-
git reset --hard 00a15db3e1a188b25065d095152d701f4394cdc5
180-
git am -3 <path_to>/executorch/examples/arm/ethos-u-setup/ethos-u-vela/patches/*.patch
181176
```
182177

183178
### Install the Vela Compiler
184179
Once the patching is done, let's finish the setup by installing the Vela compiler.
185180

186181
```bash
187-
# still in the ethos-u-vela directory
182+
cd ethos-u-vela
188183
pip install .
189184
```
190185

191186
### Install the TOSA reference model
192187
```bash
193-
git clone https://review.mlplatform.org/tosa/reference_model -b v0.80.0
188+
git clone https://review.mlplatform.org/tosa/reference_model -b v0.80
194189
cd reference_model
195190
git submodule update --init --recursive
196191
mkdir -p build
@@ -237,6 +232,8 @@ We will use a couple of simple PyTorch Modules to explore the end-to-end flow. T
237232
This is a very simple PyTorch module with just one [Softmax](https://pytorch.org/docs/stable/generated/torch.nn.Softmax.html#torch.nn.Softmax) operator.
238233

239234
```python
235+
import torch
236+
240237
class SoftmaxModule(torch.nn.Module):
241238
def __init__(self):
242239
super().__init__()
@@ -286,8 +283,8 @@ We need to be aware of data types for running networks on the Ethos-U55 as it is
286283
In the ExecuTorch AoT pipeline, one of the options is to select a backend. ExecuTorch offers a variety of different backends. Selecting backend is optional, it is typically done to target a particular mode of acceleration or hardware for a given model compute requirements. Without any backends, ExecuTorch runtime will fallback to using, available by default, a highly portable set of operators.
287284

288285
It's expected that on platforms with dedicated acceleration like the Ethos-U55, that the non-delegated flow is used for two primary cases:
289-
1. When the network is designed to be very small and best suited to run on the Cortex-M alone
290-
1. When the network has a mix of operations that can target the NPU and those that can't, e.g. the Ethos-U55 supports integer operations and so floating point softmax will fall back to execute on the CPU
286+
1. When the network is designed to be very small and best suited to run on the Cortex-M alone.
287+
2. When the network has a mix of operations that can target the NPU and those that can't, e.g. the Ethos-U55 supports integer operations and so floating point softmax will fall back to execute on the CPU.
291288

292289
In this flow, without any backend delegates, to illustrate the portability of the ExecuTorch runtime, as well as of the operator library we will skip specifying the backend during the `.pte` generation.
293290

@@ -305,7 +302,11 @@ Working with Arm, we introduced a new Arm backend delegate for ExecuTorch. This
305302
By including a following step during the ExecuTorch AoT export pipeline to generate the `.pte` file, we can enable this backend delegate.
306303

307304
```python
308-
graph_module_edge.exported_program = to_backend(model.exported_program, ArmPartitioner())
305+
from executorch.backends.arm.arm_backend import generate_ethosu_compile_spec
306+
307+
graph_module_edge.exported_program = to_backend(
308+
model.exported_program,
309+
ArmPartitioner(generate_ethosu_compile_spec("ethos-u55-128")))
309310
```
310311

311312
Similar to the non-delegate flow, the same script will server as a helper utility to help us generate the `.pte` file. Notice the `--delegate` option to enable the `to_backend` call.
@@ -352,6 +353,7 @@ To generate these libraries, use following commands,
352353
# Empty and already created
353354
cd <executorch_source_root_dir>
354355

356+
# Use provided cmake toolchain for bare-metal builds
355357
toolchain_cmake=<executorch_source_root_dir>/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
356358

357359
cmake \
@@ -361,12 +363,13 @@ cmake \
361363
-DCMAKE_BUILD_TYPE=Release \
362364
-DEXECUTORCH_ENABLE_LOGGING=ON \
363365
-DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \
366+
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
364367
-DFLATC_EXECUTABLE="$(which flatc)" \
365368
-DCMAKE_TOOLCHAIN_FILE="${toolchain_cmake}" \
366369
-B<executorch_build_dir> \
367370
<executorch_source_root_dir>
368371

369-
cmake --build <executorch_build_dir> --target install --config Release VERBOSE=1
372+
cmake --build <executorch_build_dir> --target install --config Release
370373

371374
cmake \
372375
-DCMAKE_INSTALL_PREFIX=<executorch_build_dir> \
@@ -392,27 +395,30 @@ Note, you have to generate a new `executor-runner` binary if you want to change
392395

393396
```bash
394397

395-
cd <ethos-u-sdk-dir>/core_platform/
398+
cd <executorch_source_root_dir>
399+
cd examples/arm/executor_runner
396400

397401
cmake \
398402
-DCMAKE_TOOLCHAIN_FILE="${toolchain_cmake}" \
399-
-B build targets/corstone-300 \
403+
-DTARGET_CPU=cortex-m55 \
404+
-B build \
405+
-DETHOS_SDK_PATH:PATH=<ethos-u_clone_directory> \
400406
-DET_DIR_PATH:PATH=<executorch_source_root_dir> \
401407
-DET_BUILD_DIR_PATH:PATH=<executorch_build_dir> \
402408
-DET_PTE_FILE_PATH:PATH=<path_to_pte_file_of_choice> \
403409
-DPYTHON_EXECUTABLE=$(which python3)
404410

405-
cmake --build build -- executor_runner
411+
cmake --build build -- arm_executor_runner
406412
```
407413

408414
## Running on Corstone-300 FVP Platform
409415

410416
Once the elf is prepared, regardless of the `.pte` file variant is used to generate the bare metal elf, you can run in with following command,
411417

412418
```bash
413-
ethos_u_build_dir=<ethos-u-sdk-dir>/core_platform/build/
419+
ethos_u_build_dir=examples/arm/executor_runner/
414420

415-
elf=$(find ${ethos_u_build_dir} -name "executor_runner.elf")
421+
elf=$(find ${ethos_u_build_dir} -name "arm_executor_runner")
416422

417423
FVP_Corstone_SSE-300_Ethos-U55 \
418424
-C ethosu.num_macs=128 \
@@ -488,8 +494,8 @@ Info: Simulation is stopping. Reason: CPU time has been exceeded.
488494
Through this tutorial we've 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.
489495

490496
To recap, there are two major flows:
491-
* A direct flow which offloads work onto the Cortex-M using libraries built into ExecuTorch
492-
* A delegated flow which partitions the graph into sections for Cortex-M and sections which can be offloaded and accelerated on the Ethos-U hardware
497+
* A direct flow which offloads work onto the Cortex-M using libraries built into ExecuTorch.
498+
* A delegated flow which partitions the graph into sections for Cortex-M and sections which can be offloaded and accelerated on the Ethos-U hardware.
493499

494500
Both of these flows continue to evolve, enabling more use-cases and better performance.
495501

0 commit comments

Comments
 (0)