Skip to content

Commit a6c8a01

Browse files
committed
ggml-qnn: upgrade QNN SDK and add comments in build scripts to make ggml-org#12215 more clear
1 parent d77d861 commit a6c8a01

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

cmake/arm64-windows-llvm.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
set( CMAKE_SYSTEM_NAME Windows )
22
set( CMAKE_SYSTEM_PROCESSOR arm64 )
33

4+
#this is original, might-be suitable for MS's llvm toolchain
45
#set( target arm64-pc-windows-msvc )
6+
#this is modification, the following must be set for llvm-mingw otherwise failure
57
set( target aarch64-w64-mingw32 )
68

79
set( CMAKE_C_COMPILER clang )
@@ -10,8 +12,8 @@ set( CMAKE_CXX_COMPILER clang++ )
1012
set( CMAKE_C_COMPILER_TARGET ${target} )
1113
set( CMAKE_CXX_COMPILER_TARGET ${target} )
1214

13-
#set( arch_c_flags "-march=armv8.7-a -fvectorize -ffp-model=fast -fno-finite-math-only" )
14-
#set( warn_c_flags "-Wno-format -Wno-unused-variable -Wno-unused-function -Wno-gnu-zero-variadic-macro-arguments" )
15+
set( arch_c_flags "-march=armv8.7-a -fvectorize -ffp-model=fast -fno-finite-math-only" )
16+
set( warn_c_flags "-Wno-format -Wno-unused-variable -Wno-unused-function -Wno-gnu-zero-variadic-macro-arguments" )
1517

1618
set( CMAKE_C_FLAGS_INIT "${arch_c_flags} ${warn_c_flags}" )
1719
set( CMAKE_CXX_FLAGS_INIT "${arch_c_flags} ${warn_c_flags}" )

scripts/build-run-android.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ GGUF_MODEL_NAME=/sdcard/qwen1_5-1_8b-chat-q4_0.gguf
1515
#https://developer.qualcomm.com/software/hexagon-dsp-sdk/tools
1616
QNN_SDK_URL=https://www.qualcomm.com/developer/software/qualcomm-ai-engine-direct-sdk
1717
QNN_SDK_PATH=/opt/qcom/aistack/qairt/2.31.0.250130/
18+
QNN_SDK_PATH=/opt/qcom/aistack/qairt/2.32.0.250228/
1819

1920
#default is QNN NPU
2021
qnnbackend=2

scripts/build-run-windows.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
#!/bin/bash
2-
# build llama.cpp or llama.cpp + ggml-qnn for Windows with cygwin on Windows
3-
# build llama.cpp + ggml-qnn for Snapdragon desktop SoC equipped WoA(Windows on ARM) with cygwin on Windows
2+
# this script can be used with cygwin on x86-64 Windows
3+
# or llvm-mingw on x86-64 Linux
4+
#
5+
# case-1: build llama.cpp for x86-64 Windows with cygwin on x86-64 Windows
6+
# case-2: build llama.cpp + ggml-qnn for x86-64 Windows with cygwin on x86-64 Windows
7+
# case-3: build llama.cpp + ggml-qnn for Snapdragon desktop SoC equipped WoA(Windows on ARM) with cygwin on Windows
8+
# case-4: build llama.cpp + ggml-qnn for Snapdragon desktop SoC equipped WoA(Windows on ARM) with mingw on x86-64 Linux
49

510
# items marked TODO has not verified yet
611

712
set -e
813

914

1015
PWD=`pwd`
16+
#for cygwin on x86-64 Windows
1117
PREFIX_PATH=/cygdrive/c
18+
#for mingw on x86-64 Linux
19+
#PREFIX_PATH=/opt/qcom/aistack/
20+
1221
GGUF_MODEL_NAME=${PREFIX_PATH}/qwen1_5-1_8b-chat-q4_0.gguf
1322
PROJECT_HOME_PATH=`pwd`
1423

@@ -17,6 +26,7 @@ PROJECT_HOME_PATH=`pwd`
1726
#https://developer.qualcomm.com/software/hexagon-dsp-sdk/tools
1827
QNN_SDK_URL=https://www.qualcomm.com/developer/software/qualcomm-ai-engine-direct-sdk
1928
QNN_SDK_PATH=${PREFIX_PATH}/qairt/2.31.0.250130/
29+
QNN_SDK_PATH=${PREFIX_PATH}/qairt/2.32.0.250228/
2030

2131
#default is QNN NPU
2232
qnnbackend=2
@@ -41,6 +51,7 @@ function check_qnn_sdk()
4151
fi
4252
}
4353

54+
#ok with cygwin on x86-64 Windows
4455
function build_windows_x86
4556
{
4657
echo "build_windows_x86-without-qnn"
@@ -52,6 +63,7 @@ function build_windows_x86
5263
cd -
5364
}
5465

66+
#ok with cygwin on x86-64 Windows
5567
function build_windows_x86_qnn
5668
{
5769
echo "build_windows_x86-with-qnn"
@@ -66,7 +78,8 @@ function build_windows_x86_qnn
6678
#TODO
6779
function build_windows_arm64_qnn
6880
{
69-
echo "build_windows_arm64 not supported now"
81+
echo "build llama.cpp for WoA through cgwin on Windows or mingw on Linux not supported now, pls try mingw on Windows and it works"
82+
return 0
7083
echo "cmake source dir:${PROJECT_HOME_PATH}"
7184
#cmake -H. -B./out/windows_arm64_qnn -DCMAKE_BUILD_TYPE=Release -DGGML_OPENMP=OFF -DGGML_QNN=ON -DCMAKE_TOOLCHAIN_FILE=${PROJECT_HOME_PATH}/cmake/arm64-windows-llvm.cmake -DCMAKE_C_FLAGS=-march=armv8.7-a -DGGML_QNN_SDK_PATH=${QNN_SDK_PATH}
7285
#cmake -H. -B./out/windows_arm64_qnn -DCMAKE_BUILD_TYPE=Release -DGGML_OPENMP=OFF -DGGML_QNN=ON -DCMAKE_TOOLCHAIN_FILE=${PROJECT_HOME_PATH}/cmake/arm64-windows-cygwin.cmake -DCMAKE_C_FLAGS=-march=armv8.7-a -DGGML_QNN_SDK_PATH=${QNN_SDK_PATH}

scripts/build-woa-on-windows.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo "build llama.cpp through llvm-mingw toolchain on x86-64 Windows"
2+
3+
set PATH=C:\Program Files\llvm-mingw-20250305-ggml-ucrt-x86_64\bin;C:\Program Files\llvm-mingw-20250305-ggml-ucrt-x86_64\Git\cmd;C:\Program Files\llvm-mingw-20250305-ggml-ucrt-x86_64\CMake\bin;%PATH%;
4+
cmake --preset arm64-windows-llvm-release -D GGML_OPENMP=OFF -DGGML_QNN=ON -DGGML_QNN_SDK_PATH="C:\\qairt\\2.31.0.250130"
5+
cmake --build build-arm64-windows-llvm-release

0 commit comments

Comments
 (0)