* hex-fa: clean up qf32/fp32 handling and stride handling * hex-fa: fix corner case fp NAN issues that were cause bad output from gemma4 on v79 * hex-fa: vectorize leftover handling * hex-fa: avoid HVX fallback during token gen HMX has more FP16 compute capacity * hmx-mm: remove dead code * hmx-mm: use fastdiv in x4x2 dequant * hmx-mm: sandwich dequant and scatter to improve perf * hmx-mm: fixed rebase conflicts * hmx-mm: further improve weight dequant by doing early type dispatch and precomputing fastdiv * hmx-mm: an even earlier dispatch for per-type dequant * hmx-mm: dequant linear types like q4_0 and q4_1 without the LUTs This is a bit faster than LUT. * hex-cmake: one more tweak for lto --------- Co-authored-by: Trivikram Reddy <tamarnat@qti.qualcomm.com>
82 lines
2.0 KiB
CMake
82 lines
2.0 KiB
CMake
cmake_minimum_required(VERSION 3.22.2)
|
|
project(ggml-htp C CXX ASM)
|
|
|
|
include(${HEXAGON_SDK_ROOT}/build/cmake/hexagon_fun.cmake)
|
|
|
|
include_directories(
|
|
${HEXAGON_SDK_ROOT}/incs
|
|
${HEXAGON_SDK_ROOT}/incs/stddef
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../../../include
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
|
${CMAKE_CURRENT_SOURCE_DIR}/..
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
set(HTP_LIB ggml-htp-${DSP_VERSION})
|
|
|
|
add_library(${HTP_LIB} SHARED
|
|
main.c
|
|
htp_iface_skel.c
|
|
worker-pool.c
|
|
hex-dma.c
|
|
matmul-ops.c
|
|
binary-ops.c
|
|
unary-ops.c
|
|
sum-rows-ops.c
|
|
softmax-ops.c
|
|
act-ops.c
|
|
rope-ops.c
|
|
flash-attn-ops.c
|
|
set-rows-ops.c
|
|
get-rows-ops.c
|
|
cpy-ops.c
|
|
repeat-ops.c
|
|
argsort-ops.c
|
|
ssm-conv.c
|
|
cumsum-ops.c
|
|
fill-ops.c
|
|
concat-ops.c
|
|
diag-ops.c
|
|
solve-tri-ops.c
|
|
gated-delta-net-ops.c
|
|
pad-ops.c
|
|
)
|
|
|
|
target_compile_definitions(${HTP_LIB} PRIVATE
|
|
$<IF:$<BOOL:${HEXAGON_HTP_DEBUG}>,HTP_DEBUG=1,NDEBUG=1>
|
|
$<IF:$<BOOL:${HEXAGON_HTP_DEBUG}>,FARF_HIGH=1,>
|
|
FP32_QUANTIZE_GROUP_SIZE=${GGML_HEXAGON_FP32_QUANTIZE_GROUP_SIZE})
|
|
|
|
if (GGML_HEXAGON_FA_EXP2_HF)
|
|
message(STATUS "ggml-htp: HMX_FA_USE_EXP2_HF=1 (use FP16 exp2 polynomial in FA softmax)")
|
|
target_compile_definitions(${HTP_LIB} PRIVATE HMX_FA_USE_EXP2_HF=1)
|
|
endif()
|
|
|
|
# HMX acceleration: available on v73+ architectures
|
|
set(HTP_HMX_VERSIONS v73 v75 v79 v81)
|
|
list(FIND HTP_HMX_VERSIONS ${DSP_VERSION} _hmx_idx)
|
|
|
|
if (_hmx_idx GREATER_EQUAL 0)
|
|
target_sources(${HTP_LIB} PRIVATE
|
|
hmx-flash-attn-ops.c
|
|
hmx-matmul-ops.c
|
|
hmx-queue.c
|
|
)
|
|
|
|
# -mhmx enables HMX instruction set (needed by files that include hmx-utils.h)
|
|
set_source_files_properties(
|
|
hmx-flash-attn-ops.c
|
|
hmx-matmul-ops.c
|
|
hmx-queue.c
|
|
PROPERTIES COMPILE_OPTIONS "-mhmx"
|
|
)
|
|
|
|
target_compile_definitions(${HTP_LIB} PRIVATE HTP_HAS_HMX=1)
|
|
endif()
|
|
|
|
build_idl(htp_iface.idl ${HTP_LIB})
|
|
|
|
set_target_properties(${HTP_LIB} PROPERTIES EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
install(TARGETS ${HTP_LIB})
|