Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-hexagon/CMakeLists.txt # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-hexagon / CMakeLists.txt` 128 lines ยท 5195 bytes Raw Blame History 1 file(TO_CMAKE_PATH "${HEXAGON_SDK_ROOT}" HEXAGON_SDK_ROOT) 2 file(TO_CMAKE_PATH "${HEXAGON_TOOLS_ROOT}" HEXAGON_TOOLS_ROOT) 3 4 if (NOT IS_DIRECTORY "${HEXAGON_SDK_ROOT}") 5 message(FATAL_ERROR "Make sure HEXAGON_SDK_ROOT point to the correct Hexagon SDK installation.") 6 endif() 7 8 if (NOT IS_DIRECTORY "${HEXAGON_TOOLS_ROOT}") 9 message("Try to read HEXAGON_TOOLS_ROOT from hexagon_sdk.json") 10 file(READ "${HEXAGON_SDK_ROOT}/hexagon_sdk.json" HEXAGON_SDK_CONFIG_PATH) 11 string(JSON HEXAGON_TOOLS_PATH GET ${HEXAGON_SDK_CONFIG_PATH} "root" "tools" "info" 0 "path") 12 message("Found HEXAGON_TOOLS_PATH: ${HEXAGON_TOOLS_PATH}") 13 set(HEXAGON_TOOLS_ROOT "${HEXAGON_SDK_ROOT}/${HEXAGON_TOOLS_PATH}") 14 file(TO_CMAKE_PATH "${HEXAGON_TOOLS_ROOT}" HEXAGON_TOOLS_ROOT) 15 if (NOT IS_DIRECTORY "${HEXAGON_TOOLS_ROOT}") 16 message(FATAL_ERROR "Make sure HEXAGON_TOOLS_ROOT point to the correct Hexagon SDK installation.") 17 endif() 18 endif() 19 20 message(STATUS "hexagon: using ${HEXAGON_SDK_ROOT} and ${HEXAGON_TOOLS_ROOT} for building libggml-htp skels") 21 22 include(${HEXAGON_SDK_ROOT}/build/cmake/hexagon_fun.cmake) 23 include(ExternalProject) 24 find_package(Python3 REQUIRED COMPONENTS Interpreter) 25 26 option(GGML_HEXAGON_HTP_DEBUG "ggml-hexagon: enable HTP debug output" OFF) 27 set(GGML_HEXAGON_HTP_BUILD_TYPE "Release" CACHE STRING "ggml-hexagon: HTP skel build type (Release, RelWithDebInfo, Debug)") 28 set(GGML_HEXAGON_HTP_CERT "$ENV{HEXAGON_HTP_CERT}" CACHE PATH "ggml-hexagon: enable HTP library signing using certificate") 29 30 add_library(htp_iface OBJECT 31 ${CMAKE_CURRENT_BINARY_DIR}/htp_iface_stub.c) 32 33 set_target_properties(htp_iface PROPERTIES POSITION_INDEPENDENT_CODE ON) 34 target_include_directories(htp_iface PUBLIC 35 ${HEXAGON_SDK_ROOT}/incs 36 ${HEXAGON_SDK_ROOT}/incs/stddef 37 ${HEXAGON_SDK_ROOT}/utils/examples 38 ${CMAKE_CURRENT_SOURCE_DIR}/htp 39 ${CMAKE_CURRENT_BINARY_DIR}) 40 41 build_idl(htp/htp_iface.idl htp_iface) 42 43 if (CMAKE_SYSTEM_NAME MATCHES Android) 44 target_link_options(htp_iface PUBLIC -llog -ldl) 45 elseif (CMAKE_SYSTEM_NAME MATCHES Windows) 46 target_precompile_headers(htp_iface PUBLIC ) 47 else() 48 target_link_options(htp_iface PUBLIC -ldl) 49 endif() 50 51 set(TARGET_NAME ggml-hexagon) 52 ggml_add_backend_library(${TARGET_NAME} 53 ggml-hexagon.cpp 54 htp-common.h 55 htp-kparams.cpp 56 htp-kparams.h 57 htp-opnode.cpp 58 htp-opnode.h 59 htp-fusion.cpp 60 htp-fusion.h 61 htp-repack.cpp 62 htp-repack.h 63 htp-drv.cpp 64 htp-drv.h 65 libdl.h 66 ../../include/ggml-hexagon.h) 67 68 target_link_libraries(${TARGET_NAME} PRIVATE htp_iface) 69 target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/htp ${CMAKE_CURRENT_BINARY_DIR}) 70 71 # Build HTP skels 72 set(HTP_SKELS) 73 set(HTP_PROJECTS) 74 function(build_htp_skel V) 75 ExternalProject_Add(htp-${V} 76 SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/htp BUILD_ALWAYS ON 77 CMAKE_ARGS 78 -DCMAKE_BUILD_TYPE=${GGML_HEXAGON_HTP_BUILD_TYPE} 79 -DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/htp/cmake-toolchain.cmake 80 -DCMAKE_INSTALL_LIBDIR=${CMAKE_CURRENT_BINARY_DIR} 81 -DHEXAGON_SDK_ROOT=${HEXAGON_SDK_ROOT} 82 -DHEXAGON_TOOLS_ROOT=${HEXAGON_TOOLS_ROOT} 83 -DHEXAGON_HTP_DEBUG=${GGML_HEXAGON_HTP_DEBUG} 84 -DDSP_VERSION=${V} 85 -DPython3_EXECUTABLE=${Python3_EXECUTABLE} 86 -DPREBUILT_LIB_DIR="toolv21_${V}") 87 list(APPEND HTP_SKELS ${CMAKE_CURRENT_BINARY_DIR}/libggml-htp-${V}.so) 88 list(APPEND HTP_PROJECTS htp-${V}) 89 set(HTP_SKELS ${HTP_SKELS} PARENT_SCOPE) 90 set(HTP_PROJECTS ${HTP_PROJECTS} PARENT_SCOPE) 91 endfunction() 92 93 build_htp_skel(v73) 94 build_htp_skel(v75) 95 build_htp_skel(v79) 96 build_htp_skel(v81) 97 build_htp_skel(v85) 98 99 # Install Hexagon skels required at runtime 100 install(FILES ${HTP_SKELS} TYPE LIB) 101 102 if (CMAKE_SYSTEM_NAME MATCHES Windows AND GGML_HEXAGON_HTP_CERT) 103 file(TO_CMAKE_PATH "$ENV{WINDOWS_SDK_BIN}/arm64" WINSDK_BIN0_ARM64) 104 file(TO_CMAKE_PATH "$ENV{WINDOWS_SDK_BIN}/x86" WINSDK_BIN0_X86) 105 file(TO_CMAKE_PATH "$ENV{WindowsSdkVerBinPath}/arm64" WINSDK_BIN1_ARM64) 106 file(TO_CMAKE_PATH "$ENV{WindowsSdkVerBinPath}/x86" WINSDK_BIN1_X86) 107 108 set(WINSDK_PATHS ${WINSDK_BIN0_ARM64} ${WINSDK_BIN0_X86} ${WINSDK_BIN1_ARM64} ${WINSDK_BIN1_X86}) 109 110 find_program(INF2CAT NAMES inf2cat.exe PATHS ${WINSDK_PATHS} REQUIRED) 111 find_program(SIGNTOOL NAMES signtool.exe PATHS ${WINSDK_PATHS} REQUIRED) 112 113 message(STATUS "hexagon: using ${GGML_HEXAGON_HTP_CERT} to sign libggml-htp skels") 114 115 set(LIBGGML_HTP_CAT ${CMAKE_CURRENT_BINARY_DIR}/libggml-htp.cat) 116 add_custom_target(libggml-htp-cat 117 BYPRODUCTS ${LIBGGML_HTP_CAT} 118 DEPENDS libggml-htp.inf ${HTP_PROJECTS} 119 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/libggml-htp.inf ${CMAKE_CURRENT_BINARY_DIR} 120 COMMAND ${INF2CAT} /driver:${CMAKE_CURRENT_BINARY_DIR} /os:10_25H2_ARM64 121 COMMAND ${SIGNTOOL} sign /fd sha256 /f ${GGML_HEXAGON_HTP_CERT} ${LIBGGML_HTP_CAT} 122 COMMENT "generating and signing libggml-htp.cat file" 123 VERBATIM 124 ) 125 126 add_dependencies(${TARGET_NAME} libggml-htp-cat) 127 install(FILES ${LIBGGML_HTP_CAT} TYPE LIB) 128 endif()