Skip to content

Commit 510aef3

Browse files
committed
Arm backend: Test TOSA, Ethos-U55 and Ethos-U85 on github
This will run some more models in the github test flow and also enable some unit tests to use Corston3x0 FVP. This structure up the Arm backend testing into separate runable scripts in the same structure as other backends. Signed-off-by: Zingo Andersen <[email protected]> Change-Id: I5e11b1aca19460845e330b84d0696513c400c0f0
1 parent e94c2ff commit 510aef3

File tree

6 files changed

+146
-21
lines changed

6 files changed

+146
-21
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Copyright 2024 Arm Limited and/or its affiliates.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# NB: This function could be used to install Arm dependencies
8+
# Setup arm example environment (including TOSA tools)
9+
git config --global user.email "[email protected]"
10+
git config --global user.name "Github Executorch"
11+
bash examples/arm/setup.sh --i-agree-to-the-contained-eula

.ci/scripts/utils.sh

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,6 @@ install_flatc_from_source() {
5959
popd || return
6060
}
6161

62-
install_arm() {
63-
# NB: This function could be used to install Arm dependencies
64-
# Setup arm example environment (including TOSA tools)
65-
git config --global user.email "[email protected]"
66-
git config --global user.name "Github Executorch"
67-
bash examples/arm/setup.sh --i-agree-to-the-contained-eula
68-
69-
# Test tosa_reference flow
70-
source examples/arm/ethos-u-scratch/setup_path.sh
71-
}
72-
7362
build_executorch_runner_buck2() {
7463
# Build executorch runtime with retry as this step is flaky on macos CI
7564
retry buck2 build //examples/portable/executor_runner:executor_runner

.github/workflows/pull.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,11 @@ jobs:
354354
EXECUTORCH_BUILD_ARM_BAREMETAL=ON \
355355
.ci/scripts/setup-linux.sh "${BUILD_TOOL}"
356356
357-
source .ci/scripts/utils.sh
358357
# Install Arm dependencies
359-
install_arm
360-
361-
# Run pytest with coverage
362-
pytest -c /dev/null -v -n auto --cov=./ --cov-report=xml backends/arm/test
358+
.ci/scripts/setup-arm-baremetal-tools.sh
363359
360+
# Run pytest without simulator
361+
backends/arm/test/test_arm_baremetal.sh test_pytest
364362
365363
test-llama-runner-qnn-linux:
366364
name: test-llama-runner-qnn-linux

.github/workflows/trunk.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,15 @@ jobs:
146146
source .ci/scripts/utils.sh
147147
install_executorch
148148
149-
install_arm
149+
.ci/scripts/setup-arm-baremetal-tools.sh
150150
151151
# Increase number of files user can monitor to bypass buck failures.
152152
# Hopefully this is high enough for this setup.
153153
sudo sysctl fs.inotify.max_user_watches=1048576 # 1024 * 1024
154154
155155
# Test ethos-u delegate examples with run.sh
156-
PYTHON_EXECUTABLE=python bash examples/arm/run.sh examples/arm/ethos-u-scratch/
156+
backends/arm/test/test_arm_baremetal.sh test_run_ethosu_fvp
157+
157158
158159
test-arm-reference-delegation:
159160
name: test-arm-reference-delegation
@@ -172,10 +173,10 @@ jobs:
172173
source .ci/scripts/utils.sh
173174
install_executorch
174175
175-
install_arm
176+
.ci/scripts/setup-arm-baremetal-tools.sh
176177
177-
# Run arm unit tests
178-
pytest -c /dev/null -v -n auto --cov=./ --cov-report=xml backends/arm/test
178+
# Run arm unit tests using the simulator
179+
backends/arm/test/test_arm_baremetal.sh test_pytest_ethosu_fvp
179180
180181
test-coreml-delegate:
181182
name: test-coreml-delegate

backends/arm/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ Other:
3939
- `third-party/` - Dependencies on other code - in particular the TOSA serialization_lib for compiling to TOSA and the ethos-u-core-driver for the bare-metal backend supporting Ethos-U
4040
- `test/` - Unit test and test support functions
4141

42+
## Testing
43+
44+
After a setup you can run unit tests with the test_arm_baremetal.sh script.
45+
46+
To run the pytests suite run
47+
48+
```
49+
backends/arm/test/test_arm_baremetal.sh test_pytest
50+
```
51+
52+
To run the unit test suite with Corstone3x0 FVP simulator support use
53+
54+
```
55+
backends/arm/test/test_arm_baremetal.sh test_pytest_ethosu_fvp
56+
```
57+
58+
You can test to run some models with the run.sh flow
59+
60+
```
61+
backends/arm/test/test_arm_baremetal.sh test_run_ethosu_fvp
62+
```
63+
4264
## Unit tests
4365
This is the structure of the test directory
4466

@@ -51,6 +73,8 @@ test # Root test folder
5173
├── tester # Arm Tester class
5274
├── tosautil # Utility functions for TOSA artifacts
5375
├ common.py # Common functions and definitions used by many tests
76+
├ setup_testing.sh # Script to prepare testing for using the Corstone 3x0 FVP
77+
├ test_arm_baremetal.sh # Help script to trigger testing
5478
```
5579

5680
Some example commands to run these tests follow. Run a single test:
@@ -59,6 +83,12 @@ Some example commands to run these tests follow. Run a single test:
5983
python -m unittest backends.arm.test.ops.test_add.TestSimpleAdd -k test_add2_tosa_BI
6084
```
6185

86+
or with pytest
87+
88+
```
89+
pytest -c /dev/null -v -n auto backends/arm/test/ops/test_add.py -k test_add2_tosa_BI
90+
```
91+
6292
Or all tests in "TestSimpleAdd":
6393

6494
```
@@ -71,6 +101,28 @@ Or discover and run many tests:
71101
python -m unittest discover -s backends/arm/test/ops/
72102
```
73103

104+
or with pytest
105+
106+
```
107+
pytest -c /dev/null -v -n auto backends/arm/test/ops/
108+
```
109+
110+
111+
You can run tests using Corstone3x0 simulators to see how it would work on something more target like
112+
first you need to build and prepare some used target libs
113+
114+
```
115+
examples/arm/run.sh --model_name=add --build_only
116+
backends/arm/test/setup_testing.sh
117+
```
118+
119+
The you can run the tests with
120+
121+
```
122+
pytest -c /dev/null -v -n auto backends/arm/test --arm_quantize_io --arm_run_corstoneFVP
123+
```
124+
125+
74126
### A note on unit tests
75127

76128
There are currently 3 ways we unit test our code.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
# Copyright 2024 Arm Limited and/or its affiliates.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
TEST_SUITE=$1
8+
9+
help() {
10+
echo "Usage:"
11+
echo " $0 <TESTNAME>"
12+
echo " where <TESTNAME> can be any of:"
13+
# This will list all lines in this file that is starting with test_ remove () { and print it as a list.
14+
# e,g, "test_pytest() { # Test ops and other things" -> test_pytest # Test ops and other things
15+
grep "^test_" $0 | sed 's/([^)]*)[[:space:]]*{*//g'
16+
exit
17+
}
18+
19+
if [[ -z "${TEST_SUITE:-}" ]]; then
20+
echo "Missing test suite name, exiting..."
21+
help
22+
else
23+
echo "Run Arm baremetal test suite ${TEST_SUITE}"
24+
fi
25+
26+
TEST_SUITE_NAME="$(basename "$0") ${TEST_SUITE}"
27+
28+
test_pytest() { # Test ops and other things
29+
echo "${TEST_SUITE_NAME}: Run pytest"
30+
31+
source examples/arm/ethos-u-scratch/setup_path.sh
32+
33+
# Run arm baremetal pytest tests without FVP
34+
pytest -c /dev/null -v -n auto backends/arm/test
35+
}
36+
37+
test_pytest_ethosu_fvp() { # Same as test_pytest but also sometime verify using Corstone FVP
38+
echo "${TEST_SUITE_NAME}: Run pytest with fvp"
39+
40+
source examples/arm/ethos-u-scratch/setup_path.sh
41+
42+
# Prepare Corstone-3x0 FVP for pytest
43+
examples/arm/run.sh --model_name=add --build_only
44+
backends/arm/test/setup_testing.sh
45+
46+
# Run arm baremetal pytest tests with FVP
47+
pytest -c /dev/null -v -n auto backends/arm/test --arm_quantize_io --arm_run_corstoneFVP
48+
}
49+
50+
test_run_ethosu_fvp() { # End to End model tests
51+
echo "${TEST_SUITE_NAME}: Test ethos-u delegate examples with run.sh"
52+
53+
source examples/arm/ethos-u-scratch/setup_path.sh
54+
55+
# TOSA quantized
56+
echo "${TEST_SUITE_NAME}: Test ethos-u target TOSA"
57+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh --target=TOSA --model_name=mv2
58+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh --target=TOSA --model_name=lstm
59+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh --target=TOSA --model_name=esdr
60+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh --target=TOSA --model_name=emformer_join
61+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh --target=TOSA --model_name=w2l
62+
63+
# Ethos-U55
64+
echo "${TEST_SUITE_NAME}: Test ethos-u target Ethos-U55"
65+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh --target=ethos-u55-128 --model_name=mv2
66+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh --target=ethos-u55-128 --model_name=lstm --reorder_inputs=1,0,2
67+
68+
# Ethos-U85
69+
echo "${TEST_SUITE_NAME}: Test ethos-u target Ethos-U85"
70+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh --target=ethos-u85-128 --model_name=mv2
71+
PYTHON_EXECUTABLE=python bash examples/arm/run.sh --target=ethos-u85-128 --model_name=lstm --reorder_inputs=1,0,2
72+
}
73+
74+
${TEST_SUITE}

0 commit comments

Comments
 (0)