@@ -223,6 +223,10 @@ jobs:
223223 permissions :
224224 id-token : write
225225 contents : read
226+ strategy :
227+ matrix :
228+ os : [bare_metal, zephyr-preset]
229+ fail-fast : false
226230 with :
227231 runner : linux.2xlarge
228232 docker-image : executorch-ubuntu-22.04-arm-sdk
@@ -234,91 +238,59 @@ jobs:
234238 CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
235239 conda activate "${CONDA_ENV}"
236240
237- source .ci/scripts/utils.sh
238- install_executorch "--use-pt-pinned-commit"
239- .ci/scripts/setup-arm-baremetal-tools.sh
240- source examples/arm/ethos-u-scratch/setup_path.sh
241-
242- # User baremetal toolchain
243- arm-none-eabi-c++ --version
244- toolchain_cmake=examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
245- toolchain_cmake=$(realpath ${toolchain_cmake})
246-
247- # Build and test size test
248- bash test/build_size_test.sh "-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DEXECUTORCH_BUILD_ARM_BAREMETAL=ON"
249- elf="cmake-out/test/size_test"
250-
251- # Dump basic info
252- ls -al ${elf}
253- arm-none-eabi-size ${elf}
254-
255- # Dump symbols
256- python .github/scripts/run_nm.py -e ${elf}
257- python .github/scripts/run_nm.py -e ${elf} -f "executorch" -p "arm-none-eabi-"
258- python .github/scripts/run_nm.py -e ${elf} -f "executorch_text" -p "arm-none-eabi-"
259-
260- # Add basic guard - TODO: refine this!
261- arm-none-eabi-strip ${elf}
262- output=$(ls -la ${elf})
263- arr=($output)
264- size=${arr[4]}
265- threshold="103268" # ~100KiB
266- echo "size: $size, threshold: $threshold"
267- if [[ "$size" -le "$threshold" ]]; then
268- echo "Success $size <= $threshold"
241+ cxx_flags="-fno-exceptions -fno-rtti -Wall -Werror -Wno-int-in-bool-context -DET_HAVE_PREAD=0"
242+ if [[ ${{ matrix.os}} == "bare_metal" ]]; then
243+ setup_script=.ci/scripts/setup-arm-baremetal-tools.sh
244+ toolchain_prefic=arm-none-eabi-
245+ threshold="103268" # ~100KiB
246+ elif [[ ${{ matrix.os}} == "zephyr-preset" ]]; then
247+ setup_script=.ci/scripts/setup-arm-zephyr-x86-64-tools.sh
248+ toolchain_prefic=arm-zephyr-eabi-
249+ threshold="153600" # should be ~138KB, set threashold to 150KB
269250 else
270- echo "Fail $size > $threshold "
251+ echo "Fail unsupport OS selection ${{ matrix.os }} "
271252 exit 1
272253 fi
273254
274- test-arm-cortex-m-zephyr-size-test :
275- name : test-arm-cortex-m-zephyr-size-test
276- uses : pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
277- permissions :
278- id-token : write
279- contents : read
280- with :
281- runner : linux.2xlarge
282- docker-image : executorch-ubuntu-22.04-arm-sdk
283- submodules : ' recursive'
284- ref : ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
285- timeout : 90
286- script : |
287- # The generic Linux job chooses to use base env, not the one setup by the image
288- CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
289- conda activate "${CONDA_ENV}"
290-
291255 source .ci/scripts/utils.sh
292256 install_executorch "--use-pt-pinned-commit"
293- .ci/scripts/setup-arm-zephyr-tools.sh
257+ ${setup_script}
294258 source examples/arm/ethos-u-scratch/setup_path.sh
295259
296- # Use arm zephyr toolchain
297- arm-zephyr-eabi-c++ --version
298- zephyr_preset=tools/cmake/preset/zephyr.cmake
299- zephyr_preset=$(realpath ${zephyr_preset})
300- toolchain_cmake=examples/arm/ethos-u-setup/arm-zephyr-eabi-gcc.cmake
260+ # User toolchain
261+ ${toolchain_prefix}c++ --version
262+ toolchain_cmake=examples/arm/ethos-u-setup/${toolchain_prefix}gcc.cmake
301263 toolchain_cmake=$(realpath ${toolchain_cmake})
302264
303265 # Build and test size test
304- bash test/build_size_test.sh "-DEXECUTORCH_BUILD_PRESET_FILE=${zephyr_preset} -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake}"
266+ if [[ ${{ matrix.os}} == "bare_metal" ]]; then
267+ bash test/build_size_test.sh "-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DEXECUTORCH_BUILD_ARM_BAREMETAL=ON"
268+ elif [[ ${{ matrix.os}} == "zephyr-preset" ]]; then
269+ CXXFLAGS=${cxx_flags} cmake --preset zephyr -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out .
270+ cmake --build cmake-out -j9 --target install --config Release
271+ CXXFLAGS=${cxx_flags} cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test
272+ cmake --build cmake-out/test -j9 --config Release
273+ else
274+ echo "Fail unsupport OS selection ${{ matrix.os }}"
275+ exit 1
276+ fi
277+
305278 elf="cmake-out/test/size_test"
306279
307280 # Dump basic info
308281 ls -al ${elf}
309- arm-zephyr-eabi- size ${elf}
282+ ${toolchain_prefix} size ${elf}
310283
311284 # Dump symbols
312285 python .github/scripts/run_nm.py -e ${elf}
313- python .github/scripts/run_nm.py -e ${elf} -f "executorch" -p "arm-zephyr-eabi- "
314- python .github/scripts/run_nm.py -e ${elf} -f "executorch_text" -p "arm-zephyr-eabi- "
286+ python .github/scripts/run_nm.py -e ${elf} -f "executorch" -p "${toolchain_prefix} "
287+ python .github/scripts/run_nm.py -e ${elf} -f "executorch_text" -p "${toolchain_prefix} "
315288
316289 # Add basic guard - TODO: refine this!
317- arm-zephyr-eabi- strip ${elf}
290+ ${toolchain_prefix} strip ${elf}
318291 output=$(ls -la ${elf})
319292 arr=($output)
320293 size=${arr[4]}
321- threshold="153600" # should be ~138KB, set threashold to 150KB
322294 echo "size: $size, threshold: $threshold"
323295 if [[ "$size" -le "$threshold" ]]; then
324296 echo "Success $size <= $threshold"
0 commit comments