Skip to content

Commit cbb1cb2

Browse files
committed
Merge remote-tracking branch 'github/main' into add_ootb_test_m1
Change-Id: I6ad23cd0e0877f5da8bdb0120b3967fc29a36a02
2 parents 77166dd + d43cde5 commit cbb1cb2

File tree

1,479 files changed

+78007
-19809
lines changed

Some content is hidden

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

1,479 files changed

+78007
-19809
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e7152ff8a6a929a0db7f3f4a72a5b6d471769cd3
1+
4d4abec80f03cd8fdefe1d9cb3a60d3690cd777e

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ set -o xtrace
1111

1212
build_qnn_backend() {
1313
echo "Start building qnn backend."
14-
export ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-/opt/ndk}
15-
export QNN_SDK_ROOT=${QNN_SDK_ROOT:-/tmp/qnn/2.28.0.241029}
14+
# Source QNN configuration
15+
source "$(dirname "${BASH_SOURCE[0]}")/../../backends/qualcomm/scripts/install_qnn_sdk.sh"
16+
setup_android_ndk
17+
install_qnn
1618
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
1719

1820
parallelism=$(( $(nproc) - 1 ))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ set -ex
1010
source "$(dirname "${BASH_SOURCE[0]}")/../../backends/qualcomm/scripts/install_qnn_sdk.sh"
1111

1212
setup_libcpp 12
13-
install_qnn
13+
setup_android_ndk
14+
install_qnn
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# Copyright (c) Samsung Electronics Co. LTD
4+
# All rights reserved.
5+
#
6+
# This source code is licensed under the BSD-style license found in the
7+
# LICENSE file in the root directory of this source tree.
8+
9+
set -ex
10+
11+
12+
download_ai_lite_core() {
13+
API_BASE="https://soc-developer.semiconductor.samsung.com/api/v1/resource/ai-litecore/download"
14+
API_KEY="kn10SoSY3hkC-9Qny5TqD2mnqVrlupv3krnjLeBt5cY"
15+
16+
VERSION="0.5"
17+
OS_NAME="Ubuntu 22.04"
18+
OUT_FILE="/tmp/exynos-ai-litecore-v${VERSION}.tar.gz"
19+
TARGET_PATH="/tmp/exynos_ai_lite_core"
20+
21+
mkdir -p ${TARGET_PATH}
22+
# Presigned issue URL
23+
JSON_RESP=$(curl -sS -G \
24+
--location --fail --retry 3 \
25+
-H "apikey: ${API_KEY}" \
26+
--data-urlencode "version=${VERSION}" \
27+
--data-urlencode "os=${OS_NAME}" \
28+
"${API_BASE}")
29+
30+
DOWNLOAD_URL=$(echo "$JSON_RESP" | sed -n 's/.*"data":[[:space:]]*"\([^"]*\)".*/\1/p')
31+
32+
if [[ -z "$DOWNLOAD_URL" ]]; then
33+
echo "Failed to extract download URL"
34+
echo "$JSON_RESP"
35+
exit 1
36+
fi
37+
38+
# Download LiteCore
39+
curl -sS -L --fail --retry 3 \
40+
--output "$OUT_FILE" \
41+
"$DOWNLOAD_URL"
42+
43+
echo "Download done: $OUT_FILE"
44+
45+
46+
tar -C "${TARGET_PATH}" --strip-components=1 -xzvf "${OUT_FILE}"
47+
48+
export EXYNOS_AI_LITECORE_ROOT=${TARGET_PATH}
49+
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:${EXYNOS_AI_LITECORE_ROOT}/lib/x86_64-linux
50+
}
51+
52+
install_enn_backend() {
53+
NDK_INSTALLATION_DIR=/opt/ndk
54+
rm -rf "${NDK_INSTALLATION_DIR}" && sudo mkdir -p "${NDK_INSTALLATION_DIR}"
55+
ANDROID_NDK_VERSION=r27b
56+
57+
# build Exynos backend
58+
export ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-/opt/ndk}
59+
bash backends/samsung/build.sh --build all
60+
# set env variable
61+
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
62+
export PYTHONPATH=${PYTHONPATH:-}:${EXECUTORCH_ROOT}/..
63+
}
64+
65+
AI_LITE_CORE_VERSION=0.5.0
66+
67+
download_ai_lite_core ${AI_LITE_CORE_VERSION}
68+
install_enn_backend

.ci/scripts/setup-windows.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
param (
2+
[string]$editable = "false"
3+
)
4+
5+
conda create --yes --quiet -n et python=3.12
6+
conda activate et
7+
8+
# Activate the VS environment - this is required for Dynamo to work, as it uses MSVC.
9+
# There are a bunch of environment variables that it requires.
10+
# See https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line.
11+
& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64
12+
13+
# Install test dependencies
14+
pip install -r .ci/docker/requirements-ci.txt
15+
16+
if ($editable -eq 'true') {
17+
install_executorch.bat --editable
18+
} else {
19+
install_executorch.bat
20+
}
21+
if ($LASTEXITCODE -ne 0) {
22+
Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE."
23+
exit $LASTEXITCODE
24+
}

.ci/scripts/test_backend_linux.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,26 @@ if [[ "$FLOW" == *qnn* ]]; then
3030
# Qualcomm build. TODO (gjcomer) Clean this up once the QNN pybinding integration is
3131
# cleaned up.
3232
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool cmake
33-
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
34-
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
33+
PYTHON_EXECUTABLE=python source .ci/scripts/build-qnn-sdk.sh
3534
QNN_X86_LIB_DIR=`realpath build-x86/lib/`
36-
QNN_SDK_ROOT="/tmp/qnn/2.28.0.241029"
3735
export LD_LIBRARY_PATH"=$QNN_X86_LIB_DIR:$QNN_SDK_ROOT/lib/x86_64-linux-clang/:${LD_LIBRARY_PATH:-}"
3836

3937
# TODO Get SDK root from install scripts
4038
EXTRA_BUILD_ARGS+=" -DEXECUTORCH_BUILD_QNN=ON -DQNN_SDK_ROOT=$QNN_SDK_ROOT"
4139
fi
4240

4341
if [[ "$FLOW" == *vulkan* ]]; then
44-
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate
42+
# Setup swiftshader and Vulkan SDK which are required to build the Vulkan delegate.
4543
source .ci/scripts/setup-vulkan-linux-deps.sh
4644

4745
EXTRA_BUILD_ARGS+=" -DEXECUTORCH_BUILD_VULKAN=ON"
4846
fi
4947

48+
if [[ "$FLOW" == *arm* ]]; then
49+
# Setup ARM deps.
50+
.ci/scripts/setup-arm-baremetal-tools.sh
51+
fi
52+
5053
# We need the runner to test the built library.
5154
PYTHON_EXECUTABLE=python CMAKE_ARGS="$EXTRA_BUILD_ARGS" .ci/scripts/setup-linux.sh --build-tool cmake --build-mode Release --editable true
5255

.ci/scripts/test_llama.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ echo "COREML option ${COREML}"
119119

120120
if [[ "${MODE}" =~ .*qnn.* ]]; then
121121
QNN=ON
122+
123+
# Download QNN_SDK. If already downloaded, export environment path
124+
source "$(dirname "${BASH_SOURCE[0]}")/../../backends/qualcomm/scripts/install_qnn_sdk.sh"
125+
install_qnn
126+
122127
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
123-
export QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029
124128
export LD_LIBRARY_PATH="${QNN_SDK_ROOT}/lib/x86_64-linux-clang"
125129
export PYTHONPATH=".."
126130
cp schema/program.fbs exir/_serialize/program.fbs
@@ -150,6 +154,7 @@ cmake_install_executorch_libraries() {
150154
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
151155
rm -rf cmake-out
152156
retry cmake --preset llm \
157+
-DEXECUTORCH_BUILD_TESTS=ON \
153158
-DBUILD_TESTING=OFF \
154159
-DCMAKE_INSTALL_PREFIX=cmake-out \
155160
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
@@ -166,6 +171,7 @@ cmake_build_llama_runner() {
166171
popd
167172
dir="examples/models/llama"
168173
retry cmake \
174+
-DEXECUTORCH_BUILD_TESTS=ON \
169175
-DBUILD_TESTING=OFF \
170176
-DCMAKE_INSTALL_PREFIX=cmake-out \
171177
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \

.ci/scripts/test_llava.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ run_and_verify() {
149149

150150
# verify result.txt
151151
RESULT=$(cat result.txt)
152-
EXPECTED_PREFIX="ASSISTANT: image captures a basketball game in progress, with"
152+
EXPECTED_PREFIX="ASSISTANT: The image captures a basketball game in progress, with"
153153

154154
if [[ "${RESULT}" == *"${EXPECTED_PREFIX}"* ]]; then
155155
echo "Expected result prefix: ${EXPECTED_PREFIX}"

.ci/scripts/test_model.ps1

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
param (
2+
[string]$modelName,
3+
[string]$backend,
4+
[string]$buildDir = "cmake-out",
5+
[bool]$strict = $false
6+
)
7+
8+
Set-PSDebug -Trace 1
9+
$ErrorActionPreference = 'Stop'
10+
$PSNativeCommandUseErrorActionPreference = $true
11+
12+
function ExportModel-Portable {
13+
param (
14+
[string]$model_name,
15+
[bool]$strict
16+
)
17+
18+
$exportParams = "--model_name", "$modelName"
19+
if ($strict) {
20+
$exportParams += "--strict"
21+
}
22+
python -m examples.portable.scripts.export @exportParams | Write-Host
23+
if ($LASTEXITCODE -ne 0) {
24+
Write-Host "Model export failed. Exit code: $LASTEXITCODE."
25+
exit $LASTEXITCODE
26+
}
27+
28+
"$modelName.pte"
29+
}
30+
31+
function ExportModel-Xnnpack {
32+
param (
33+
[string]$model_name,
34+
[bool]$quantize
35+
)
36+
37+
if ($quantize) {
38+
python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate --quantize | Write-Host
39+
$modelFile = "$($modelName)_xnnpack_q8.pte"
40+
} else {
41+
python -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate | Write-Host
42+
$modelFile = "$($modelName)_xnnpack_fp32.pte"
43+
}
44+
if ($LASTEXITCODE -ne 0) {
45+
Write-Host "Model export failed. Exit code: $LASTEXITCODE."
46+
exit $LASTEXITCODE
47+
}
48+
49+
$modelFile
50+
}
51+
52+
# Build the runner
53+
if (Test-Path -Path $buildDir) {
54+
Remove-Item -Path $buildDir -Recurse -Force
55+
}
56+
New-Item -Path $buildDir -ItemType Directory
57+
Push-Location $buildDir
58+
cmake .. --preset windows
59+
cmake --build . -t executor_runner -j16 --config Release
60+
if ($LASTEXITCODE -ne 0) {
61+
Write-Host "Runner build failed. Exit code: $LASTEXITCODE."
62+
exit $LASTEXITCODE
63+
}
64+
$executorBinaryPath = Join-Path -Path $buildDir -ChildPath "Release\executor_runner.exe"
65+
Pop-Location
66+
67+
# Export the model
68+
switch ($backend) {
69+
"portable" {
70+
$model_path = ExportModel-Portable -model_name $modelName -strict $strict
71+
}
72+
"xnnpack-f32" {
73+
$model_path = ExportModel-Xnnpack -model_name $modelName -quantize $false
74+
}
75+
"xnnpack-q8" {
76+
$model_path = ExportModel-Xnnpack -model_name $modelName -quantize $true
77+
}
78+
default {
79+
Write-Host "Unknown backend $backend."
80+
exit 1
81+
}
82+
}
83+
84+
# Run the runner
85+
& "$executorBinaryPath" --model_path="$model_path"
86+
if ($LASTEXITCODE -ne 0) {
87+
Write-Host "Model execution failed. Exit code: $LASTEXITCODE."
88+
exit $LASTEXITCODE
89+
}

.ci/scripts/test_model.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ test_model() {
9797
bash examples/models/llava/install_requirements.sh
9898
STRICT="--no-strict"
9999
fi
100-
if [[ "${MODEL_NAME}" == "qwen2_5" ]]; then
100+
if [[ "${MODEL_NAME}" == "qwen2_5_1_5b" ]]; then
101101
# Install requirements for export_llama
102102
bash examples/models/llama/install_requirements.sh
103103
# Test export_llm script: python3 -m extension.llm.export.export_llm.

0 commit comments

Comments
 (0)