From: 오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 8 Aug 2019 00:45:27 +0000 (+0900) Subject: Merge neurun kernel and backend build (#6313) X-Git-Tag: submit/tizen/20190809.050447~59 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9dd1623d4afbe90dfdf2cefb9edad2b410be0cf;p=platform%2Fcore%2Fml%2Fnnfw.git Merge neurun kernel and backend build (#6313) - Merge neurun each backend's kernel and backend build - Fix build error on cpu backend kernel by restrict build option - Invalid type comparison - Unused variable - Unused function Signed-off-by: Hyeongseok Oh --- diff --git a/runtimes/neurun/backend/acl_cl/CMakeLists.txt b/runtimes/neurun/backend/acl_cl/CMakeLists.txt index c2f1fd6..2dd7959 100644 --- a/runtimes/neurun/backend/acl_cl/CMakeLists.txt +++ b/runtimes/neurun/backend/acl_cl/CMakeLists.txt @@ -5,13 +5,8 @@ if(NOT ARMCompute_FOUND) endif(NOT ARMCompute_FOUND) set(LIB_NEURUN_BACKEND_ACL_CL neurun_backend_acl_cl) -set(LIB_NEURUN_KERNEL_ACL_CL neurun_kernel_acl_cl) - -add_subdirectory(kernel) file(GLOB_RECURSE SOURCES "*.cc") -file(GLOB_RECURSE REMOVE_KERNEL_SOURCES "kernel/*.cc") -list(REMOVE_ITEM SOURCES ${REMOVE_KERNEL_SOURCES}) add_library(${LIB_NEURUN_BACKEND_ACL_CL} SHARED ${SOURCES}) @@ -20,7 +15,6 @@ target_include_directories(${LIB_NEURUN_BACKEND_ACL_CL} PUBLIC ${CMAKE_CURRENT_S target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} arm_compute) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} arm_compute_ex) -target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} ${LIB_NEURUN_KERNEL_ACL_CL}) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} neurun-core) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_CL} ${LIB_NEURUN_BACKEND_ACL_COMMON}) diff --git a/runtimes/neurun/backend/acl_cl/kernel/CMakeLists.txt b/runtimes/neurun/backend/acl_cl/kernel/CMakeLists.txt deleted file mode 100644 index 1dbeba3..0000000 --- a/runtimes/neurun/backend/acl_cl/kernel/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Unsupported architecture -nnfw_find_package(ARMCompute QUIET) -if(NOT ARMCompute_FOUND) - return() -endif(NOT ARMCompute_FOUND) - -file(GLOB SOURCES "*.cc") - -add_library(${LIB_NEURUN_KERNEL_ACL_CL} STATIC ${SOURCES}) - -target_include_directories(${LIB_NEURUN_KERNEL_ACL_CL} PUBLIC ${NEURUN_INCLUDE_DIR}) -target_include_directories(${LIB_NEURUN_KERNEL_ACL_CL} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) -target_include_directories(${LIB_NEURUN_KERNEL_ACL_CL} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../..) - -target_link_libraries(${LIB_NEURUN_KERNEL_ACL_CL} arm_compute) -target_link_libraries(${LIB_NEURUN_KERNEL_ACL_CL} ${LIB_NEURUN_BACKEND_ACL_COMMON}) - -set_target_properties(${LIB_NEURUN_KERNEL_ACL_CL} PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(${LIB_NEURUN_KERNEL_ACL_CL} PROPERTIES OUTPUT_NAME kernel_acl_cl) diff --git a/runtimes/neurun/backend/acl_cl/kernel/ConcatLayer.cc b/runtimes/neurun/backend/acl_cl/kernel/ConcatLayer.cc index fee3272..04388ce 100644 --- a/runtimes/neurun/backend/acl_cl/kernel/ConcatLayer.cc +++ b/runtimes/neurun/backend/acl_cl/kernel/ConcatLayer.cc @@ -25,8 +25,9 @@ namespace { -bool matchSizeExceptAxis(const ::neurun::backend::acl_cl::operand::ICLTensor *t1, - const ::neurun::backend::acl_cl::operand::ICLTensor *t2, uint32_t axis) +inline bool matchSizeExceptAxis(const ::neurun::backend::acl_cl::operand::ICLTensor *t1, + const ::neurun::backend::acl_cl::operand::ICLTensor *t2, + uint32_t axis) { assert(t1->num_dimensions() <= 4); assert(t2->num_dimensions() <= 4); @@ -82,8 +83,6 @@ template bool ConcatLayer::concatenate() { uint32_t axis_offset = 0; - auto &queue = ::arm_compute::CLScheduler::get().queue(); - auto outout_fn = [&](::neurun::backend::operand::ITensor &out_tensor) { for (auto input : _input_allocs) { @@ -92,13 +91,13 @@ template bool ConcatLayer::concatenate() auto input_fn = [&](::neurun::backend::operand::ITensor &in_tensor) { auto &in_cl_tensor = static_cast<::neurun::backend::acl_cl::operand::ICLTensor &>(in_tensor); - for (int32_t i = 0; i < in_cl_tensor.info()->dimension(0); i++) + for (uint32_t i = 0; i < in_cl_tensor.info()->dimension(0); i++) { - for (int32_t j = 0; j < in_cl_tensor.info()->dimension(1); j++) + for (uint32_t j = 0; j < in_cl_tensor.info()->dimension(1); j++) { - for (int32_t k = 0; k < in_cl_tensor.info()->dimension(2); k++) + for (uint32_t k = 0; k < in_cl_tensor.info()->dimension(2); k++) { - for (int32_t l = 0; l < in_cl_tensor.info()->dimension(3); l++) + for (uint32_t l = 0; l < in_cl_tensor.info()->dimension(3); l++) { int32_t io = (_axis == 0) ? axis_offset : 0; int32_t jo = (_axis == 1) ? axis_offset : 0; diff --git a/runtimes/neurun/backend/acl_neon/CMakeLists.txt b/runtimes/neurun/backend/acl_neon/CMakeLists.txt index 8b1ae5d..0ffcc6b 100644 --- a/runtimes/neurun/backend/acl_neon/CMakeLists.txt +++ b/runtimes/neurun/backend/acl_neon/CMakeLists.txt @@ -5,24 +5,18 @@ if(NOT ARMCompute_FOUND) endif(NOT ARMCompute_FOUND) set(LIB_NEURUN_BACKEND_ACL_NEON neurun_backend_acl_neon) -set(LIB_NEURUN_KERNEL_ACL_NEON neurun_kernel_acl_neon) -add_subdirectory(kernel) file(GLOB_RECURSE SOURCES "*.cc") -file(GLOB_RECURSE REMOVE_KERNEL_SOURCES "kernel/*.cc") -list(REMOVE_ITEM SOURCES ${REMOVE_KERNEL_SOURCES}) - add_library(${LIB_NEURUN_BACKEND_ACL_NEON} SHARED ${SOURCES}) target_include_directories(${LIB_NEURUN_BACKEND_ACL_NEON} PUBLIC ${NEURUN_INCLUDE_DIR}) target_include_directories(${LIB_NEURUN_BACKEND_ACL_NEON} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) #following line it to reuse codes of other backends -target_include_directories(${LIB_NEURUN_KERNEL_ACL_NEON} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..) +target_include_directories(${LIB_NEURUN_BACKEND_ACL_NEON} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_NEON} arm_compute) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_NEON} arm_compute_ex) -target_link_libraries(${LIB_NEURUN_BACKEND_ACL_NEON} ${LIB_NEURUN_KERNEL_ACL_NEON}) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_NEON} neurun-core) target_link_libraries(${LIB_NEURUN_BACKEND_ACL_NEON} ${LIB_NEURUN_BACKEND_ACL_COMMON}) diff --git a/runtimes/neurun/backend/acl_neon/kernel/CMakeLists.txt b/runtimes/neurun/backend/acl_neon/kernel/CMakeLists.txt deleted file mode 100644 index 3944436..0000000 --- a/runtimes/neurun/backend/acl_neon/kernel/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Unsupported architecture -nnfw_find_package(ARMCompute QUIET) -if(NOT ARMCompute_FOUND) - return() -endif(NOT ARMCompute_FOUND) - -file(GLOB SOURCES "*.cc") - -add_library(${LIB_NEURUN_KERNEL_ACL_NEON} STATIC ${SOURCES}) - -target_include_directories(${LIB_NEURUN_KERNEL_ACL_NEON} PUBLIC ${NEURUN_INCLUDE_DIR}) -target_include_directories(${LIB_NEURUN_KERNEL_ACL_NEON} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) -#following line it to reuse codes of other backends -target_include_directories(${LIB_NEURUN_KERNEL_ACL_NEON} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../..) - -target_link_libraries(${LIB_NEURUN_KERNEL_ACL_NEON} arm_compute) -target_link_libraries(${LIB_NEURUN_KERNEL_ACL_NEON} ${LIB_NEURUN_BACKEND_ACL_COMMON}) - -set_target_properties(${LIB_NEURUN_KERNEL_ACL_NEON} PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(${LIB_NEURUN_KERNEL_ACL_NEON} PROPERTIES OUTPUT_NAME kernel_acl_neon) diff --git a/runtimes/neurun/backend/acl_neon/kernel/ConcatLayer.cc b/runtimes/neurun/backend/acl_neon/kernel/ConcatLayer.cc index 8d73980..49ffa7b 100644 --- a/runtimes/neurun/backend/acl_neon/kernel/ConcatLayer.cc +++ b/runtimes/neurun/backend/acl_neon/kernel/ConcatLayer.cc @@ -23,8 +23,9 @@ namespace { -bool matchSizeExceptAxis(const ::neurun::backend::acl_neon::operand::INETensor *t1, - const ::neurun::backend::acl_neon::operand::INETensor *t2, uint32_t axis) +inline bool matchSizeExceptAxis(const ::neurun::backend::acl_neon::operand::INETensor *t1, + const ::neurun::backend::acl_neon::operand::INETensor *t2, + uint32_t axis) { assert(t1->num_dimensions() <= 4); assert(t2->num_dimensions() <= 4); @@ -84,13 +85,13 @@ template bool ConcatLayer::concatenate() for (auto input : _input_allocs) { - for (int32_t i = 0; i < input->info()->dimension(0); i++) + for (uint32_t i = 0; i < input->info()->dimension(0); i++) { - for (int32_t j = 0; j < input->info()->dimension(1); j++) + for (uint32_t j = 0; j < input->info()->dimension(1); j++) { - for (int32_t k = 0; k < input->info()->dimension(2); k++) + for (uint32_t k = 0; k < input->info()->dimension(2); k++) { - for (int32_t l = 0; l < input->info()->dimension(3); l++) + for (uint32_t l = 0; l < input->info()->dimension(3); l++) { uint32_t io = (_axis == 0) ? axis_offset : 0; uint32_t jo = (_axis == 1) ? axis_offset : 0; diff --git a/runtimes/neurun/backend/cpu/CMakeLists.txt b/runtimes/neurun/backend/cpu/CMakeLists.txt index fb75d6e..029fd03 100644 --- a/runtimes/neurun/backend/cpu/CMakeLists.txt +++ b/runtimes/neurun/backend/cpu/CMakeLists.txt @@ -1,19 +1,12 @@ set(LIB_NEURUN_BACKEND_CPU neurun_backend_cpu) -set(LIB_NEURUN_KERNEL_CPU neurun_kernel_cpu) - -add_subdirectory(kernel) file(GLOB_RECURSE SOURCES "*.cc") -file(GLOB_RECURSE REMOVE_KERNEL_SOURCES "kernel/*.cc") file(GLOB_RECURSE TESTS "*.test.cc") -list(REMOVE_ITEM SOURCES ${REMOVE_KERNEL_SOURCES}) list(REMOVE_ITEM SOURCES ${TESTS}) add_library(${LIB_NEURUN_BACKEND_CPU} SHARED ${SOURCES}) -target_link_libraries(${LIB_NEURUN_BACKEND_CPU} nnfw_lib_misc) -target_link_libraries(${LIB_NEURUN_BACKEND_CPU} nnfw_lib_cpp14) -target_link_libraries(${LIB_NEURUN_BACKEND_CPU} ${LIB_NEURUN_KERNEL_CPU}) +target_link_libraries(${LIB_NEURUN_BACKEND_CPU} nnfw_lib_misc nnfw_lib_cpp14 nnfw_lib_cker) target_link_libraries(${LIB_NEURUN_BACKEND_CPU} neurun-core) target_compile_options(${LIB_NEURUN_BACKEND_CPU} PRIVATE -Wall -Wextra -Werror) diff --git a/runtimes/neurun/backend/cpu/kernel/AddLayer.cc b/runtimes/neurun/backend/cpu/kernel/AddLayer.cc index 56ad6b6..14e2afe 100644 --- a/runtimes/neurun/backend/cpu/kernel/AddLayer.cc +++ b/runtimes/neurun/backend/cpu/kernel/AddLayer.cc @@ -47,9 +47,9 @@ void AddLayer::addQuant8() int32_t output_activation_min, output_activation_max; CalculateActivationRangeUint8(_activation, _outputShape, &output_activation_min, &output_activation_max); - nnfw::cker::AddParam op_params; - op_params.quantized_activation_max = output_activation_max; - op_params.quantized_activation_min = output_activation_min; + // nnfw::cker::AddParam op_params; + // op_params.quantized_activation_max = output_activation_max; + // op_params.quantized_activation_min = output_activation_min; // cker quant8 add is not implemented yet throw std::runtime_error{"NYI"}; diff --git a/runtimes/neurun/backend/cpu/kernel/CMakeLists.txt b/runtimes/neurun/backend/cpu/kernel/CMakeLists.txt deleted file mode 100644 index fa95817..0000000 --- a/runtimes/neurun/backend/cpu/kernel/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -file(GLOB SOURCES "*.cc") - -add_library(${LIB_NEURUN_KERNEL_CPU} STATIC ${SOURCES}) - -target_include_directories(${LIB_NEURUN_KERNEL_CPU} PUBLIC ${NEURUN_INCLUDE_DIR}) - -target_link_libraries(${LIB_NEURUN_KERNEL_CPU} nnfw_lib_misc nnfw_lib_cpp14 nnfw_lib_cker) - -set_target_properties(${LIB_NEURUN_KERNEL_CPU} PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(${LIB_NEURUN_KERNEL_CPU} PROPERTIES OUTPUT_NAME kernel_cpu) diff --git a/runtimes/neurun/backend/cpu/kernel/ConcatLayer.cc b/runtimes/neurun/backend/cpu/kernel/ConcatLayer.cc index 1dac452..c390436 100644 --- a/runtimes/neurun/backend/cpu/kernel/ConcatLayer.cc +++ b/runtimes/neurun/backend/cpu/kernel/ConcatLayer.cc @@ -68,7 +68,7 @@ void ConcatLayer::concatenationFloat32() } void ConcatLayer::concatenationQuant8() { - int num_inputs = _inputShapes.size(); + uint32_t num_inputs = _inputShapes.size(); std::vector input_zeropoints(num_inputs); std::vector input_scales(num_inputs); diff --git a/runtimes/neurun/backend/cpu/kernel/OperationUtils.cc b/runtimes/neurun/backend/cpu/kernel/OperationUtils.cc index 7de047e..d30eb00 100644 --- a/runtimes/neurun/backend/cpu/kernel/OperationUtils.cc +++ b/runtimes/neurun/backend/cpu/kernel/OperationUtils.cc @@ -80,6 +80,7 @@ void GetQuantizedConvolutionMultiplier(const Shape &inputShape, const Shape &fil const float bias_scale = biasShape.scale; const float output_scale = outputShape.scale; // The following conditions must be guaranteed by the training pipeline. + UNUSED_RELEASE(bias_scale); assert(std::abs(input_product_scale - bias_scale) <= 1e-6 * std::min(input_product_scale, bias_scale)); assert(input_product_scale >= 0); diff --git a/runtimes/neurun/backend/cpu/kernel/PermuteLayer.h b/runtimes/neurun/backend/cpu/kernel/PermuteLayer.h index e3c3522..a3cca0c 100644 --- a/runtimes/neurun/backend/cpu/kernel/PermuteLayer.h +++ b/runtimes/neurun/backend/cpu/kernel/PermuteLayer.h @@ -61,7 +61,6 @@ private: auto rank = _output_shape.rank(); auto fn = [&](::neurun::backend::operand::ITensor &in_tensor) { _output->access([&](::neurun::backend::operand::ITensor &out_tensor) { - auto layout = out_tensor.layout(); auto input_buffer = in_tensor.buffer(); auto input_size = in_tensor.total_size(); auto output_buffer = out_tensor.buffer(); diff --git a/runtimes/neurun/backend/hi_perf_cpu/CMakeLists.txt b/runtimes/neurun/backend/hi_perf_cpu/CMakeLists.txt index f30ef8c..af27d85 100644 --- a/runtimes/neurun/backend/hi_perf_cpu/CMakeLists.txt +++ b/runtimes/neurun/backend/hi_perf_cpu/CMakeLists.txt @@ -13,19 +13,14 @@ if(NOT BUILD_NEURUN_HI_PERF_CPU_BACKEND) return() endif(NOT BUILD_NEURUN_HI_PERF_CPU_BACKEND) -add_subdirectory(kernel) - file(GLOB_RECURSE SOURCES "*.cc") -file(GLOB_RECURSE REMOVE_KERNEL_SOURCES "kernel/*.cc") file(GLOB_RECURSE TESTS "*.test.cc") -#list(REMOVE_ITEM SOURCES ${REMOVE_KERNEL_SOURCES}) list(REMOVE_ITEM SOURCES ${TESTS}) add_library(${LIB_NEURUN_BACKEND_HI_PERF_CPU} SHARED ${SOURCES}) target_link_libraries(${LIB_NEURUN_BACKEND_HI_PERF_CPU} nnfw_lib_misc) target_link_libraries(${LIB_NEURUN_BACKEND_HI_PERF_CPU} nnfw_lib_cpp14) -target_link_libraries(${LIB_NEURUN_BACKEND_HI_PERF_CPU} ${LIB_NEURUN_KERNEL_NNPACK}) target_link_libraries(${LIB_NEURUN_BACKEND_HI_PERF_CPU} neurun-core) target_compile_options(${LIB_NEURUN_BACKEND_HI_PERF_CPU} PRIVATE -Wall -Wextra -Werror) diff --git a/runtimes/neurun/backend/hi_perf_cpu/kernel/CMakeLists.txt b/runtimes/neurun/backend/hi_perf_cpu/kernel/CMakeLists.txt deleted file mode 100644 index c643e26..0000000 --- a/runtimes/neurun/backend/hi_perf_cpu/kernel/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -return()