Skip to content

Commit 69d7dbb

Browse files
authored
Merge branch 'main' into export-D77479748
2 parents 299b4c3 + 6da7bde commit 69d7dbb

File tree

102 files changed

+2426
-1055
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2426
-1055
lines changed

.ci/scripts/setup-arm-baremetal-tools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
# Setup arm example environment (including TOSA tools)
99
git config --global user.email "[email protected]"
1010
git config --global user.name "Github Executorch"
11-
bash examples/arm/setup.sh --i-agree-to-the-contained-eula
11+
bash examples/arm/setup.sh --i-agree-to-the-contained-eula ${@:-}

.ci/scripts/test_model.sh

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,6 @@ test_model_with_qnn() {
188188
EXPORT_SCRIPT=edsr
189189
# Additional deps for edsr
190190
pip install piq
191-
elif [[ "${MODEL_NAME}" == "cvt" ]]; then
192-
EXPORT_SCRIPT=cvt
193-
elif [[ "${MODEL_NAME}" == "dit" ]]; then
194-
EXPORT_SCRIPT=dit
195-
elif [[ "${MODEL_NAME}" == "efficientnet" ]]; then
196-
EXPORT_SCRIPT=efficientnet
197-
elif [[ "${MODEL_NAME}" == "focalnet" ]]; then
198-
EXPORT_SCRIPT=focalnet
199-
elif [[ "${MODEL_NAME}" == "mobilevit_v1" ]]; then
200-
EXPORT_SCRIPT=mobilevit_v1
201-
elif [[ "${MODEL_NAME}" == "mobilevit_v2" ]]; then
202-
EXPORT_SCRIPT=mobilevit_v2
203-
elif [[ "${MODEL_NAME}" == "pvt" ]]; then
204-
EXPORT_SCRIPT=pvt
205-
elif [[ "${MODEL_NAME}" == "swin" ]]; then
206-
EXPORT_SCRIPT=swin_transformer
207191
elif [[ "${MODEL_NAME}" == "albert" ]]; then
208192
EXPORT_SCRIPT=albert
209193
elif [[ "${MODEL_NAME}" == "bert" ]]; then
@@ -212,8 +196,6 @@ test_model_with_qnn() {
212196
EXPORT_SCRIPT=distilbert
213197
elif [[ "${MODEL_NAME}" == "eurobert" ]]; then
214198
EXPORT_SCRIPT=eurobert
215-
elif [[ "${MODEL_NAME}" == "roberta" ]]; then
216-
EXPORT_SCRIPT=roberta
217199
else
218200
echo "Unsupported model $MODEL_NAME"
219201
exit 1
@@ -228,13 +210,10 @@ test_model_with_qnn() {
228210
"dl3"|"mv3"|"mv2"|"ic4"|"ic3"|"vit"|"mb"|"w2l")
229211
SCRIPT_FOLDER=scripts
230212
;;
231-
"cvt"|"dit"|"focalnet"|"mobilevit_v2"|"pvt"|"swin")
232-
SCRIPT_FOLDER=oss_scripts
233-
;;
234-
"albert"|"bert"|"distilbert"|"roberta"|"efficientnet"|"mobilevit_v1")
213+
"albert"|"bert"|"distilbert")
235214
pip install evaluate
236215
SCRIPT_FOLDER=oss_scripts
237-
# 16bit models will encounter op validation fail on some operations,
216+
# Bert models running in 16bit will encounter op validation fail on some operations,
238217
# which requires CHIPSET >= SM8550.
239218
QNN_CHIPSET=SM8550
240219
;;

.github/workflows/build-presets.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,45 @@ 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/linux_job_v2.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+
submodules: recursive
49+
timeout: 90
50+
script: |
51+
set -eux
52+
# The generic Linux job chooses to use base env, not the one setup by the image
53+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
54+
conda activate "${CONDA_ENV}"
55+
56+
./install_requirements.sh > /dev/null
57+
58+
# Download toolchain
59+
toolchain_url="https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.2/toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz"
60+
toolchain_dir="arm-zephyr-eabi"
61+
curl --output "${toolchain_dir}.tar.xz" -L "${toolchain_url}"
62+
63+
# Verify download
64+
echo "93128be0235cf5cf5f1ee561aa6eac5f ${toolchain_dir}.tar.xz" > arm-zephyr-eabi.md5
65+
md5sum -c --strict arm-zephyr-eabi.md5
66+
67+
# Extract and install to PATH
68+
tar xf "${toolchain_dir}.tar.xz"
69+
rm -f "${toolchain_dir}.tar.xz"
70+
toolchain_bin_path="$(cd ${toolchain_dir}/bin && pwd)"
71+
export PATH=$PATH:${toolchain_bin_path}
72+
73+
# Build Arm Zephyr Preset
74+
cmake --preset ${{ matrix.preset }}
75+
cmake --build cmake-out -j$(( $(nproc) - 1 ))
3776
linux:
3877
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
3978
strategy:

.github/workflows/trunk.yml

Lines changed: 76 additions & 15 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,35 +238,62 @@ jobs:
234238
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
235239
conda activate "${CONDA_ENV}"
236240
241+
cxx_flags="-fno-exceptions -fno-rtti -Wall -Werror -Wno-int-in-bool-context -DET_HAVE_PREAD=0"
242+
setup_script_args=""
243+
if [[ ${{ matrix.os}} == "bare_metal" ]]; then
244+
toolchain_prefix=arm-none-eabi-
245+
threshold="103268" # ~100KiB
246+
toolchain_cmake=examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
247+
elif [[ ${{ matrix.os}} == "zephyr-preset" ]]; then
248+
setup_script_args="--target-toolchain zephyr"
249+
toolchain_prefix=arm-zephyr-eabi-
250+
threshold="133120" # should be ~125KB, set threshold to 130KB
251+
toolchain_cmake=examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake
252+
else
253+
echo "Fail unsupport OS selection ${{ matrix.os }}"
254+
exit 1
255+
fi
256+
237257
source .ci/scripts/utils.sh
238258
install_executorch "--use-pt-pinned-commit"
239-
.ci/scripts/setup-arm-baremetal-tools.sh
259+
.ci/scripts/setup-arm-baremetal-tools.sh ${setup_script_args}
240260
source examples/arm/ethos-u-scratch/setup_path.sh
241261
242-
# User baremetal toolchain
243-
arm-none-eabi-c++ --version
244-
toolchain_cmake=examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
262+
# User toolchain
263+
${toolchain_prefix}c++ --version
264+
265+
# Setup cmake target to desired toolchain
245266
toolchain_cmake=$(realpath ${toolchain_cmake})
246267
247-
# Build and test size test
248-
bash test/build_size_test.sh "-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DEXECUTORCH_BUILD_ARM_BAREMETAL=ON"
268+
# Build and run size test
269+
if [[ ${{ matrix.os}} == "bare_metal" ]]; then
270+
bash test/build_size_test.sh "-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DEXECUTORCH_BUILD_ARM_BAREMETAL=ON"
271+
elif [[ ${{ matrix.os}} == "zephyr-preset" ]]; then
272+
CXXFLAGS=${cxx_flags} cmake --preset zephyr -DCMAKE_BUILD_TYPE=Release -DEXECUTORCH_OPTIMIZE_SIZE=ON -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out .
273+
cmake --build cmake-out -j9 --target install --config Release
274+
CXXFLAGS=${cxx_flags} cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake-out -Bcmake-out/test test
275+
cmake --build cmake-out/test -j9 --config Release
276+
else
277+
echo "Fail unsupport OS selection ${{ matrix.os }}"
278+
exit 1
279+
fi
280+
249281
elf="cmake-out/test/size_test"
250282
251283
# Dump basic info
252284
ls -al ${elf}
253-
arm-none-eabi-size ${elf}
285+
${toolchain_prefix}size ${elf}
254286
255-
# Dump symbols
287+
# Dump symbol
256288
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-"
289+
python .github/scripts/run_nm.py -e ${elf} -f "executorch" -p "${toolchain_prefix}"
290+
python .github/scripts/run_nm.py -e ${elf} -f "executorch_text" -p "${toolchain_prefix}"
259291
260292
# Add basic guard - TODO: refine this!
261-
arm-none-eabi-strip ${elf}
293+
${toolchain_prefix}strip ${elf}
262294
output=$(ls -la ${elf})
263295
arr=($output)
264296
size=${arr[4]}
265-
threshold="103268" # ~100KiB
266297
echo "size: $size, threshold: $threshold"
267298
if [[ "$size" -le "$threshold" ]]; then
268299
echo "Success $size <= $threshold"
@@ -271,6 +302,36 @@ jobs:
271302
exit 1
272303
fi
273304
305+
nxp-build-test:
306+
name: nxp-build-test
307+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
308+
permissions:
309+
id-token: write
310+
contents: read
311+
with:
312+
runner: linux.2xlarge
313+
docker-image: executorch-ubuntu-22.04-arm-sdk
314+
submodules: 'recursive'
315+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
316+
timeout: 90
317+
script: |
318+
# The generic Linux job chooses to use base env, not the one setup by the image
319+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
320+
conda activate "${CONDA_ENV}"
321+
322+
# Build
323+
cmake -DEXECUTORCH_BUILD_NXP_NEUTRON=ON -Bcmake-out .
324+
cmake --build cmake-out --target executorch_delegate_neutron --config Release
325+
326+
# Build check for the neutron backend library
327+
lib_neutron="cmake-out/backends/nxp/libexecutorch_delegate_neutron.a"
328+
if [ -f $lib_neutron ]; then
329+
echo "Neutron backend library built."
330+
else
331+
echo "Neutron backend library not found!"
332+
exit 1
333+
fi
334+
274335
test-coreml-delegate:
275336
name: test-coreml-delegate
276337
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
@@ -470,7 +531,7 @@ jobs:
470531
docker-image: executorch-ubuntu-22.04-qnn-sdk
471532
submodules: 'recursive'
472533
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
473-
timeout: 90
534+
timeout: 900
474535
script: |
475536
# The generic Linux job chooses to use base env, not the one setup by the image
476537
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
@@ -489,14 +550,14 @@ jobs:
489550
strategy:
490551
matrix:
491552
dtype: [fp32]
492-
model: [cvt, dit, efficientnet, focalnet, mobilevit_v1, mobilevit_v2, pvt, swin, albert, bert, distilbert, roberta] # eurobert requires transfomer >= 4.48.0, skip for now
553+
model: [albert, bert, distilbert] # eurobert requires transfomer >= 4.48.0, skip for now
493554
fail-fast: false
494555
with:
495556
runner: linux.2xlarge
496557
docker-image: executorch-ubuntu-22.04-qnn-sdk
497558
submodules: 'recursive'
498559
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
499-
timeout: 90
560+
timeout: 900
500561
script: |
501562
# The generic Linux job chooses to use base env, not the one setup by the image
502563
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,12 @@ install(
449449
FILES_MATCHING
450450
PATTERN "*.h"
451451
)
452+
install(
453+
DIRECTORY runtime/executor/
454+
DESTINATION include/executorch/runtime/executor
455+
FILES_MATCHING
456+
PATTERN "*.h"
457+
)
452458
install(
453459
DIRECTORY runtime/kernel/
454460
DESTINATION include/executorch/runtime/kernel
@@ -496,6 +502,10 @@ if(EXECUTORCH_BUILD_CADENCE)
496502
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/cadence)
497503
endif()
498504

505+
if(EXECUTORCH_BUILD_NXP_NEUTRON)
506+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/nxp)
507+
endif()
508+
499509
if(EXECUTORCH_BUILD_COREML)
500510
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/coreml)
501511
endif()
@@ -542,6 +552,12 @@ endif()
542552

543553
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
544554
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/module)
555+
install(
556+
DIRECTORY extension/module/
557+
DESTINATION include/executorch/extension/module
558+
FILES_MATCHING
559+
PATTERN "*.h"
560+
)
545561
endif()
546562

547563
if(EXECUTORCH_BUILD_EXTENSION_LLM)

CMakePresets.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@
104104
"Windows"
105105
]
106106
}
107+
},
108+
{
109+
"name": "zephyr",
110+
"displayName": "Build everything buildable on Zephyr RTOS",
111+
"inherits": [
112+
"common"
113+
],
114+
"cacheVariables": {
115+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/zephyr.cmake",
116+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/examples/zephyr/x86_64-linux-arm-zephyr-eabi-gcc.cmake"
117+
}
107118
}
108119
]
109120
}

backends/arm/_passes/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from .decompose_ne_pass import DecomposeNotEqualPass # noqa
4242
from .decompose_round_pass import DecomposeRoundPass # noqa
4343
from .decompose_select import DecomposeSelectPass # noqa
44+
from .decompose_sign_pass import DecomposeSignPass # noqa
4445
from .decompose_silu_pass import DecomposeSiluPass # noqa
4546
from .decompose_sinh_pass import DecomposeSinhPass # noqa
4647
from .decompose_softmax_pass import DecomposeSoftmaxPass # noqa

backends/arm/_passes/arm_pass_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
DecomposeNotEqualPass,
4545
DecomposeRoundPass,
4646
DecomposeSelectPass,
47+
DecomposeSignPass,
4748
DecomposeSiluPass,
4849
DecomposeSinhPass,
4950
DecomposeSoftmaxPass,
@@ -158,6 +159,7 @@ def _tosa_080_MI_pipeline(self, exported_program: ExportedProgram) -> GraphModul
158159
self.add_pass(ConvertIntPowToMuls())
159160
self.add_pass(CastBoolToInt8Pass())
160161
self.add_pass(DecomposeSinhPass())
162+
self.add_pass(DecomposeSignPass())
161163
self.add_pass(ReplaceScalarWithTensorArgPassTOSAMI())
162164
self.add_pass(DecomposeEmbeddingPass())
163165
self.add_pass(FuseQuantizedActivationPass())
@@ -242,6 +244,7 @@ def transform_for_annotation_pipeline(self, graph_module: GraphModule):
242244
self.add_pass(DecomposeScaledDotProductAttention())
243245
self.add_pass(DecomposeRoundPass())
244246
self.add_pass(CastBoolToInt8Pass())
247+
self.add_pass(DecomposeSignPass())
245248
self.add_pass(ReplaceScalarWithTensorArgPassTOSABI())
246249
self.add_pass(ScalarsToAttributePass())
247250
self.add_pass(DecomposeGroupNormPass())

backends/arm/_passes/decompose_linear_pass.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def call(self, graph_module):
8888
op_target=exir_ops.edge.aten.view_copy.default,
8989
args=(conv, list(output_shape)),
9090
kwargs={},
91+
from_node=node,
9192
)
9293

9394
node.replace_all_uses_with(output)

0 commit comments

Comments
 (0)