[neurun] Extract cpu backend as a separate lib (#2042)
author이한종/동작제어Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Mon, 23 Jul 2018 02:11:09 +0000 (11:11 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 23 Jul 2018 02:11:09 +0000 (11:11 +0900)
Extract cpu backend as a separate lib but still kernel implementation is
included in this lib.

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

index b3ca947..c61a110 100644 (file)
@@ -1,4 +1,17 @@
-file(GLOB_RECURSE SOURCES "src/*.cc")
+# Add cpu
+
+set(NEURUN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
+
+set(LIB_NEURUN_BACKEND_CPU neurun_backend_cpu)
+add_subdirectory(src/backend)
+
+file(GLOB SOURCES "src/*.cc")
+file(GLOB_RECURSE SOURCES_INTERNAL "src/internal/*.cc")
+
+# TODO This must be built separately, just like "backend/cpu"
+file(GLOB_RECURSE SOURCES_BACKEND_ACL "src/backend/acl_cl/*.cc")
+
+set(SOURCES ${SOURCES} ${SOURCES_INTERNAL} ${SOURCES_BACKEND_ACL})
 
 # NOTE For now ARMCompute is necessary
 # TODO Remove required package below(should be optional)
@@ -6,12 +19,16 @@ nnfw_find_package(ARMCompute REQUIRED)
 
 add_library(${LIB_NEURUN} SHARED ${SOURCES})
 target_include_directories(${LIB_NEURUN} PUBLIC ${NNFW_INCLUDE_DIR})
-target_include_directories(${LIB_NEURUN} PUBLIC src
-                           ${CMAKE_SOURCE_DIR}/externals/tensorflow)
+target_include_directories(${LIB_NEURUN} PUBLIC ${NEURUN_INCLUDE_DIR})
+target_include_directories(${LIB_NEURUN} PUBLIC ${CMAKE_SOURCE_DIR}/externals/tensorflow)
 target_link_libraries(${LIB_NEURUN} arm_compute)
 target_link_libraries(${LIB_NEURUN} tensorflow-lite)
 target_link_libraries(${LIB_NEURUN} nnfw_util)
 target_link_libraries(${LIB_NEURUN} nnfw_support_nnapi)
+
+# TODO This should be optional
+target_link_libraries(${LIB_NEURUN} ${LIB_NEURUN_BACKEND_CPU})
+
 set_target_properties(${LIB_NEURUN} PROPERTIES OUTPUT_NAME neuralnetworks)
 
 install(TARGETS ${LIB_NEURUN} DESTINATION lib/new_runtime)
diff --git a/runtimes/neurun/src/backend/CMakeLists.txt b/runtimes/neurun/src/backend/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9f4db84
--- /dev/null
@@ -0,0 +1 @@
+add_subdirectory(cpu)
diff --git a/runtimes/neurun/src/backend/cpu/CMakeLists.txt b/runtimes/neurun/src/backend/cpu/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7fb0ab9
--- /dev/null
@@ -0,0 +1,15 @@
+file(GLOB SOURCES "*.cc")
+
+add_library(${LIB_NEURUN_BACKEND_CPU} SHARED ${SOURCES})
+
+target_include_directories(${LIB_NEURUN_BACKEND_CPU} PUBLIC ${NNFW_INCLUDE_DIR})
+target_include_directories(${LIB_NEURUN_BACKEND_CPU} PUBLIC ${NEURUN_INCLUDE_DIR})
+target_include_directories(${LIB_NEURUN_BACKEND_CPU} PUBLIC ${CMAKE_SOURCE_DIR}/externals/tensorflow)
+
+target_link_libraries(${LIB_NEURUN_BACKEND_CPU} arm_compute) # TODO We should not need this
+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)
+
+set_target_properties(${LIB_NEURUN_BACKEND_CPU} PROPERTIES OUTPUT_NAME backend_cpu)
+install(TARGETS ${LIB_NEURUN_BACKEND_CPU} DESTINATION lib/new_runtime)
index 336fb39..23a5329 100644 (file)
@@ -1,4 +1,4 @@
-#include "backend/cpu/InitializerGenerator.h"
+#include "InitializerGenerator.h"
 
 #include "internal/nnapi/kernel/Reader.h"
 #include "internal/nnapi/kernel/View.h"
index f6eb121..d2e719d 100644 (file)
@@ -1,4 +1,4 @@
-#include "backend/cpu/StageGenerator.h"
+#include "StageGenerator.h"
 
 #include <stdexcept>
 
index 7f75ba6..1a6c38e 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "internal/Model.h"
 #include "internal/cpu.h"
-#include "backend/cpu/TensorBuilder.h"
+#include "TensorBuilder.h"
 
 namespace internal
 {
index 24257ad..d13671f 100644 (file)
@@ -1,4 +1,4 @@
-#include "backend/cpu/TensorBuilder.h"
+#include "TensorBuilder.h"
 
 #include <cassert>