File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,20 @@ if (CANN_INSTALL_DIR)
3939 target_include_directories (ggml-cann PRIVATE . .. ${CANN_INCLUDE_DIRS} )
4040 target_link_directories (ggml-cann PRIVATE ${CANN_INSTALL_DIR} /lib64)
4141
42+ # set define macro for the special soc type, as function of some ascend kernel is different for different soc type.
43+ set (SOC_VERSION "" )
44+ if (NOT SOC_TYPE)
45+ detect_ascend_soc_type(SOC_VERSION)
46+ set (SOC_TYPE "${SOC_VERSION} " )
47+ endif ()
48+ string (TOLOWER ${SOC_TYPE} SOC_VERSION)
49+ string (FIND "${SOC_VERSION} " "ascend310p" FIRST_310P_INDEX)
50+ if (FIRST_310P_INDEX GREATER -1)
51+ #add_compile_definitions(ASCEND_310P)
52+ target_compile_definitions (ggml-cann PRIVATE ASCEND_310P)
53+ endif ()
54+ message (STATUS "CANN: Compile llama.cpp with ${SOC_TYPE} ." )
55+
4256 message (STATUS "CANN: CANN_INCLUDE_DIRS = ${CANN_INCLUDE_DIRS} " )
4357 message (STATUS "CANN: CANN_LIBRARIES = ${CANN_LIBRARIES} " )
4458else ()
Original file line number Diff line number Diff line change 22set (SOC_VERSION "" )
33function (detect_ascend_soc_type SOC_VERSION)
44 execute_process (
5- COMMAND bash -c "npu-smi info|awk -F' ' 'NF > 0 && NR==7 {print $3}'"
5+ COMMAND bash -c "npu-smi info|awk -F' ' 'NF > 0 && NR==7 {print $3}'"
66 OUTPUT_VARIABLE npu_info
77 RESULT_VARIABLE npu_result
88 OUTPUT_STRIP_TRAILING_WHITESPACE
You can’t perform that action at this time.
0 commit comments