Skip to content

Commit ddec425

Browse files
committed
Editing Ethos-U learning path
1 parent 5eeee23 commit ddec425

12 files changed

Lines changed: 247 additions & 75 deletions

File tree

content/learning-paths/embedded-and-microcontrollers/visualizing-tinyml-on-arm/1-overview.md renamed to content/learning-paths/embedded-and-microcontrollers/visualizing-ethos-u-performance/1-overview.md

File renamed without changes.

content/learning-paths/embedded-and-microcontrollers/visualizing-tinyml-on-arm/2-env-setup.md renamed to content/learning-paths/embedded-and-microcontrollers/visualizing-ethos-u-performance/2-env-setup.md

File renamed without changes.

content/learning-paths/embedded-and-microcontrollers/visualizing-tinyml-on-arm/4-env-setup-fvp-macos.md renamed to content/learning-paths/embedded-and-microcontrollers/visualizing-ethos-u-performance/3-env-setup-fvp.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
---
22
# User change
3-
title: "Set up the Corstone-320 FVP on macOS"
3+
title: "Set up the Corstone-320 FVP on Linux"
44

5-
weight: 5 # 1 is first, 2 is second, etc.
5+
weight: 4 # 1 is first, 2 is second, etc.
66

77
# Do not modify these elements
88
layout: "learningpathall"
99
---
1010

11-
## macOS Prerequisits
12-
13-
Setting up FVPs on MacOS requires some extra steps, outlined in GitHub repo [VPs-on-Mac](https://github.com/Arm-Examples/FVPs-on-Mac/). macOS users must do this first, before setting up the Corestone-320 FVP.
14-
15-
## Set up the Corestone-320 FVP
11+
In this section, you will run scripts to set up the Corstone-320 reference package.
1612

1713
The Corstone-320 Fixed Virtual Platform (FVP) is a pre-silicon software development environment for Arm-based microcontrollers. It provides a virtual representation of hardware, allowing developers to test and optimize software before actual hardware is available. Designed for AI and machine learning workloads, it includes support for Arm's Ethos-U NPU and Cortex-M processors, making it ideal for embedded AI applications. The FVP accelerates development by enabling early software validation and performance tuning in a flexible, simulation-based environment.
1814

1915
The Corstone reference system is provided free of charge, although you will have to accept the license in the next step. For more information on Corstone-320, check out the [official documentation](https://developer.arm.com/documentation/109761/0000?lang=en).
2016

2117
## Corstone-320 FVP Setup for ExecuTorch
2218

19+
{{% notice macOS %}}
20+
21+
Setting up FVPs on MacOS requires some extra steps, outlined in GitHub repo [VPs-on-Mac](https://github.com/Arm-Examples/FVPs-on-Mac/). macOS users must do this first, before setting up the Corestone-320 FVP.
22+
23+
{{% /notice %}}
24+
2325
Navigate to the Arm examples directory in the ExecuTorch repository. Run the following command.
2426

2527
```bash
@@ -35,6 +37,12 @@ source $HOME/executorch/examples/arm/ethos-u-scratch/setup_path.sh
3537

3638
Test that the setup was successful by running the `run.sh` script for Ethos-U85, which is the target device for Corstone-320:
3739

40+
{{% notice macOS %}}
41+
42+
**Start Docker:** on macOS, FVPs run inside a Docker container.
43+
44+
{{% /notice %}}
45+
3846
```bash
3947
./examples/arm/run.sh --target=ethos-u85-256
4048
```
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
# User change
3+
title: "How ExecuTorch Works"
4+
5+
weight: 5 # 1 is first, 2 is second, etc.
6+
7+
# Do not modify these elements
8+
layout: "learningpathall"
9+
---
10+
11+
Source: [How ExecuTorch Works](https://docs.pytorch.org/executorch/stable/intro-how-it-works.html) (official PyTorch Documentation)
12+
1. **Export the model:**
13+
* Generate a Graph
14+
* A graph is series of operators (ReLU, quantize, etc.) eligible for delegation to an accelerator
15+
* Your goal is to identify operators for acceleration on the Ethos-U NPU
16+
2. **Compile to ExecuTorch:**
17+
* This is the ahead-of-time compiler
18+
* This is why ExecuTorch inference is faster than PyTorch inference
19+
* Delegate operators to an accelerator, like the Ethos-U NPU
20+
3. **Run on targeted device:**
21+
* Deploy the ML model to the Fixed Virtual Platform (FVP) or physical device
22+
* Execute operators on the CPU and delegated operators on the Ethos-U NPU
23+
24+
**Diagram of How ExecuTorch Works**
25+
![How ExecuTorch works](./how-executorch-works-high-level.png)
26+
27+
## Deploy a TinyML Model
28+
29+
With your development environment set up, you can deploy a simple PyTorch model.
30+
31+
This example deploys the [MobileNet V2](https://pytorch.org/hub/pytorch_vision_mobilenet_v2/) computer vision model. The model is a convolutional neural network (CNN) that extracts visual features from an image. It is used for image classification and object detection.
32+
33+
The actual Python code for the MobileNet V2 model is in your local `executorch` repo: [executorch/examples/models/mobilenet_v2/model.py](https://github.com/pytorch/executorch/blob/main/examples/models/mobilenet_v2/model.py). You can deploy it using [run.sh](https://github.com/pytorch/executorch/blob/main/examples/arm/run.sh), just like you did in the previous step, with some extra parameters:
34+
35+
{{% notice macOS %}}
36+
37+
**Start Docker:** on macOS, FVPs run inside a Docker container.
38+
39+
{{% /notice %}}
40+
41+
```bash
42+
./examples/arm/run.sh \
43+
--aot_arm_compiler_flags="--delegate --quantize --intermediates mv2_u85/ --debug --evaluate" \
44+
--output=mv2_u85 \
45+
--target=ethos-u85-128 \
46+
--model_name=mv2
47+
```
48+
49+
**Explanation of run.sh Parameters**
50+
|run.sh Parameter|Meaning / Context|
51+
|--------------|-----------------|
52+
|--aot_arm_compiler_flags|Passes a string of compiler options to the ExecuTorch Ahead-of-Time (AOT) compiler|
53+
|--delegate|Enables backend delegation|
54+
|--quantize|Converts the floating-point model to int8 quantized format using post-training quantization<br>**Essential for running on NPUs**|
55+
|--intermediates mv2_u85/|Directory where intermediate files (e.g., TOSA, YAMLs, debug graphs) will be saved<br>Useful output files for **manual debugging**|
56+
|--debug|Verbose debugging logging|
57+
|--evaluate|Validates model output, provides timing estimates|

content/learning-paths/embedded-and-microcontrollers/visualizing-tinyml-on-arm/5-deploy-model.md renamed to content/learning-paths/embedded-and-microcontrollers/visualizing-ethos-u-performance/5-configure-fvp-gui.md

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
11
---
22
# User change
3-
title: "Deploy a PyTorch model"
3+
title: "Configure the FVP GUI (optional)"
44

55
weight: 6 # 1 is first, 2 is second, etc.
66

77
# Do not modify these elements
88
layout: "learningpathall"
99
---
1010

11-
## Deploy a small neural network using Python
12-
13-
With your development environment set up, you can deploy a simple PyTorch model.
14-
15-
This example deploys the [MobileNet V2](https://pytorch.org/hub/pytorch_vision_mobilenet_v2/) computer vision model. The model is a convolutional neural network (CNN) that extracts visual features from an image. It is used for image classification and object detection.
16-
17-
The actual Python code for the MobileNet V2 model is in your local `executorch` repo: [executorch/examples/models/mobilenet_v2/model.py](https://github.com/pytorch/executorch/blob/main/examples/models/mobilenet_v2/model.py). You can deploy it using [run.sh](https://github.com/pytorch/executorch/blob/main/examples/arm/run.sh), just like you did in the previous step, with some extra parameters:
18-
```bash
19-
./examples/arm/run.sh \
20-
--aot_arm_compiler_flags="--delegate --quantize --intermediates mv2_u85/ --debug --evaluate" \
21-
--output=mv2_u85 \
22-
--target=ethos-u85-128 \
23-
--model_name=mv2
24-
```
25-
26-
## Running the model on the Corstone-320 FVP GUI
27-
### Find your IP address
11+
## Find your IP address
2812

2913
Note down your computer's IP address:
3014
```bash
@@ -38,20 +22,17 @@ To help you, here are some common WiFi interface names on Linux:
3822
|wlx<MAC>|Some systems name interfaces after MAC addresses|
3923
|wifi0, ath0|Very rare, specific to certain drivers (e.g., Atheros)|
4024

41-
4225
{{% notice macOS %}}
4326

4427
Note down your `en0` IP address (or whichever network adapter is active):
4528

4629
```bash
4730
ipconfig getifaddr en0 # Returns your Mac's WiFi IP address
48-
xhost + <YOUR_MAC_IP_ADDRESS>
49-
xhost + 127.0.0.1 # The Docker container seems to proxy through localhost, so add localhost just in case
5031
```
5132

5233
{{% /notice %}}
5334

54-
### Enable the FVP's GUI
35+
## Enable the FVP's GUI
5536

5637
Edit the following parameters in [run_fvp.sh](https://github.com/pytorch/executorch/blob/d5fe5faadb8a46375d925b18827493cd65ec84ce/backends/arm/scripts/run_fvp.sh#L97-L102), to enable the Mobilenet V2 output on the FVP's GUI:
5738

@@ -78,17 +59,19 @@ Edit the following parameters in [run_fvp.sh](https://github.com/pytorch/executo
7859
--display-ip <YOUR_IP_ADDRESS> \
7960
```
8061

81-
### Deploy the model
62+
## Deploy the model
8263

8364
{{% notice macOS %}}
8465

85-
- Start Docker: on macOS, FVPs run inside a Docker container.
66+
- **Start Docker:** on macOS, FVPs run inside a Docker container.
8667

8768
**Do not use Colima Docker!**
8869

89-
Make sure to use an [official version of Docker](https://www.docker.com/products/docker-desktop/) and not a free version like the [Colima](https://github.com/abiosoft/colima?tab=readme-ov-file) Docker container runtime. `run.sh` assumes Docker Desktop style networking (`host.docker.internal`) which breaks with Colima.
70+
- Make sure to use an [official version of Docker](https://www.docker.com/products/docker-desktop/) and not a free version like the [Colima](https://github.com/abiosoft/colima?tab=readme-ov-file) Docker container runtime
71+
- `run.sh` assumes Docker Desktop style networking (`host.docker.internal`) which breaks with Colima
72+
- Colima then breaks the FVP GUI
9073

91-
- Start XQuartz: on macOS, the FVP GUI runs using XQuartz.
74+
- **Start XQuartz:** on macOS, the FVP GUI runs using XQuartz.
9275

9376
Start the xquartz.app and then configure XQuartz so that the FVP will accept connections from your Mac and localhost:
9477
```bash
@@ -108,4 +91,4 @@ Now run the Mobilenet V2 computer vision model, using [executorch/examples/arm/r
10891

10992
Observe that the FVP loads the model file, compiles the PyTorch model to ExecuTorch `.pte` format and then shows an instruction count in the top right of the GUI:
11093

111-
![Terminal and FVP output](./Terminal%20and%20FVP%20Output.png)
94+
![Terminal and FVP output](./Terminal%20and%20FVP%20Output.jpg)

0 commit comments

Comments
 (0)