Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou.weiguo committed Apr 26, 2024
1 parent 3a46ac3 commit 67beeb6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 4 additions & 2 deletions llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15402,8 +15402,10 @@ struct llama_context * llama_new_context_with_model(
}
#elif defined(GGML_USE_QNN)
if (model->n_gpu_layers > 0) {
//the second param is package name of Andorid app, can be got by JNI from Java layer
ggml_backend_t backend = ggml_backend_qnn_init(model->main_gpu, "/data/data/com.ggml.llamacpp/");
//the second param is data path of prebuit QNN libs provided by Qualcomm
//in Andorid APP mode, can be obtained through JNI from Java layer
//in Andorid terminal mode, can be hardcoded to "/data/local/tmp"
ggml_backend_t backend = ggml_backend_qnn_init(model->main_gpu, "/data/local/tmp/");
if (nullptr == backend) {
LLAMA_LOG_ERROR("%s: failed to initialize QNN backend\n", __func__);
llama_free(ctx);
Expand Down
5 changes: 4 additions & 1 deletion tests/ggml-qnn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
cmake_minimum_required(VERSION 3.22.1)
project(ggml-qnn)
project(ggml-qnn-test)

set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

#set to ON if target Android phone is based on Qualcomm Snapdragon 8 Gen 3
set(TARGET_SNAPDRAGON_8_GEN3 OFF)

set(LLAMACPP_SRC_PATH ${PROJECT_ROOT_PATH})
Expand Down Expand Up @@ -37,8 +38,10 @@ message("target name : ${TARGET_NAME}")
add_definitions(-D__ARM_NEON)
add_definitions(-DGGML_USE_QNN)

if(CMAKE_BUILD_TYPE STREQUAL "release")
add_definitions(-DNDEBUG)
add_definitions(-O3)
endif()

if (TARGET_SNAPDRAGON_8_GEN3)
# the below build optimization only works well on Qualcomm SM8650-AB Snapdragon 8 Gen 3
Expand Down
7 changes: 5 additions & 2 deletions tests/ggml-qnn/build-ggml-qnn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ QNN_SDK_PATH=/opt/qcom/aistack/qnn/2.20.0.240223/


ANDROID_NDK=`pwd`/android-ndk-r26c
ANDROID_PLATFORM=android-34
#BUILD_TYPE=release
BUILD_TYPE=debug
TARGET=ggml-qnn-test


function dump_vars()
{
echo -e "PROJECT_ROOT_PATH: ${PROJECT_ROOT_PATH}"
echo -e "LLAMACPP_ROOT_PATH: ${LLAMACPP_ROOT_PATH}"
echo -e "ANDROID_NDK: ${ANDROID_NDK}"
echo -e "QNN_SDK_PATH: ${QNN_SDK_PATH}"
}
Expand Down Expand Up @@ -61,7 +64,7 @@ function check_and_download_ndk()

function build_arm64
{
cmake -H. -B./out/arm64-v8a -DPROJECT_ROOT_PATH=${LLAMACPP_ROOT_PATH} -DTARGET_NAME=${TARGET} -DCMAKE_BUILD_TYPE=${PROJECT_BUILD_TYPE} -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DANDROID_NDK=${ANDROID_NDK} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake -DQNN_SDK_PATH=${QNN_SDK_PATH}
cmake -H. -B./out/arm64-v8a -DPROJECT_ROOT_PATH=${LLAMACPP_ROOT_PATH} -DTARGET_NAME=${TARGET} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DANDROID_NDK=${ANDROID_NDK} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake -DQNN_SDK_PATH=${QNN_SDK_PATH}

cd ./out/arm64-v8a
make
Expand Down
6 changes: 4 additions & 2 deletions tests/ggml-qnn/run-ggml-qnn.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

#modify following lines to adapt to local dev envs
#modify following line to adapt to local dev envs
#https://qpm.qualcomm.com/#/main/tools/details/qualcomm_ai_engine_direct
#https://developer.qualcomm.com/software/hexagon-dsp-sdk/tools
QNN_SDK_PATH=/opt/qcom/aistack/qnn/2.20.0.240223/

GGML_QNN_TEST=ggml-qnn-test
Expand All @@ -10,7 +12,7 @@ adb push ${GGML_QNN_TEST} ${REMOTE_PATH}

adb shell ls ${REMOTE_PATH}/libQnnCpu.so
if [ $? -eq 0 ]; then
printf "QNN libs already exist\n"
printf "QNN libs already exist on Android phone\n"
else
adb push ${QNN_SDK_PATH}/lib/aarch64-android/libQnnSystem.so ${REMOTE_PATH}/
adb push ${QNN_SDK_PATH}/lib/aarch64-android/libQnnCpu.so ${REMOTE_PATH}/
Expand Down

0 comments on commit 67beeb6

Please sign in to comment.