diff --git a/.ci/scripts/test_cortex_m_e2e.sh b/.ci/scripts/test_cortex_m_e2e.sh new file mode 100755 index 00000000000..a26ad49c8fb --- /dev/null +++ b/.ci/scripts/test_cortex_m_e2e.sh @@ -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 +# 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 + +echo "=== SUCCESS: ${MODEL} e2e passed on FVP ===" diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 282a393c7ba..89f23835852 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -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 }} diff --git a/backends/cortex_m/test/build_test_runner.sh b/backends/cortex_m/test/build_test_runner.sh index 727e91a4161..4d773835dff 100755 --- a/backends/cortex_m/test/build_test_runner.sh +++ b/backends/cortex_m/test/build_test_runner.sh @@ -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}"