Skip to content

Commit 7107178

Browse files
committed
Add Cortex-M e2e integration tests on trunk
Add a CI job that exports models (mv2, mv3) via aot_arm_compiler.py with --target=cortex-m55+int8 and runs them on the Corstone-300 FVP. Uses matrix strategy so adding models is just appending to the list. - New .ci/scripts/test_cortex_m_e2e.sh: export + FVP runner script - Enable --bundleio in build_test_runner.sh for .bpte support - Add test-cortex-m-e2e job to trunk.yml Authored with Claude.
1 parent 569cf41 commit 7107178

3 files changed

Lines changed: 85 additions & 1 deletion

File tree

.ci/scripts/test_cortex_m_e2e.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
# End-to-end test for Cortex-M backend: export a model via aot_arm_compiler
9+
# with cortex-m55+int8 target, then run the .bpte on Corstone-300 FVP.
10+
#
11+
# Usage: bash .ci/scripts/test_cortex_m_e2e.sh <model_name>
12+
# Example: bash .ci/scripts/test_cortex_m_e2e.sh mv2
13+
14+
set -eux
15+
16+
MODEL=$1
17+
WORK_DIR="./cortex_m_e2e/${MODEL}"
18+
mkdir -p "${WORK_DIR}"
19+
20+
echo "=== Exporting ${MODEL} with cortex-m55+int8 ==="
21+
python -m examples.arm.aot_arm_compiler \
22+
-m "${MODEL}" \
23+
--target=cortex-m55+int8 \
24+
--quantize \
25+
--bundleio \
26+
--intermediates="${WORK_DIR}/intermediates" \
27+
--output="${WORK_DIR}/${MODEL}.bpte"
28+
29+
BPTE="${WORK_DIR}/${MODEL}.bpte"
30+
test -f "${BPTE}" || { echo "FAIL: ${BPTE} not produced"; exit 1; }
31+
echo "=== Exported ${BPTE} ($(stat --printf='%s' "${BPTE}") bytes) ==="
32+
33+
ELF="arm_test/arm_semihosting_executor_runner_corstone-300/arm_executor_runner"
34+
test -f "${ELF}" || { echo "FAIL: executor runner not found at ${ELF}"; exit 1; }
35+
36+
# Copy .bpte into work dir so FVP semihosting can find it via cwd
37+
cp "${BPTE}" "${WORK_DIR}/${MODEL}.bpte"
38+
39+
echo "=== Running ${MODEL} on Corstone-300 FVP ==="
40+
FVP_Corstone_SSE-300_Ethos-U55 \
41+
-C ethosu.num_macs=128 \
42+
-C mps3_board.visualisation.disable-visualisation=1 \
43+
-C cpu0.semihosting-enable=1 \
44+
-C "cpu0.semihosting-cwd=${WORK_DIR}" \
45+
-C "ethosu.extra_args='--fast'" \
46+
-C "cpu0.semihosting-cmd_line='executor_runner -m ${MODEL}.bpte'" \
47+
-a "${ELF}" \
48+
--timelimit 300
49+
50+
echo "=== SUCCESS: ${MODEL} e2e passed on FVP ==="

.github/workflows/trunk.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,3 +1084,37 @@ jobs:
10841084
10851085
# To run cortex_m tests
10861086
pytest --config-file=backends/arm/test/pytest.ini backends/cortex_m/test
1087+
1088+
test-cortex-m-e2e:
1089+
name: test-cortex-m-e2e
1090+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
1091+
strategy:
1092+
matrix:
1093+
model: [mv2, mv3]
1094+
fail-fast: false
1095+
permissions:
1096+
id-token: write
1097+
contents: read
1098+
with:
1099+
runner: linux.2xlarge.memory
1100+
docker-image: ci-image:executorch-ubuntu-22.04-arm-sdk
1101+
submodules: 'recursive'
1102+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
1103+
timeout: 120
1104+
script: |
1105+
# The generic Linux job chooses to use base env, not the one setup by the image
1106+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
1107+
conda activate "${CONDA_ENV}"
1108+
1109+
source .ci/scripts/utils.sh
1110+
install_executorch "--use-pt-pinned-commit"
1111+
1112+
# Install arm dependencies
1113+
.ci/scripts/setup-arm-baremetal-tools.sh
1114+
source examples/arm/arm-scratch/setup_path.sh
1115+
1116+
# Build cortex-m test runner with bundled IO support
1117+
backends/cortex_m/test/build_test_runner.sh
1118+
1119+
# Export model and run on FVP
1120+
bash .ci/scripts/test_cortex_m_e2e.sh ${{ matrix.model }}

backends/cortex_m/test/build_test_runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ aten::unsqueeze_copy.out,\
3131
aten::select_copy.int_out,\
3232
aten::amax.out"
3333

34-
${build_executor_runner} --pte=semihosting --target=ethos-u55-128 --output="${build_root_test_dir}" --select_ops_list="${select_ops_list}"
34+
${build_executor_runner} --pte=semihosting --bundleio --target=ethos-u55-128 --output="${build_root_test_dir}" --select_ops_list="${select_ops_list}"

0 commit comments

Comments
 (0)