xref: /aosp_15_r20/external/executorch/examples/arm/README.md (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1*523fa7a6SAndroid Build Coastguard Worker## ExecuTorch on ARM Cortex-M55 + Ethos-U55
2*523fa7a6SAndroid Build Coastguard Worker
3*523fa7a6SAndroid Build Coastguard WorkerThis dir contains scripts to help you prepare setup needed to run a PyTorch
4*523fa7a6SAndroid Build Coastguard Workermodel on an ARM Corstone-300 platform via ExecuTorch. Corstone-300 platform
5*523fa7a6SAndroid Build Coastguard Workercontains the Cortex-M55 CPU and Ethos-U55 NPU.
6*523fa7a6SAndroid Build Coastguard Worker
7*523fa7a6SAndroid Build Coastguard WorkerWe will start from a PyTorch model in python, export it, convert it to a `.pte`
8*523fa7a6SAndroid Build Coastguard Workerfile - A binary format adopted by ExecuTorch. Then we will take the `.pte`
9*523fa7a6SAndroid Build Coastguard Workermodel file and embed that with a baremetal application executor_runner. We will
10*523fa7a6SAndroid Build Coastguard Workerthen take the executor_runner file, which contains not only the `.pte` file but
11*523fa7a6SAndroid Build Coastguard Workeralso necessary software component to run standalone on a baremetal system.
12*523fa7a6SAndroid Build Coastguard WorkerLastly, we will run the executor_runner binary on a Corstone-300 FVP Simulator
13*523fa7a6SAndroid Build Coastguard Workerplatform.
14*523fa7a6SAndroid Build Coastguard Worker
15*523fa7a6SAndroid Build Coastguard Worker### Example workflow
16*523fa7a6SAndroid Build Coastguard Worker
17*523fa7a6SAndroid Build Coastguard WorkerThere are two main scripts, setup.sh and run.sh. Each takes one optional,
18*523fa7a6SAndroid Build Coastguard Workerpositional argument. It is a path to a scratch dir to download and generate
19*523fa7a6SAndroid Build Coastguard Workerbuild artifacts. If supplied, the same argument must be supplied to both the scripts.
20*523fa7a6SAndroid Build Coastguard Worker
21*523fa7a6SAndroid Build Coastguard WorkerTo run these scripts. On a Linux system, in a terminal, with a working internet connection,
22*523fa7a6SAndroid Build Coastguard Worker```
23*523fa7a6SAndroid Build Coastguard Worker# Step [1] - setup necessary tools
24*523fa7a6SAndroid Build Coastguard Worker$ ./setup.sh --i-agree-to-the-contained-eula [optional-scratch-dir]
25*523fa7a6SAndroid Build Coastguard Worker
26*523fa7a6SAndroid Build Coastguard Worker# Step [2] - build + run ExecuTorch and executor_runner baremetal application
27*523fa7a6SAndroid Build Coastguard Worker# suited for Corstone300 to run a simple PyTorch model.
28*523fa7a6SAndroid Build Coastguard Worker$ ./run.sh [--scratch-dir=same-optional-scratch-dir-as-before]
29*523fa7a6SAndroid Build Coastguard Worker```
30*523fa7a6SAndroid Build Coastguard Worker### Online Tutorial
31*523fa7a6SAndroid Build Coastguard Worker
32*523fa7a6SAndroid Build Coastguard WorkerWe also have a [tutorial](https://pytorch.org/executorch/stable/executorch-arm-delegate-tutorial.html) explaining the steps performed in these
33*523fa7a6SAndroid Build Coastguard Workerscripts, expected results, and more. It is a step-by-step guide
34*523fa7a6SAndroid Build Coastguard Workeryou can follow to better understand this delegate.
35