Skip to content

Commit 85ec533

Browse files
psiddhGithub Executorch
andauthored
Summary: Add MCU model verification to CI (#13572)
Test Plan: OSS CI Reviewers: Subscribers: Tasks: Tags: ### Summary [PLEASE REMOVE] See [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests) for ExecuTorch PR guidelines. [PLEASE REMOVE] If this PR closes an issue, please add a `Fixes #<issue-id>` line. [PLEASE REMOVE] If this PR introduces a fix or feature that should be the upcoming release notes, please add a "Release notes: <area>" label. For a list of available release notes labels, check out [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests). ### Test plan [PLEASE REMOVE] How did you test this PR? Please write down any manual commands you used and note down tests that you have written if applicable. Co-authored-by: Github Executorch <[email protected]>
1 parent 6208340 commit 85ec533

File tree

2 files changed

+71
-16
lines changed

2 files changed

+71
-16
lines changed

.github/workflows/trunk.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,3 +940,42 @@ jobs:
940940
build-mode: Release
941941
build-tool: cmake
942942
docker-image: ci-image:executorch-ubuntu-22.04-clang12
943+
944+
test-mcu-models:
945+
name: test-mcu-models
946+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
947+
strategy:
948+
matrix:
949+
include:
950+
- build-tool: cmake
951+
fail-fast: false
952+
permissions:
953+
id-token: write
954+
contents: read
955+
with:
956+
runner: linux.2xlarge
957+
docker-image: ci-image:executorch-ubuntu-22.04-arm-sdk
958+
submodules: 'recursive'
959+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
960+
timeout: 90
961+
script: |
962+
BUILD_TOOL=${{ matrix.build-tool }}
963+
964+
# The generic Linux job chooses to use base env, not the one setup by the image
965+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
966+
conda activate "${CONDA_ENV}"
967+
968+
# Try to mirror these as closely as possible
969+
source .ci/scripts/utils.sh
970+
install_executorch "--use-pt-pinned-commit"
971+
972+
.ci/scripts/setup-arm-baremetal-tools.sh
973+
source examples/arm/ethos-u-scratch/setup_path.sh
974+
975+
# Run selective Build
976+
chmod +x examples/selective_build/test_selective_build.sh
977+
examples/selective_build/test_selective_build.sh "${BUILD_TOOL}"
978+
979+
# Run MCU models
980+
chmod +x examples/arm/run_mcu_models_fvp.sh
981+
examples/arm/run_mcu_models_fvp.sh --target=cortex-m55

examples/arm/run_mcu_models_fvp.sh

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,16 @@ set -u
1919

2020
# Valid targets for MCU model validation
2121
VALID_TARGETS=(
22-
"ethos-u55-32"
23-
"ethos-u55-64"
24-
"ethos-u55-128"
25-
"ethos-u55-256"
26-
"ethos-u85-128"
27-
"ethos-u85-256"
28-
"ethos-u85-512"
29-
"ethos-u85-1024"
30-
"ethos-u85-2048"
22+
"cortex-m55"
23+
"cortex-m85"
3124
)
3225

3326
# Default models for MCU validation with portable kernels
34-
DEFAULT_MODELS=(mv2 mv3 lstm resnet18)
27+
DEFAULT_MODELS=(mv2 mv3 lstm)
3528
# Available models (on FVP)
36-
AVAILABLE_MODELS=(mv2 mv3 lstm resnet18)
29+
AVAILABLE_MODELS=(mv2 mv3 lstm)
3730
# Add the following models if you want to enable them later (atm they are not working on FVP)
38-
# edsr w2l ic3 ic4 resnet50
31+
# edsr w2l ic3 ic4 resnet18 resnet50
3932

4033
# Variables
4134
TARGET=""
@@ -71,6 +64,22 @@ validate_models() {
7164
return 0
7265
}
7366

67+
cpu_to_ethos_target() {
68+
local cpu=$1
69+
case $cpu in
70+
cortex-m55)
71+
echo "ethos-u55-128"
72+
;;
73+
cortex-m85)
74+
echo "ethos-u85-128"
75+
;;
76+
*)
77+
echo "Unknown CPU: $cpu" >&2
78+
return 1
79+
;;
80+
esac
81+
}
82+
7483
# Function to show usage
7584
show_usage() {
7685
echo "Usage: $0 --target=<target> [--models=<model1,model2,...>]"
@@ -224,6 +233,13 @@ fi
224233
echo "✅ ExecuteTorch libraries built successfully"
225234
echo ""
226235

236+
ETHOS_TARGET=$(cpu_to_ethos_target "$TARGET")
237+
if [[ $? -ne 0 ]]; then
238+
echo "Invalid CPU target: $TARGET"
239+
exit 1
240+
fi
241+
echo "Using ETHOS target: $ETHOS_TARGET"
242+
227243
# Process each model
228244
for model in "${MODELS[@]}"; do
229245
echo "=== 🚀 Processing $model for $TARGET ==="
@@ -239,7 +255,7 @@ for model in "${MODELS[@]}"; do
239255
echo "⚙️ AOT compilation for $model"
240256
if ! python3 -m examples.arm.aot_arm_compiler \
241257
-m "$model" \
242-
--target="$TARGET" \
258+
--target="$ETHOS_TARGET" \
243259
--quantize \
244260
--output="arm_test/$model"; then
245261
echo "❌ AOT compilation failed for $model"
@@ -250,8 +266,8 @@ for model in "${MODELS[@]}"; do
250266
if [[ "$MODEL_SUCCESS" == true ]]; then
251267
echo "🔨 Building executor runner for $model"
252268
if ! backends/arm/scripts/build_executor_runner.sh \
253-
--pte="arm_test/$model/${model}_arm_${TARGET}.pte" \
254-
--target="$TARGET" \
269+
--pte="arm_test/$model/${model}_arm_${ETHOS_TARGET}.pte" \
270+
--target="$ETHOS_TARGET" \
255271
--output="arm_test/$model"; then
256272
echo "❌ Executor runner build failed for $model"
257273
MODEL_SUCCESS=false
@@ -263,7 +279,7 @@ for model in "${MODELS[@]}"; do
263279
echo "🏃 Running $model on FVP with portable kernels"
264280
if ! backends/arm/scripts/run_fvp.sh \
265281
--elf="arm_test/$model/arm_executor_runner" \
266-
--target="$TARGET"; then
282+
--target="$ETHOS_TARGET"; then
267283
echo "❌ FVP execution failed for $model"
268284
MODEL_SUCCESS=false
269285
fi

0 commit comments

Comments
 (0)