From a220ae41796cde007b2b3c79a53956fca05956c5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Thu, 26 Jul 2018 13:46:30 +0900 Subject: [PATCH] [neurun] Build cpu kernel as separate lib (#2084) Build cpu kernel as separate lib `libkernel_cpu.a`. Part of #1960 Signed-off-by: Hanjoung Lee --- runtimes/neurun/CMakeLists.txt | 6 +++++- runtimes/neurun/src/backend/cpu/CMakeLists.txt | 1 + runtimes/neurun/src/kernel/CMakeLists.txt | 1 + runtimes/neurun/src/kernel/cpufallback/CMakeLists.txt | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 runtimes/neurun/src/kernel/CMakeLists.txt create mode 100644 runtimes/neurun/src/kernel/cpufallback/CMakeLists.txt diff --git a/runtimes/neurun/CMakeLists.txt b/runtimes/neurun/CMakeLists.txt index 2fb4a0c..e253fb3 100644 --- a/runtimes/neurun/CMakeLists.txt +++ b/runtimes/neurun/CMakeLists.txt @@ -2,6 +2,10 @@ set(NEURUN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) +# Build kernels +set(LIB_NEURUN_KERNEL_CPU neurun_kernel_cpu) +add_subdirectory(src/kernel) + # Build backends set(LIB_NEURUN_BACKEND_CPU neurun_backend_cpu) set(LIB_NEURUN_BACKEND_ACL_CL neurun_backend_acl_cl) @@ -9,7 +13,7 @@ add_subdirectory(src/backend) file(GLOB SOURCES "src/*.cc") file(GLOB_RECURSE SOURCES_INTERNAL "src/internal/*.cc") -file(GLOB_RECURSE SOURCES_KERNEL "src/kernel/*.cc") # TODO should be built as a separate lib +file(GLOB_RECURSE SOURCES_KERNEL "src/kernel/acl_cl/*.cc") # TODO should be built as a separate lib set(SOURCES ${SOURCES} ${SOURCES_INTERNAL} ${SOURCES_KERNEL}) diff --git a/runtimes/neurun/src/backend/cpu/CMakeLists.txt b/runtimes/neurun/src/backend/cpu/CMakeLists.txt index ec223d3..618fb2c 100644 --- a/runtimes/neurun/src/backend/cpu/CMakeLists.txt +++ b/runtimes/neurun/src/backend/cpu/CMakeLists.txt @@ -10,6 +10,7 @@ target_link_libraries(${LIB_NEURUN_BACKEND_CPU} arm_compute) # TODO We should no target_link_libraries(${LIB_NEURUN_BACKEND_CPU} tensorflow-lite) target_link_libraries(${LIB_NEURUN_BACKEND_CPU} nnfw_util) target_link_libraries(${LIB_NEURUN_BACKEND_CPU} nnfw_support_nnapi) +target_link_libraries(${LIB_NEURUN_BACKEND_CPU} ${LIB_NEURUN_KERNEL_CPU}) set_target_properties(${LIB_NEURUN_BACKEND_CPU} PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(${LIB_NEURUN_BACKEND_CPU} PROPERTIES OUTPUT_NAME backend_cpu) diff --git a/runtimes/neurun/src/kernel/CMakeLists.txt b/runtimes/neurun/src/kernel/CMakeLists.txt new file mode 100644 index 0000000..641d1f2 --- /dev/null +++ b/runtimes/neurun/src/kernel/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(cpufallback) diff --git a/runtimes/neurun/src/kernel/cpufallback/CMakeLists.txt b/runtimes/neurun/src/kernel/cpufallback/CMakeLists.txt new file mode 100644 index 0000000..dddf154 --- /dev/null +++ b/runtimes/neurun/src/kernel/cpufallback/CMakeLists.txt @@ -0,0 +1,14 @@ +file(GLOB SOURCES "*.cc") + +add_library(${LIB_NEURUN_KERNEL_CPU} STATIC ${SOURCES}) + +target_include_directories(${LIB_NEURUN_KERNEL_CPU} PUBLIC ${NNFW_INCLUDE_DIR}) +target_include_directories(${LIB_NEURUN_KERNEL_CPU} PUBLIC ${NEURUN_INCLUDE_DIR}) +target_include_directories(${LIB_NEURUN_KERNEL_CPU} PUBLIC ${CMAKE_SOURCE_DIR}/externals/tensorflow) + +target_link_libraries(${LIB_NEURUN_KERNEL_CPU} arm_compute) # TODO We should not need this +target_link_libraries(${LIB_NEURUN_KERNEL_CPU} tensorflow-lite) + +set_target_properties(${LIB_NEURUN_KERNEL_CPU} PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(${LIB_NEURUN_KERNEL_CPU} PROPERTIES OUTPUT_NAME kernel_cpu) +install(TARGETS ${LIB_NEURUN_KERNEL_CPU} DESTINATION lib/neurun) -- 2.7.4