Skip to content

Commit 7e74895

Browse files
committed
add MTK ci
1 parent d679ad7 commit 7e74895

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

.ci/scripts/build-mediatek-sdk.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -eux
9+
10+
build_neuron_backend() {
11+
echo "Start building neuron backend."
12+
export ANDROID_NDK=/opt/ndk
13+
export MEDIATEK_SDK_ROOT=/tmp/neuropilot
14+
export NEURON_BUFFER_ALLOCATOR_LIB=${MEDIATEK_SDK_ROOT}/libneuron_buffer_allocator.so
15+
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
16+
17+
18+
cd ${EXECUTORCH_ROOT}
19+
./backends/mediatek/scripts/mtk_build.sh
20+
}
21+
22+
build_neuron_backend

.ci/scripts/setup-mediatek-deps.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree.
7+
8+
set -eux
9+
10+
MEDIATEK_INSTALLATION_DIR=/tmp/neuropilot
11+
EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
12+
13+
install_neuropilot() {
14+
echo "Start installing neuropilot."
15+
mkdir -p "${MEDIATEK_INSTALLATION_DIR}"
16+
17+
# curl -Lo /tmp/neuropilot-express-sdk-8.0.4-build20241016.tar.gz "https://s3.ap-southeast-1.amazonaws.com/mediatek.neuropilot.com/8c1ff4e4-4256-47ed-9e24-67818b4cc4b9.gz"
18+
echo "Finishing downloading neuropilot sdk."
19+
tar zxvf /tmp/neuropilot-express-sdk-8.0.4-build20241016.tar.gz --strip-components=1 --directory "${MEDIATEK_INSTALLATION_DIR}"
20+
echo "Finishing unzip neuropilot sdk."
21+
22+
# Print the content for manual verification
23+
ls -lah "${MEDIATEK_INSTALLATION_DIR}"
24+
}
25+
26+
setup_neuropilot() {
27+
pip3 install -r ${EXECUTORCH_ROOT}/backends/mediatek/requirements.txt
28+
pip3 install ${MEDIATEK_INSTALLATION_DIR}/mtk_neuron-8.2.13-py3-none-linux_x86_64.whl
29+
pip3 install ${MEDIATEK_INSTALLATION_DIR}/mtk_converter-8.9.1_public_packages/mtk_converter-8.9.1+public-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
30+
}
31+
32+
install_neuropilot
33+
setup_neuropilot

.ci/scripts/test_model.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,24 @@ test_model_with_mps() {
206206
EXPORTED_MODEL=$(find "." -type f -name "${MODEL_NAME}*.pte" -print -quit)
207207
}
208208

209+
test_model_with_mediatek() {
210+
if [[ "${MODEL_NAME}" == "dl3" ]]; then
211+
EXPORT_SCRIPT=deeplab_v3
212+
elif [[ "${MODEL_NAME}" == "mv3" ]]; then
213+
EXPORT_SCRIPT=mobilenet_v3
214+
elif [[ "${MODEL_NAME}" == "mv2" ]]; then
215+
EXPORT_SCRIPT=mobilenet_v2
216+
elif [[ "${MODEL_NAME}" == "ic4" ]]; then
217+
EXPORT_SCRIPT=inception_v4
218+
elif [[ "${MODEL_NAME}" == "ic3" ]]; then
219+
EXPORT_SCRIPT=inception_v3
220+
fi
221+
222+
"${PYTHON_EXECUTABLE}" -m examples.mediatek.model_export_scripts.${EXPORT_SCRIPT} -d /tmp/tiny_imagenet -a ${EXPORT_SCRIPT}
223+
EXPORTED_MODEL=$(find "./${EXPORT_SCRIPT}" -type f -name "*.pte" -print -quit)
224+
}
225+
226+
209227
if [[ "${BACKEND}" == "portable" ]]; then
210228
echo "Testing ${MODEL_NAME} with portable kernels..."
211229
test_model
@@ -239,6 +257,12 @@ elif [[ "${BACKEND}" == "xnnpack" ]]; then
239257
if [[ $? -eq 0 ]]; then
240258
prepare_artifacts_upload
241259
fi
260+
elif [[ "${BACKEND}" == "mediatek" ]]; then
261+
echo "Testing ${MODEL_NAME} with mediatek..."
262+
test_model_with_mediatek
263+
if [[ $? -eq 0 ]]; then
264+
prepare_artifacts_upload
265+
fi
242266
else
243267
set +e
244268
if [[ "${BACKEND}" == *"quantization"* ]]; then

0 commit comments

Comments
 (0)