Skip to content

Commit a4ce74c

Browse files
author
zhouwg
committed
ggml-hexagon: check whether user's specified htp arch is valid in CMakeLists.txt
1 parent e00955e commit a4ce74c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

ggml/src/ggml-hexagon/CMakeLists.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,18 @@ endif()
3232
#v75 --- Snapdragon 8 Gen3
3333
#v79 --- Snapdragon 8 Elite(aka Gen4)
3434
if(NOT DEFINED HTP_ARCH_VERSION)
35-
#set default HTP_ARCH_VERSION to v75
36-
set(HTP_ARCH_VERSION v75)
35+
message(FATAL_ERROR "HTP_ARCH_VERSION not defined, valid htp arch: v68,v69,v73,v75,v79")
36+
endif()
37+
38+
#check whether user's specified htp arch is valid
39+
set(CHECK_HTP_ARCH "WRONG")
40+
foreach (feat v68 v69 v73 v75 v79)
41+
if (${feat} STREQUAL ${HTP_ARCH_VERSION})
42+
set(CHECK_HTP_ARCH "GOOD")
43+
endif()
44+
endforeach()
45+
if (${CHECK_HTP_ARCH} STREQUAL "WRONG")
46+
message(FATAL_ERROR "ggml-hexagon backend only support htp arch v68,v69,v73,v75,v79")
3747
endif()
3848

3949
#cross compiling for hexagon kernels on cDSP side
@@ -71,14 +81,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
7181
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
7282
set(QNN_DEFAULT_LIB_SEARCH_PATH "C:\\" CACHE STRING "customized library search path for QNN backend")
7383
else()
74-
message(FATAL_ERROR "QNN now only available on Android and Windows(Windows on ARM)")
84+
message(FATAL_ERROR "ggml-hexagon now only available on Android and Windows(Windows on ARM)")
7585
endif()
7686

7787
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGGML_USE_HEXAGON ${DEBUG_FLAG}")
7888
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
7989

80-
file(GLOB QNN_SOURCES "${CMAKE_CURRENT_LIST_DIR}/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/kernels/ggmlop_ap_skel.c")
81-
ggml_add_backend_library(ggml-hexagon ${QNN_SOURCES})
90+
file(GLOB HEXAGON_SOURCES "${CMAKE_CURRENT_LIST_DIR}/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/kernels/ggmlop_ap_skel.c")
91+
ggml_add_backend_library(ggml-hexagon ${HEXAGON_SOURCES})
8292

8393
target_include_directories(ggml-hexagon PRIVATE ${QNN_SDK_PATH}/include/QNN ${HEXAGON_SDK_PATH} ${CMAKE_CURRENT_LIST_DIR})
8494
target_link_libraries(ggml-hexagon PRIVATE ${QNN_LINK_LIBRARIES})
@@ -87,7 +97,7 @@ string(REGEX REPLACE "/$" "" QNN_DEFAULT_LIB_SEARCH_PATH "${QNN_DEFAULT_LIB_SEAR
8797
target_compile_definitions(ggml-hexagon PRIVATE QNN_DEFAULT_LIB_SEARCH_PATH="${QNN_DEFAULT_LIB_SEARCH_PATH}/")
8898

8999
function(ggml_hexagon_build_kernel KNAME)
90-
message(STATUS "ggml_hexagon: build kernel ${KNAME}")
100+
message(STATUS "ggml_hexagon: build hexagon-kernel ${KNAME}")
91101

92102
add_custom_command(
93103
TARGET ${PROJECT_NAME}

0 commit comments

Comments
 (0)