Skip to content

Commit 8e2a8d1

Browse files
committed
[trunk.yml] Add cortex-m binary size test
Just getting started. We will build on top of this.
1 parent a52b216 commit 8e2a8d1

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.github/workflows/trunk.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,60 @@ jobs:
231231
# Run arm unit tests using the simulator
232232
backends/arm/test/test_arm_baremetal.sh test_pytest_ethosu_fvp
233233
234+
test-arm-cortex-m-size-test:
235+
name: test-arm-cortex-m-size-test
236+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
237+
permissions:
238+
id-token: write
239+
contents: read
240+
with:
241+
runner: linux.2xlarge
242+
docker-image: executorch-ubuntu-22.04-arm-sdk
243+
submodules: 'true'
244+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
245+
timeout: 90
246+
script: |
247+
# The generic Linux job chooses to use base env, not the one setup by the image
248+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
249+
conda activate "${CONDA_ENV}"
250+
251+
source .ci/scripts/utils.sh
252+
install_executorch "--use-pt-pinned-commit"
253+
.ci/scripts/setup-arm-baremetal-tools.sh
254+
source examples/arm/ethos-u-scratch/setup_path.sh
255+
256+
# User baremetal toolchain
257+
arm-none-eabi-c++ --version
258+
toolchain_cmake=examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
259+
toolchain_cmake=$(realpath ${toolchain_cmake})
260+
261+
# Build and test size test
262+
bash test/build_size_test.sh "-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DEXECUTORCH_BUILD_ARM_BAREMETAL=ON"
263+
elf="cmake-out/test/size_test"
264+
265+
# Dump basic info
266+
ls -al ${elf}
267+
arm-none-eabi-size ${elf}
268+
269+
# Dump symbols
270+
python .github/scripts/run_nm.py -e ${elf}
271+
python .github/scripts/run_nm.py -e ${elf} -f "executorch" -p "arm-none-eabi-"
272+
python .github/scripts/run_nm.py -e ${elf} -f "executorch_text" -p "arm-none-eabi-"
273+
274+
# Add basic guard - TODO: refine this!
275+
arm-none-eabi-strip ${elf}
276+
output=$(ls -la ${elf})
277+
arr=($output)
278+
size=${arr[4]}
279+
threshold="102400" # 100KiB
280+
echo "size: $size, threshold: $threshold"
281+
if [[ "$size" -le "$threshold" ]]; then
282+
echo "Success $size <= $threshold"
283+
else
284+
echo "Fail $size > $threshold"
285+
exit 1
286+
fi
287+
234288
test-coreml-delegate:
235289
name: test-coreml-delegate
236290
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main

examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,7 @@ add_compile_options(
9797
# -Wall -Wextra -Wcast-align -Wdouble-promotion -Wformat
9898
# -Wmissing-field-initializers -Wnull-dereference -Wredundant-decls -Wshadow
9999
# -Wswitch -Wswitch-default -Wunused -Wno-redundant-decls
100+
-Wno-error=deprecated-declarations
101+
-Wno-error=shift-count-overflow
100102
-Wno-psabi
101103
)

0 commit comments

Comments
 (0)