Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .ci/scripts/test_cortex_m_e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# End-to-end test for Cortex-M backend: export a model via aot_arm_compiler
# with cortex-m55+int8 target, then run the .bpte on Corstone-300 FVP.
#
# Usage: bash .ci/scripts/test_cortex_m_e2e.sh <model_name>
# Example: bash .ci/scripts/test_cortex_m_e2e.sh mv2

set -eux

MODEL=$1
WORK_DIR="./cortex_m_e2e/${MODEL}"
mkdir -p "${WORK_DIR}"

echo "=== Exporting ${MODEL} with cortex-m55+int8 ==="
python -m examples.arm.aot_arm_compiler \
-m "${MODEL}" \
--target=cortex-m55+int8 \
--quantize \
--bundleio \
--intermediates="${WORK_DIR}/intermediates" \
--output="${WORK_DIR}/${MODEL}.bpte"

BPTE="${WORK_DIR}/${MODEL}.bpte"
test -f "${BPTE}" || { echo "FAIL: ${BPTE} not produced"; exit 1; }
echo "=== Exported ${BPTE} ($(stat --printf='%s' "${BPTE}") bytes) ==="

ELF="arm_test/arm_semihosting_executor_runner_corstone-300/arm_executor_runner"
test -f "${ELF}" || { echo "FAIL: executor runner not found at ${ELF}"; exit 1; }

# Copy .bpte into work dir so FVP semihosting can find it via cwd
cp "${BPTE}" "${WORK_DIR}/${MODEL}.bpte"

echo "=== Running ${MODEL} on Corstone-300 FVP ==="
FVP_Corstone_SSE-300_Ethos-U55 \
-C ethosu.num_macs=128 \
-C mps3_board.visualisation.disable-visualisation=1 \
-C cpu0.semihosting-enable=1 \
-C "cpu0.semihosting-cwd=${WORK_DIR}" \
-C "ethosu.extra_args='--fast'" \
-C "cpu0.semihosting-cmd_line='executor_runner -m ${MODEL}.bpte'" \
-a "${ELF}" \
--timelimit 300
Comment on lines +39 to +48

echo "=== SUCCESS: ${MODEL} e2e passed on FVP ==="
34 changes: 34 additions & 0 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1084,3 +1084,37 @@ jobs:

# To run cortex_m tests
pytest --config-file=backends/arm/test/pytest.ini backends/cortex_m/test

test-cortex-m-e2e:
name: test-cortex-m-e2e
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
strategy:
matrix:
model: [mv2, mv3]
fail-fast: false
permissions:
id-token: write
contents: read
with:
runner: linux.2xlarge.memory
docker-image: ci-image:executorch-ubuntu-22.04-arm-sdk
submodules: 'recursive'
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
timeout: 120
script: |
# The generic Linux job chooses to use base env, not the one setup by the image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"

source .ci/scripts/utils.sh
install_executorch "--use-pt-pinned-commit"

# Install arm dependencies
.ci/scripts/setup-arm-baremetal-tools.sh
source examples/arm/arm-scratch/setup_path.sh

# Build cortex-m test runner with bundled IO support
backends/cortex_m/test/build_test_runner.sh

# Export model and run on FVP
bash .ci/scripts/test_cortex_m_e2e.sh ${{ matrix.model }}
2 changes: 1 addition & 1 deletion backends/cortex_m/test/build_test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ aten::unsqueeze_copy.out,\
aten::select_copy.int_out,\
aten::amax.out"

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