[neurun] Build cpu kernel as separate lib (#2084)
author이한종/동작제어Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Thu, 26 Jul 2018 04:46:30 +0000 (13:46 +0900)
committer이춘석/동작제어Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Thu, 26 Jul 2018 04:46:30 +0000 (13:46 +0900)
Build cpu kernel as separate lib `libkernel_cpu.a`.

Part of #1960

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
runtimes/neurun/CMakeLists.txt
runtimes/neurun/src/backend/cpu/CMakeLists.txt
runtimes/neurun/src/kernel/CMakeLists.txt [new file with mode: 0644]
runtimes/neurun/src/kernel/cpufallback/CMakeLists.txt [new file with mode: 0644]

index 2fb4a0c..e253fb3 100644 (file)
@@ -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})
 
index ec223d3..618fb2c 100644 (file)
@@ -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 (file)
index 0000000..641d1f2
--- /dev/null
@@ -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 (file)
index 0000000..dddf154
--- /dev/null
@@ -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)