@@ -5,10 +5,59 @@ include(CheckIncludeFileCXX)
55#set(CMAKE_WARN_DEPRECATED YES)
66set (CMAKE_WARN_UNUSED_CLI YES )
77
8+ if (GGML_TSAVORITE)
9+ if (NOT DEFINED GGML_TSAVORITE_TARGET)
10+ set (GGML_TSAVORITE_TARGET "posix" )
11+ endif ()
12+ if (NOT ${GGML_TSAVORITE_TARGET} STREQUAL fpga)
13+ set (GGML_TSAVORITE_TARGET "posix" )
14+ endif ()
15+
16+ if (NOT DEFINED MLIR_COMPILER_DIR)
17+ if (NOT DEFINED $ENV{MLIR_SDK_VERSION} )
18+ set (MLIR_COMPILER_DIR /proj/work/rel/sw/sdk-r.0.1.0/compiler)
19+ else ()
20+ set (MLIR_COMPILER_DIR $ENV{MLIR_SDK_VERSION} /compiler)
21+ endif ()
22+ endif ()
23+
24+ if (NOT DEFINED RUNTIME_DIR)
25+ if (NOT DEFINED $ENV{MLIR_SDK_VERSION} )
26+ set (RUNTIME_DIR /proj/work/rel/sw/sdk-r.0.1.0/${GGML_TSAVORITE_TARGET} /runtime)
27+ else ()
28+ set (RUNTIME_DIR $ENV{MLIR_SDK_VERSION} /${GGML_TSAVORITE_TARGET} /runtime)
29+ endif ()
30+ endif ()
31+
32+ if (NOT DEFINED GGML_TSI_KERNEL_DIR)
33+ set (GGML_TSI_KERNEL_DIR ${CMAKE_SOURCE_DIR} /ggml-tsi-kernel/${GGML_TSAVORITE_TARGET} )
34+ endif ()
35+
36+ file (GLOB TLIBS "${RUNTIME_DIR} /lib/*.so" "${GGML_TSI_KERNEL_DIR} /host/*.o" )
37+
38+ if (${GGML_TSAVORITE_TARGET} STREQUAL fpga)
39+ set (CMAKE_CROSSCOMPILING ON )
40+ set (ARCH_FLAGS -march=armv8-a)
41+ message ("Setting target as fpga" )
42+ elseif (${GGML_TSAVORITE_TARGET} STREQUAL "posix" )
43+ list (APPEND TLIBS "${MLIR_COMPILER_DIR} /lib/libFFMDeviceShim.so" )
44+ message ("Setting target as posix for tsavorite" )
45+ endif ()
46+
47+ set (GGML_TSAVORITE_TARGET "${GGML_TSAVORITE_TARGET} " CACHE STRING "Target for tsavorite" )
48+ set (TSAVORITE_INCLUDE_DIR ${CMAKE_SOURCE_DIR} /ggml/src/ggml-tsavorite/include )
49+
50+ include_directories (${TSAVORITE_INCLUDE_DIR} )
51+ include_directories (${MLIR_COMPILER_DIR} /include /runtime/shim)
52+ include_directories (${RUNTIME_DIR} /include )
53+ message ("tsavorite backend is enabled" )
54+ endif ()
55+
856set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
957
1058if (NOT XCODE AND NOT MSVC AND NOT CMAKE_BUILD_TYPE )
11- set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
59+ #set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
60+ set (CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
1261 set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
1362endif ()
1463
@@ -82,9 +131,18 @@ option(LLAMA_BUILD_EXAMPLES "llama: build examples" ${LLAMA_STANDALONE})
82131option (LLAMA_BUILD_SERVER "llama: build server example" ${LLAMA_STANDALONE} )
83132
84133# 3rd party libs
85- option (LLAMA_CURL "llama: use libcurl to download model from an URL" ON )
86134option (LLAMA_LLGUIDANCE "llama-common: include LLGuidance library for structured output in common utils" OFF )
87135
136+ if (GGML_TSAVORITE)
137+ if (${GGML_TSAVORITE_TARGET} STREQUAL fpga)
138+ option (LLAMA_CURL "llama: use libcurl to download model from an URL" OFF )
139+ else ()
140+ option (LLAMA_CURL "llama: use libcurl to download model from an URL" ON )
141+ endif ()
142+ else ()
143+ option (LLAMA_CURL "llama: use libcurl to download model from an URL" ON )
144+ endif ()
145+
88146# Required for relocatable CMake package
89147include (${CMAKE_CURRENT_SOURCE_DIR} /cmake/build -info.cmake)
90148include (${CMAKE_CURRENT_SOURCE_DIR} /cmake/common.cmake)
0 commit comments