Skip to content

Commit

Permalink
[LLM Runtime] dynamic link the layer to compress binary size (#1059)
Browse files Browse the repository at this point in the history
Co-authored-by: Ding, Yi <[email protected]>
  • Loading branch information
a32543254 and DDEle committed Dec 22, 2023
1 parent 3115926 commit 6e3a514
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ if (NE_GELU_VEC)
endif()
option(NE_PYTHON_API "neural_engine: use python api" OFF)
option(NE_SIMD_VEC_DOT_F16 "neural_engine: enable vec_dot_fp16 SIMD optimization" ON)

option(BUILD_SHARED_LIBS "If build as shared libs" ON)

if (NE_SIMD_VEC_DOT_F16)
add_compile_definitions(NE_SIMD_VEC_DOT_F16)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,25 @@ function(add_executable_w_warning TARGET)
warning_check(${TARGET})
endfunction()

function(add_library_w_warning TARGET)
add_library(${TARGET} STATIC ${ARGN})
function(add_library_w_warning_ TARGET)
add_library(${TARGET} ${ARGN})
set_target_properties(${TARGET} PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON C_EXTENSIONS OFF)
set_target_properties(${TARGET} PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
warning_check(${TARGET})
endfunction()

function(add_library_w_warning TARGET)
add_library_w_warning_(${TARGET} STATIC ${ARGN})
endfunction()

function(add_shared_library_w_warning TARGET)
add_library_w_warning_(${TARGET} SHARED ${ARGN})
endfunction()

function(add_shareable_library_w_warning TARGET)
if (BUILD_SHARED_LIBS)
add_library_w_warning_(${TARGET} SHARED ${ARGN})
else()
add_library_w_warning_(${TARGET} STATIC ${ARGN})
endif()
endfunction()
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ find_package(Threads REQUIRED)
file(GLOB layers_srcs "layers/*.cpp")
set(sources ne_layers.c ${layers_srcs})

add_library_w_warning(ne_layers "${sources}")
add_shareable_library_w_warning(ne_layers "${sources}")

target_include_directories(ne_layers PUBLIC .)
target_compile_features(ne_layers PUBLIC c_std_11) # don't bump
Expand Down

0 comments on commit 6e3a514

Please sign in to comment.