Skip to content
Merged
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
39 changes: 39 additions & 0 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -940,3 +940,42 @@ jobs:
build-mode: Release
build-tool: cmake
docker-image: ci-image:executorch-ubuntu-22.04-clang12

test-mcu-models:
name: test-mcu-models
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
strategy:
matrix:
include:
- build-tool: cmake
fail-fast: false
permissions:
id-token: write
contents: read
with:
runner: linux.2xlarge
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: 90
script: |
BUILD_TOOL=${{ matrix.build-tool }}

# 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}"

# Try to mirror these as closely as possible
source .ci/scripts/utils.sh
install_executorch "--use-pt-pinned-commit"

.ci/scripts/setup-arm-baremetal-tools.sh
source examples/arm/ethos-u-scratch/setup_path.sh

# Run selective Build
chmod +x examples/selective_build/test_selective_build.sh
examples/selective_build/test_selective_build.sh "${BUILD_TOOL}"

# Run MCU models
chmod +x examples/arm/run_mcu_models_fvp.sh
examples/arm/run_mcu_models_fvp.sh --target=cortex-m55
48 changes: 32 additions & 16 deletions examples/arm/run_mcu_models_fvp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,16 @@ set -u

# Valid targets for MCU model validation
VALID_TARGETS=(
"ethos-u55-32"
"ethos-u55-64"
"ethos-u55-128"
"ethos-u55-256"
"ethos-u85-128"
"ethos-u85-256"
"ethos-u85-512"
"ethos-u85-1024"
"ethos-u85-2048"
"cortex-m55"
"cortex-m85"
)

# Default models for MCU validation with portable kernels
DEFAULT_MODELS=(mv2 mv3 lstm resnet18)
DEFAULT_MODELS=(mv2 mv3 lstm)
# Available models (on FVP)
AVAILABLE_MODELS=(mv2 mv3 lstm resnet18)
AVAILABLE_MODELS=(mv2 mv3 lstm)
# Add the following models if you want to enable them later (atm they are not working on FVP)
# edsr w2l ic3 ic4 resnet50
# edsr w2l ic3 ic4 resnet18 resnet50

# Variables
TARGET=""
Expand Down Expand Up @@ -71,6 +64,22 @@ validate_models() {
return 0
}

cpu_to_ethos_target() {
local cpu=$1
case $cpu in
cortex-m55)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah perfect!! ❤️

echo "ethos-u55-128"
;;
cortex-m85)
echo "ethos-u85-128"
;;
*)
echo "Unknown CPU: $cpu" >&2
return 1
;;
esac
}

# Function to show usage
show_usage() {
echo "Usage: $0 --target=<target> [--models=<model1,model2,...>]"
Expand Down Expand Up @@ -224,6 +233,13 @@ fi
echo "✅ ExecuteTorch libraries built successfully"
echo ""

ETHOS_TARGET=$(cpu_to_ethos_target "$TARGET")
if [[ $? -ne 0 ]]; then
echo "Invalid CPU target: $TARGET"
exit 1
fi
echo "Using ETHOS target: $ETHOS_TARGET"

# Process each model
for model in "${MODELS[@]}"; do
echo "=== 🚀 Processing $model for $TARGET ==="
Expand All @@ -239,7 +255,7 @@ for model in "${MODELS[@]}"; do
echo "⚙️ AOT compilation for $model"
if ! python3 -m examples.arm.aot_arm_compiler \
-m "$model" \
--target="$TARGET" \
--target="$ETHOS_TARGET" \
--quantize \
--output="arm_test/$model"; then
echo "❌ AOT compilation failed for $model"
Expand All @@ -250,8 +266,8 @@ for model in "${MODELS[@]}"; do
if [[ "$MODEL_SUCCESS" == true ]]; then
echo "🔨 Building executor runner for $model"
if ! backends/arm/scripts/build_executor_runner.sh \
--pte="arm_test/$model/${model}_arm_${TARGET}.pte" \
--target="$TARGET" \
--pte="arm_test/$model/${model}_arm_${ETHOS_TARGET}.pte" \
--target="$ETHOS_TARGET" \
--output="arm_test/$model"; then
echo "❌ Executor runner build failed for $model"
MODEL_SUCCESS=false
Expand All @@ -263,7 +279,7 @@ for model in "${MODELS[@]}"; do
echo "🏃 Running $model on FVP with portable kernels"
if ! backends/arm/scripts/run_fvp.sh \
--elf="arm_test/$model/arm_executor_runner" \
--target="$TARGET"; then
--target="$ETHOS_TARGET"; then
echo "❌ FVP execution failed for $model"
MODEL_SUCCESS=false
fi
Expand Down
Loading