Skip to content

Commit 7b27f9b

Browse files
authored
Back out "Back out "[executorch][PR] Add stories ci for qnn""
Summary: Pull Request resolved: #4689 Original commit changeset: 4e0ee9cac90b Original Phabricator Diff: D61192484 Reviewed By: larryliu0820, kirklandsign Differential Revision: D61214261
1 parent 5d151d0 commit 7b27f9b

File tree

6 files changed

+110
-3
lines changed

6 files changed

+110
-3
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 -ex
9+
10+
build_qnn_backend() {
11+
echo "Start building qnn backend."
12+
export ANDROID_NDK_ROOT=/opt/ndk
13+
export QNN_SDK_ROOT=/tmp/qnn/2.23.0.240531
14+
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
15+
16+
bash backends/qualcomm/scripts/build.sh --skip_aarch64 --job_number 2 --release
17+
}
18+
19+
build_qnn_backend

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 -ex
9+
10+
install_qnn() {
11+
echo "Start installing qnn."
12+
QNN_INSTALLATION_DIR=/tmp/qnn
13+
mkdir -p "${QNN_INSTALLATION_DIR}"
14+
15+
curl -Lo /tmp/v2.23.0.24.06.24.zip "https://softwarecenter.qualcomm.com/api/download/software/qualcomm_neural_processing_sdk/v2.23.0.24.06.24.zip"
16+
echo "Finishing downloading qnn sdk."
17+
unzip -qo /tmp/v2.23.0.24.06.24.zip -d /tmp
18+
echo "Finishing unzip qnn sdk."
19+
20+
21+
# Print the content for manual verification
22+
ls -lah "/tmp/qairt"
23+
mv "/tmp/qairt"/* "${QNN_INSTALLATION_DIR}"
24+
echo "Finishing installing qnn '${QNN_INSTALLATION_DIR}' ."
25+
26+
ls -lah "${QNN_INSTALLATION_DIR}"
27+
}
28+
29+
install_qnn

.ci/scripts/test_llama.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ fi
7272

7373
echo "COREML option ${COREML}"
7474

75+
if [[ "${MODE}" =~ .*qnn.* ]]; then
76+
QNN=ON
77+
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
78+
export QNN_SDK_ROOT=/tmp/qnn/2.23.0.240531
79+
export LD_LIBRARY_PATH="${QNN_SDK_ROOT}/lib/x86_64-linux-clang"
80+
export PYTHONPATH=".."
81+
cp schema/program.fbs exir/_serialize/program.fbs
82+
cp schema/scalar_type.fbs exir/_serialize/scalar_type.fbs
83+
cp -f build-x86/backends/qualcomm/PyQnnManagerAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python
84+
cp -f build-x86/backends/qualcomm/PyQnnWrapperAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python
85+
86+
else
87+
QNN=OFF
88+
QNN_SDK_ROOT=""
89+
fi
90+
91+
echo "QNN option ${QNN}"
92+
echo "QNN_SDK_ROOT: ${QNN_SDK_ROOT}"
93+
7594
if [[ -z "${BUCK:-}" ]]; then
7695
BUCK=buck2
7796
fi
@@ -96,6 +115,8 @@ cmake_install_executorch_libraries() {
96115
-DEXECUTORCH_BUILD_XNNPACK="$XNNPACK" \
97116
-DEXECUTORCH_BUILD_MPS="$MPS" \
98117
-DEXECUTORCH_BUILD_COREML="$COREML" \
118+
-DEXECUTORCH_BUILD_QNN="$QNN" \
119+
-DQNN_SDK_ROOT="$QNN_SDK_ROOT" \
99120
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
100121
-Bcmake-out .
101122
cmake --build cmake-out -j9 --target install --config Debug
@@ -176,6 +197,9 @@ fi
176197
if [[ "${COREML}" == "ON" ]]; then
177198
EXPORT_ARGS="${EXPORT_ARGS} -kv -v --coreml --disable_dynamic_shape"
178199
fi
200+
if [[ "${QNN}" == "ON" ]]; then
201+
EXPORT_ARGS="${EXPORT_ARGS} -kv -v --qnn --disable_dynamic_shape"
202+
fi
179203
# Add dynamically linked library location
180204
$PYTHON_EXECUTABLE -m examples.models.llama2.export_llama ${EXPORT_ARGS}
181205

.github/workflows/pull.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,3 +369,38 @@ jobs:
369369
370370
# Run pytest with coverage
371371
pytest -c /dev/null -v -n auto --cov=./ --cov-report=xml backends/arm/test
372+
373+
374+
test-llama-runner-qnn-linux:
375+
name: test-llama-runner-qnn-linux
376+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
377+
strategy:
378+
matrix:
379+
dtype: [fp32]
380+
build-tool: [cmake]
381+
mode: [qnn]
382+
fail-fast: false
383+
with:
384+
runner: linux.2xlarge
385+
docker-image: executorch-ubuntu-22.04-clang12-android
386+
submodules: 'true'
387+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
388+
timeout: 900
389+
script: |
390+
# The generic Linux job chooses to use base env, not the one setup by the image
391+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
392+
conda activate "${CONDA_ENV}"
393+
394+
DTYPE=${{ matrix.dtype }}
395+
BUILD_TOOL=${{ matrix.build-tool }}
396+
MODE=${{ matrix.mode }}
397+
398+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
399+
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
400+
401+
# Setup executorch
402+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh buck2
403+
# Install requirements for export_llama
404+
PYTHON_EXECUTABLE=python bash examples/models/llama2/install_requirements.sh
405+
# Test llama2
406+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M.pt "${BUILD_TOOL}" "${DTYPE}" "${MODE}"

backends/qualcomm/aot/python/PyQnnWrapperAdaptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class PyQnnOpWrapper {
8686
break;
8787
default:
8888
QNN_EXECUTORCH_LOG_ERROR(
89-
"%s has invalid data type: %d", name, data_type);
89+
"%s has invalid data type: %d", name.c_str(), data_type);
9090
break;
9191
}
9292
}

backends/qualcomm/scripts/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ usage() {
2525
[ "$1" = -h ] && usage
2626

2727
BUILD_X86_64="true"
28-
CMAKE_X86_64="cmake-out"
28+
CMAKE_X86_64="build-x86"
2929
BUILD_AARCH64="true"
30-
CMAKE_AARCH64="cmake-out-android"
30+
CMAKE_AARCH64="build-android"
3131
CLEAN="true"
3232
BUILD_TYPE="Debug"
3333
BUILD_JOB_NUMBER="16"

0 commit comments

Comments
 (0)