Skip to content

Commit 8cd3afd

Browse files
authored
Qualcomm AI Engine Direct - Support QNN 2.28
Differential Revision: D65949627 Pull Request resolved: #6811
1 parent 44d223d commit 8cd3afd

File tree

8 files changed

+47
-19
lines changed

8 files changed

+47
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -o xtrace
1111
build_qnn_backend() {
1212
echo "Start building qnn backend."
1313
export ANDROID_NDK_ROOT=/opt/ndk
14-
export QNN_SDK_ROOT=/tmp/qnn/2.25.0.240728
14+
export QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029
1515
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
1616

1717
bash backends/qualcomm/scripts/build.sh --skip_aarch64 --job_number 2 --release

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ install_qnn() {
1616
QNN_INSTALLATION_DIR=/tmp/qnn
1717
mkdir -p "${QNN_INSTALLATION_DIR}"
1818

19-
curl -Lo /tmp/v2.25.0.24.07.28.zip "https://softwarecenter.qualcomm.com/api/download/software/qualcomm_neural_processing_sdk/v2.25.0.240728.zip"
19+
curl -Lo /tmp/v2.28.0.24.10.29.zip "https://softwarecenter.qualcomm.com/api/download/software/qualcomm_neural_processing_sdk/v2.28.0.241029.zip"
2020
echo "Finishing downloading qnn sdk."
21-
unzip -qo /tmp/v2.25.0.24.07.28.zip -d /tmp
21+
unzip -qo /tmp/v2.28.0.24.10.29.zip -d /tmp
2222
echo "Finishing unzip qnn sdk."
2323

2424

.ci/scripts/test_llama.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ echo "COREML option ${COREML}"
121121
if [[ "${MODE}" =~ .*qnn.* ]]; then
122122
QNN=ON
123123
export EXECUTORCH_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
124-
export QNN_SDK_ROOT=/tmp/qnn/2.25.0.240728
124+
export QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029
125125
export LD_LIBRARY_PATH="${QNN_SDK_ROOT}/lib/x86_64-linux-clang"
126126
export PYTHONPATH=".."
127127
cp schema/program.fbs exir/_serialize/program.fbs

backends/qualcomm/runtime/backends/QnnBackendCache.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ Error QnnBackendCache::GetQnnGraphInfoFromBinary(
5151
} else if (binaryinfo->version == QNN_SYSTEM_CONTEXT_BINARY_INFO_VERSION_2) {
5252
num_graphs = binaryinfo->contextBinaryInfoV2.numGraphs;
5353
graphs = binaryinfo->contextBinaryInfoV2.graphs;
54+
#if (QNN_API_VERSION_MAJOR >= 2 && QNN_API_VERSION_MINOR >= 21)
55+
} else if (binaryinfo->version == QNN_SYSTEM_CONTEXT_BINARY_INFO_VERSION_3) {
56+
num_graphs = binaryinfo->contextBinaryInfoV3.numGraphs;
57+
graphs = binaryinfo->contextBinaryInfoV3.graphs;
58+
#endif
5459
} else {
5560
QNN_EXECUTORCH_LOG_WARN(
5661
"Unknown QNN BinaryInfo version %d.", binaryinfo->version);
@@ -62,6 +67,10 @@ Error QnnBackendCache::GetQnnGraphInfoFromBinary(
6267
RetrieveGraphInfo<QnnSystemContext_GraphInfoV1_t>(graphs[i].graphInfoV1);
6368
} else if (graphs->version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_2) {
6469
RetrieveGraphInfo<QnnSystemContext_GraphInfoV2_t>(graphs[i].graphInfoV2);
70+
#if (QNN_API_VERSION_MAJOR >= 2 && QNN_API_VERSION_MINOR >= 21)
71+
} else if (graphs->version == QNN_SYSTEM_CONTEXT_GRAPH_INFO_VERSION_3) {
72+
RetrieveGraphInfo<QnnSystemContext_GraphInfoV3_t>(graphs[i].graphInfoV3);
73+
#endif
6574
} else {
6675
QNN_EXECUTORCH_LOG_WARN(
6776
"Unknown QNN GraphInfo version %d.", binaryinfo->version);

backends/qualcomm/runtime/backends/htpbackend/HtpBackendCache.cpp

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,53 @@ using executorch::runtime::Error;
1717
Error HtpBackendCache::RetrieveBackendBinaryInfo(
1818
const QnnSystemContext_BinaryInfo_t* binaryinfo) {
1919
QnnHtpSystemContext_HwBlobInfo_t* htp_hwblobinfo = nullptr;
20+
#if (QNN_API_VERSION_MAJOR >= 2 && QNN_API_VERSION_MINOR >= 21)
21+
QnnHtpSystemContext_GraphBlobInfo_t* htp_graphblobinfo = nullptr;
22+
#endif
2023

2124
if (binaryinfo->version == QNN_SYSTEM_CONTEXT_BINARY_INFO_VERSION_1) {
2225
htp_hwblobinfo = static_cast<QnnHtpSystemContext_HwBlobInfo_t*>(
2326
binaryinfo->contextBinaryInfoV1.hwInfoBlob);
2427
} else if (binaryinfo->version == QNN_SYSTEM_CONTEXT_BINARY_INFO_VERSION_2) {
2528
htp_hwblobinfo = static_cast<QnnHtpSystemContext_HwBlobInfo_t*>(
2629
binaryinfo->contextBinaryInfoV2.hwInfoBlob);
30+
#if (QNN_API_VERSION_MAJOR >= 2 && QNN_API_VERSION_MINOR >= 21)
31+
} else if (binaryinfo->version == QNN_SYSTEM_CONTEXT_BINARY_INFO_VERSION_3) {
32+
htp_graphblobinfo = static_cast<QnnHtpSystemContext_GraphBlobInfo_t*>(
33+
binaryinfo->contextBinaryInfoV3.graphs->graphInfoV3.graphBlobInfo);
34+
#endif
2735
} else {
2836
QNN_EXECUTORCH_LOG_WARN(
2937
"Unknown QNN BinaryInfo version %d.", binaryinfo->version);
3038
return Error::Internal;
3139
}
3240

33-
if (htp_hwblobinfo == nullptr) {
34-
QNN_EXECUTORCH_LOG_WARN(
35-
"Htp hardware blob information is not found in binary information.");
36-
return Error::Ok;
41+
if (htp_hwblobinfo) {
42+
if (htp_hwblobinfo->version ==
43+
QNN_SYSTEM_CONTEXT_HTP_HW_INFO_BLOB_VERSION_V1) {
44+
spill_fill_buf_ =
45+
(*htp_hwblobinfo).contextBinaryHwInfoBlobV1_t.spillFillBufferSize;
46+
} else {
47+
QNN_EXECUTORCH_LOG_WARN(
48+
"Unknown QNN Htp hw blob info version %d.", htp_hwblobinfo->version);
49+
return Error::Internal;
50+
}
3751
}
3852

39-
if (htp_hwblobinfo->version ==
40-
QNN_SYSTEM_CONTEXT_HTP_HW_INFO_BLOB_VERSION_V1) {
41-
spill_fill_buf_ =
42-
(*htp_hwblobinfo).contextBinaryHwInfoBlobV1_t.spillFillBufferSize;
43-
} else {
44-
QNN_EXECUTORCH_LOG_WARN(
45-
"Unknown QNN Htp hw blob info version %d.", htp_hwblobinfo->version);
46-
return Error::Internal;
53+
#if (QNN_API_VERSION_MAJOR >= 2 && QNN_API_VERSION_MINOR >= 21)
54+
if (htp_graphblobinfo) {
55+
if (htp_graphblobinfo->version ==
56+
QNN_SYSTEM_CONTEXT_HTP_GRAPH_INFO_BLOB_VERSION_V1) {
57+
spill_fill_buf_ =
58+
(*htp_graphblobinfo).contextBinaryGraphBlobInfoV1.spillFillBufferSize;
59+
} else {
60+
QNN_EXECUTORCH_LOG_WARN(
61+
"Unknown QNN Htp graph blob info version %d.",
62+
htp_graphblobinfo->version);
63+
return Error::Internal;
64+
}
4765
}
66+
#endif
4867

4968
return Error::Ok;
5069
}

docs/source/build-run-qualcomm-ai-engine-direct-backend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ This example is verified with SM8550 and SM8450.
5959
- Click the "Get Software" button to download a version of QNN SDK.
6060
- However, at the moment of updating this tutorial, the above website doesn't provide QNN SDK newer than 2.22.6.
6161
- The below is public links to download various QNN versions. Hope they can be publicly discoverable soon.
62-
- [QNN 2.26.0](https://softwarecenter.qualcomm.com/api/download/software/qualcomm_neural_processing_sdk/v2.26.0.240828.zip)
62+
- [QNN 2.28.0](https://softwarecenter.qualcomm.com/api/download/software/qualcomm_neural_processing_sdk/v2.28.0.241029.zip)
6363

6464
The directory with installed Qualcomm AI Engine Direct SDK looks like:
6565
```

docs/source/llm/build-run-llama3-qualcomm-ai-engine-direct-backend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This tutorial demonstrates how to export Llama 3 8B Instruct for Qualcomm AI Eng
99
- Follow [the README for executorch llama](https://github.com/pytorch/executorch/tree/main/examples/models/llama) to know how to run a llama model on mobile via ExecuTorch.
1010
- A Qualcomm device with 16GB RAM
1111
- We are continuing to optimize our memory usage to ensure compatibility with lower memory devices.
12-
- The version of [Qualcomm AI Engine Direct SDK](https://developer.qualcomm.com/software/qualcomm-ai-engine-direct-sdk) is 2.26.0 or above.
12+
- The version of [Qualcomm AI Engine Direct SDK](https://developer.qualcomm.com/software/qualcomm-ai-engine-direct-sdk) is 2.28.0 or above.
1313

1414
## Instructions
1515

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def get_qnn_library_verision():
2-
return "2.26"
2+
return "2.28"

0 commit comments

Comments
 (0)