Skip to content

Commit bafc2e4

Browse files
BujSetGithub Executorch
authored andcommitted
Addressing some comments
1 parent d9f8f1e commit bafc2e4

File tree

8 files changed

+70
-75
lines changed

8 files changed

+70
-75
lines changed

.github/workflows/build-presets.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ jobs:
3434
${CONDA_RUN} cmake --preset ${{ matrix.preset }}
3535
${CONDA_RUN} cmake --build cmake-out -j$(( $(sysctl -n hw.ncpu) - 1 ))
3636
37+
zephyr:
38+
uses: pytorch/test-infra/.github/workflows/zephyr_job.yml@main
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
preset: [zephyr]
43+
with:
44+
job-name: build
45+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
46+
runner: linux.2xlarge
47+
docker-image: executorch-ubuntu-22.04-arm-sdk
48+
python-version: 3.12
49+
submodules: recursive
50+
timeout: 90
51+
script: |
52+
set -eux
53+
${CONDA_RUN} ./install_requirements.sh > /dev/null
54+
${CONDA_RUN} cmake --preset ${{ matrix.preset }}
55+
${CONDA_RUN} cmake --build cmake-out -j$(( $(sysctl -n hw.ncpu) - 1 ))
3756
linux:
3857
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
3958
strategy:

.github/workflows/trunk.yml

Lines changed: 34 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -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"

CMakePresets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@
112112
"common"
113113
],
114114
"cacheVariables": {
115-
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/zephyr.cmake"
115+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/zephyr.cmake",
116+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/examples/arm/ethos-u-setup/arm-zephyr-eabi-gcc.cmake"
116117
}
117118
}
118119
]

backends/arm/scripts/build_executor_runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ help() {
4646
echo " --output=<FOLDER> Output folder Default: <MODEL>/<MODEL>_<TARGET INFO>.pte"
4747
echo " --et_build_root=<FOLDER> Build output root folder to use, defaults to ${et_build_root}"
4848
echo " --ethosu_tools_dir=<FOLDER> Path to your Ethos-U tools dir if you not using default: ${ethosu_tools_dir}"
49-
echo " --toolchain=<TOOLCHAIN> Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zpehyr as arm-zephyr-eabi-gcc"
49+
echo " --toolchain=<TOOLCHAIN> Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zephyr as arm-zephyr-eabi-gcc"
5050
exit 0
5151
}
5252

backends/arm/scripts/build_portable_kernels.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ help() {
2828
echo " --et_build_root=<FOLDER> Build output root folder to use, defaults to ${et_build_root}"
2929
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
3030
echo " --portable_kernels=<OPS> Comma separated list of portable (non delagated) kernels to include Default: ${portable_kernels}"
31-
echo " --toolchain=<TOOLCHAIN> Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zpehyr as arm-zephyr-eabi-gcc"
31+
echo " --toolchain=<TOOLCHAIN> Toolchain can be specified (e.g. bare metal as arm-none-eabi-gcc or zephyr as arm-zephyr-eabi-gcc"
3232
exit 0
3333
}
3434

examples/arm/setup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ function setup_toolchain() {
234234
selected_toolchain_url="${user_toolchain_url}"
235235
selected_toolchain_dir="${user_toolchain_dir}"
236236
selected_toolchain_md5=""
237+
# TODO: For now we skip this if its a user specified url
238+
# but eventually we should verify the checksums
237239
skip_md5_verify=1
238240
fi
239241
if [[ ! -e "${selected_toolchain_dir}.tar.xz" ]]; then

test/build_size_test.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ cmake_install_executorch_lib() {
2323
update_tokenizers_git_submodule
2424
local EXTRA_BUILD_ARGS="${@}"
2525

26-
CXXFLAGS="$COMMON_CXXFLAGS" retry cmake -DBUCK2="$BUCK2" \
27-
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
28-
-DCMAKE_INSTALL_PREFIX=cmake-out \
29-
-DCMAKE_BUILD_TYPE=Release \
30-
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
31-
-DEXECUTORCH_OPTIMIZE_SIZE=ON \
32-
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
33-
${EXTRA_BUILD_ARGS} \
34-
-Bcmake-out .
26+
# CXXFLAGS="$COMMON_CXXFLAGS" retry cmake -DBUCK2="$BUCK2" \
27+
# -DCMAKE_CXX_STANDARD_REQUIRED=ON \
28+
# -DCMAKE_INSTALL_PREFIX=cmake-out \
29+
# -DCMAKE_BUILD_TYPE=Release \
30+
# -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
31+
# -DEXECUTORCH_OPTIMIZE_SIZE=ON \
32+
# -DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
33+
# ${EXTRA_BUILD_ARGS} \
34+
# -Bcmake-out .
35+
cmake --preset zephyr ${EXTRA_BUILD_ARGS} -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out .
3536
cmake --build cmake-out -j9 --target install --config Release
3637
}
3738

@@ -40,7 +41,7 @@ test_cmake_size_test() {
4041
-DCMAKE_INSTALL_PREFIX=cmake-out \
4142
${EXTRA_BUILD_ARGS} \
4243
-Bcmake-out/test test
43-
44+
# cmake --preset zephyr ${EXTRA_BUILD_ARGS} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test
4445
echo "Build size test"
4546
cmake --build cmake-out/test -j9 --config Release
4647

0 commit comments

Comments
 (0)