From b8401f2bb931bca1df3b5a94b1a98caf2c4baa5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=84=B8=ED=9D=AC/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Principal=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 29 Mar 2018 08:48:24 +0900 Subject: [PATCH] Fix bindacl, convacl experiment to use environment (#280) This will fix bindacl and convacl expierment to use envionment variable to choose NEON/OpenCL And also remove alc's utils methods Signed-off-by: SaeHie Park --- experiments/bindacl/CMakeLists.txt | 9 ++++----- experiments/bindacl/src/nnapi_acl.cc | 11 ++++------- experiments/convacl/CMakeLists.txt | 9 ++++----- experiments/convacl/src/nnapi_acl_conv.cc | 16 ++++++---------- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/experiments/bindacl/CMakeLists.txt b/experiments/bindacl/CMakeLists.txt index d553352..3aade70 100644 --- a/experiments/bindacl/CMakeLists.txt +++ b/experiments/bindacl/CMakeLists.txt @@ -1,15 +1,13 @@ file(GLOB_RECURSE NNAPI_BINDACL_SRCS "src/*.cc") +set(NNFW_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) + # TODO: fix nnapi.h location set(NNAPI_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/tools/nnapi_bindings/include) # TODO: fix acl location set(ACL_DIR ${CMAKE_SOURCE_DIR}/externals/acl) -# These are not included in arm_compute libraries so add here -set(ACL_GRAPH_UTILS_SRCS ${ACL_DIR}/utils/GraphUtils.cpp - ${ACL_DIR}/utils/Utils.cpp) - set(ACL_INCLUDES ${ACL_DIR} ${ACL_DIR}/include) set(ACL_LIBS arm_compute_graph arm_compute arm_compute_core) @@ -19,8 +17,9 @@ link_directories(${CMAKE_INSTALL_PREFIX}/lib) add_library(exp_bindacl SHARED ${NNAPI_BINDACL_SRCS} ${ACL_GRAPH_UTILS_SRCS}) target_include_directories(exp_bindacl PUBLIC ${NNAPI_INCLUDE_DIR} + ${NNFW_INCLUDE_DIR} ${ACL_INCLUDES}) -target_link_libraries(exp_bindacl ${ACL_LIBS}) +target_link_libraries(exp_bindacl nnfw_util ${ACL_LIBS}) # we need the library name to be 'neuralnetworks' and this will do the trick set_target_properties(exp_bindacl PROPERTIES OUTPUT_NAME neuralnetworks) diff --git a/experiments/bindacl/src/nnapi_acl.cc b/experiments/bindacl/src/nnapi_acl.cc index eaa1243..599da08 100644 --- a/experiments/bindacl/src/nnapi_acl.cc +++ b/experiments/bindacl/src/nnapi_acl.cc @@ -9,8 +9,8 @@ // ACL Headers #include #include -#include -#include + +#include "util/environment.h" // // Asynchronous Event @@ -183,11 +183,8 @@ ResultCode ANeuralNetworksExecution_create(ANeuralNetworksCompilation* compilati ANeuralNetworksExecution* execlocal = *execution; arm_compute::graph::Graph& graph = execlocal->graph; - TargetHint target_hint; - - // 0 = NEON, 1 = OpenCL - // arm_compute::graph_utils can't be used with 'using' - target_hint = arm_compute::graph_utils::set_target_hint(1); + TargetHint target_hint = nnfw::util::get_env_int("NNFW_ACL_USEOPENCL") + ? TargetHint::OPENCL : TargetHint::NEON; graph << target_hint << Tensor(TensorInfo(TensorShape(224U, 224U, 3U, 1U), 1, DataType::F32), diff --git a/experiments/convacl/CMakeLists.txt b/experiments/convacl/CMakeLists.txt index 2ec0820..f7d7198 100644 --- a/experiments/convacl/CMakeLists.txt +++ b/experiments/convacl/CMakeLists.txt @@ -1,15 +1,13 @@ file(GLOB_RECURSE NNAPI_CONVACL_SRCS "src/*.cc") +set(NNFW_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) + # TODO: fix nnapi.h location set(NNAPI_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/tools/nnapi_bindings/include) # TODO: fix acl location set(ACL_DIR ${CMAKE_SOURCE_DIR}/externals/acl) -# These are not included in arm_compute libraries so add here -set(ACL_GRAPH_UTILS_SRCS ${ACL_DIR}/utils/GraphUtils.cpp - ${ACL_DIR}/utils/Utils.cpp) - set(ACL_INCLUDES ${ACL_DIR} ${ACL_DIR}/include) set(ACL_LIBS arm_compute_graph arm_compute arm_compute_core) @@ -19,8 +17,9 @@ link_directories(${CMAKE_INSTALL_PREFIX}/lib) add_library(exp_convacl SHARED ${NNAPI_CONVACL_SRCS} ${ACL_GRAPH_UTILS_SRCS}) target_include_directories(exp_convacl PUBLIC ${NNAPI_INCLUDE_DIR} + ${NNFW_INCLUDE_DIR} ${ACL_INCLUDES}) -target_link_libraries(exp_convacl ${ACL_LIBS}) +target_link_libraries(exp_convacl nnfw_util ${ACL_LIBS}) # we need the library name to be 'neuralnetworks' and this will do the trick set_target_properties(exp_convacl PROPERTIES OUTPUT_NAME neuralnetworks) diff --git a/experiments/convacl/src/nnapi_acl_conv.cc b/experiments/convacl/src/nnapi_acl_conv.cc index 0085477..fff1f3b 100644 --- a/experiments/convacl/src/nnapi_acl_conv.cc +++ b/experiments/convacl/src/nnapi_acl_conv.cc @@ -9,9 +9,8 @@ // ACL Headers #include #include -#include -#include +#include "util/environment.h" #include "io_accessor.h" // @@ -155,19 +154,16 @@ ResultCode ANeuralNetworksExecution_create(ANeuralNetworksCompilation* compilati ANeuralNetworksExecution* execlocal = *execution; arm_compute::graph::Graph& graph = execlocal->graph; - TargetHint target_hint; - - // 0 = NEON, 1 = OpenCL - // arm_compute::graph_utils can't be used with 'using' - // TODO: set NEON/OpenCL hint by Environment variable - target_hint = arm_compute::graph_utils::set_target_hint(1); + TargetHint target_hint = nnfw::util::get_env_int("NNFW_ACL_USEOPENCL") + ? TargetHint::OPENCL : TargetHint::NEON; + bool autoinc = nnfw::util::get_env_bool("NNFW_TEST_AUTOINC"); graph << target_hint << Tensor(TensorInfo(TensorShape(3U, 3U, 1U, 1U), 1, DataType::F32), - std::unique_ptr(new InputAccessor(true))) + std::unique_ptr(new InputAccessor(autoinc))) << arm_compute::graph::ConvolutionLayer( 3U, 3U, 1U, - std::unique_ptr(new WeightAccessor(true)), + std::unique_ptr(new WeightAccessor(autoinc)), std::unique_ptr(new BiasAccessor()), arm_compute::PadStrideInfo(1, 1, 0, 0)) << Tensor( -- 2.7.4