From adc92356ab98900d2b4f16f09b091db2824254fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 13 Mar 2019 15:16:31 +0900 Subject: [PATCH] [neurun] Extract NNAPI frontend from src (#4705) This commit extracts NNAPI implementations (e.g. ANeuralNetworksModel_create) from "src" and moves it to newly introduced frontend/nnapi directory. Signed-off-by: Jonghyun Park --- runtimes/neurun/CMakeLists.txt | 25 ++++++++++++++++------ .../nnapi}/frontend/compilation.cc | 0 .../{src => frontend/nnapi}/frontend/event.cc | 0 .../{src => frontend/nnapi}/frontend/execution.cc | 0 .../{src => frontend/nnapi}/frontend/memory.cc | 0 .../{src => frontend/nnapi}/frontend/model.cc | 0 .../nnapi}/frontend/wrapper/OperationFactory.cc | 0 .../nnapi}/frontend/wrapper/OperationFactory.h | 0 .../nnapi}/frontend/wrapper/compilation.cc | 0 .../nnapi}/frontend/wrapper/compilation.h | 0 .../nnapi}/frontend/wrapper/event.h | 0 .../nnapi}/frontend/wrapper/execution.cc | 0 .../nnapi}/frontend/wrapper/execution.h | 0 .../nnapi}/frontend/wrapper/memory.cc | 0 .../nnapi}/frontend/wrapper/memory.h | 0 .../nnapi}/frontend/wrapper/model.cc | 0 .../nnapi}/frontend/wrapper/model.h | 0 17 files changed, 18 insertions(+), 7 deletions(-) rename runtimes/neurun/{src => frontend/nnapi}/frontend/compilation.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/event.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/execution.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/memory.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/model.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/OperationFactory.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/OperationFactory.h (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/compilation.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/compilation.h (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/event.h (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/execution.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/execution.h (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/memory.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/memory.h (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/model.cc (100%) rename runtimes/neurun/{src => frontend/nnapi}/frontend/wrapper/model.h (100%) diff --git a/runtimes/neurun/CMakeLists.txt b/runtimes/neurun/CMakeLists.txt index 3ca5316..d8bacef 100644 --- a/runtimes/neurun/CMakeLists.txt +++ b/runtimes/neurun/CMakeLists.txt @@ -15,7 +15,6 @@ endif(NOT "${TARGET_ARCH}" STREQUAL "x86_64") add_subdirectory(src/backend) file(GLOB SOURCES "src/*.cc") -file(GLOB_RECURSE SOURCES_FRONTEND "src/frontend/*.cc") file(GLOB SOURCES_BACKEND "src/backend/*.cc") file(GLOB_RECURSE SOURCES_GRAPH "src/graph/*.cc") file(GLOB_RECURSE SOURCES_LINEAR "src/linear/*.cc") @@ -26,15 +25,25 @@ file(GLOB_RECURSE SOURCES_VERIFIER "src/verifier/*.cc") file(GLOB_RECURSE SOURCES_UTIL "src/util/*.cc") file(GLOB_RECURSE SOURCES_MODEL "src/model/*.cc") -set(SOURCES ${SOURCES} ${SOURCES_FRONTEND} ${SOURCES_BACKEND} ${SOURCES_GRAPH} ${SOURCES_LINEAR} ${SOURCES_DUMPER} ${SOURCES_COMPILER} ${SOURCES_EXEC} ${SOURCES_VERIFIER} ${SOURCES_UTIL} ${SOURCES_MODEL}) +set(SOURCES ${SOURCES} ${SOURCES_BACKEND} ${SOURCES_GRAPH} ${SOURCES_LINEAR} ${SOURCES_DUMPER} ${SOURCES_COMPILER} ${SOURCES_EXEC} ${SOURCES_VERIFIER} ${SOURCES_UTIL} ${SOURCES_MODEL}) -add_library(${LIB_NEURUN} SHARED ${SOURCES}) +add_library(neurun-core STATIC ${SOURCES}) +set_target_properties(neurun-core PROPERTIES POSITION_INDEPENDENT_CODE ON) +target_include_directories(neurun-core PUBLIC ${NEURUN_INCLUDE_DIR}) +target_include_directories(neurun-core PUBLIC ${CMAKE_SOURCE_DIR}/externals/tensorflow) +target_link_libraries(neurun-core nnapi-header) +target_link_libraries(neurun-core tensorflow-lite) +target_link_libraries(neurun-core nnfw_lib_misc) +target_link_libraries(neurun-core nnfw_lib_cpp14) +target_compile_options(neurun-core PRIVATE -Wall -Wextra -Werror) + +file(GLOB_RECURSE SOURCES_FRONTEND "frontend/nnapi/*.cc") + +add_library(${LIB_NEURUN} SHARED ${SOURCES_FRONTEND}) +target_include_directories(${LIB_NEURUN} PRIVATE frontend/nnapi) 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} nnapi-header) -target_link_libraries(${LIB_NEURUN} tensorflow-lite) -target_link_libraries(${LIB_NEURUN} nnfw_lib_misc) -target_link_libraries(${LIB_NEURUN} nnfw_lib_cpp14) +target_link_libraries(${LIB_NEURUN} neurun-core) target_compile_options(${LIB_NEURUN} PRIVATE -Wall -Wextra -Werror) @@ -50,6 +59,8 @@ set(TEST_NEURUN test_neurun) file(GLOB_RECURSE TESTS "test/*.cc") add_executable(${TEST_NEURUN} ${TESTS}) +# NOTE This line is a workaround to resolve compilation error +target_include_directories(${TEST_NEURUN} PRIVATE frontend/nnapi) target_link_libraries(${TEST_NEURUN} ${LIB_NEURUN}) target_link_libraries(${TEST_NEURUN} gtest) target_link_libraries(${TEST_NEURUN} gtest_main) diff --git a/runtimes/neurun/src/frontend/compilation.cc b/runtimes/neurun/frontend/nnapi/frontend/compilation.cc similarity index 100% rename from runtimes/neurun/src/frontend/compilation.cc rename to runtimes/neurun/frontend/nnapi/frontend/compilation.cc diff --git a/runtimes/neurun/src/frontend/event.cc b/runtimes/neurun/frontend/nnapi/frontend/event.cc similarity index 100% rename from runtimes/neurun/src/frontend/event.cc rename to runtimes/neurun/frontend/nnapi/frontend/event.cc diff --git a/runtimes/neurun/src/frontend/execution.cc b/runtimes/neurun/frontend/nnapi/frontend/execution.cc similarity index 100% rename from runtimes/neurun/src/frontend/execution.cc rename to runtimes/neurun/frontend/nnapi/frontend/execution.cc diff --git a/runtimes/neurun/src/frontend/memory.cc b/runtimes/neurun/frontend/nnapi/frontend/memory.cc similarity index 100% rename from runtimes/neurun/src/frontend/memory.cc rename to runtimes/neurun/frontend/nnapi/frontend/memory.cc diff --git a/runtimes/neurun/src/frontend/model.cc b/runtimes/neurun/frontend/nnapi/frontend/model.cc similarity index 100% rename from runtimes/neurun/src/frontend/model.cc rename to runtimes/neurun/frontend/nnapi/frontend/model.cc diff --git a/runtimes/neurun/src/frontend/wrapper/OperationFactory.cc b/runtimes/neurun/frontend/nnapi/frontend/wrapper/OperationFactory.cc similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/OperationFactory.cc rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/OperationFactory.cc diff --git a/runtimes/neurun/src/frontend/wrapper/OperationFactory.h b/runtimes/neurun/frontend/nnapi/frontend/wrapper/OperationFactory.h similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/OperationFactory.h rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/OperationFactory.h diff --git a/runtimes/neurun/src/frontend/wrapper/compilation.cc b/runtimes/neurun/frontend/nnapi/frontend/wrapper/compilation.cc similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/compilation.cc rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/compilation.cc diff --git a/runtimes/neurun/src/frontend/wrapper/compilation.h b/runtimes/neurun/frontend/nnapi/frontend/wrapper/compilation.h similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/compilation.h rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/compilation.h diff --git a/runtimes/neurun/src/frontend/wrapper/event.h b/runtimes/neurun/frontend/nnapi/frontend/wrapper/event.h similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/event.h rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/event.h diff --git a/runtimes/neurun/src/frontend/wrapper/execution.cc b/runtimes/neurun/frontend/nnapi/frontend/wrapper/execution.cc similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/execution.cc rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/execution.cc diff --git a/runtimes/neurun/src/frontend/wrapper/execution.h b/runtimes/neurun/frontend/nnapi/frontend/wrapper/execution.h similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/execution.h rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/execution.h diff --git a/runtimes/neurun/src/frontend/wrapper/memory.cc b/runtimes/neurun/frontend/nnapi/frontend/wrapper/memory.cc similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/memory.cc rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/memory.cc diff --git a/runtimes/neurun/src/frontend/wrapper/memory.h b/runtimes/neurun/frontend/nnapi/frontend/wrapper/memory.h similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/memory.h rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/memory.h diff --git a/runtimes/neurun/src/frontend/wrapper/model.cc b/runtimes/neurun/frontend/nnapi/frontend/wrapper/model.cc similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/model.cc rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/model.cc diff --git a/runtimes/neurun/src/frontend/wrapper/model.h b/runtimes/neurun/frontend/nnapi/frontend/wrapper/model.h similarity index 100% rename from runtimes/neurun/src/frontend/wrapper/model.h rename to runtimes/neurun/frontend/nnapi/frontend/wrapper/model.h -- 2.7.4