Fix bindacl experiment to run with acl graph layer
authorSaeHie Park <saehie.park@samsung.com>
Fri, 23 Mar 2018 00:52:47 +0000 (09:52 +0900)
committer박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Fri, 23 Mar 2018 01:37:26 +0000 (10:37 +0900)
This will fix bindacl failure and run with one SoftMaxLayer in the network

experiments/bindacl/CMakeLists.txt
experiments/bindacl/src/nnapi_acl.cc

index 6943137..d553352 100644 (file)
@@ -6,13 +6,18 @@ 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)
 
 link_directories(${CMAKE_INSTALL_PREFIX}/lib)
 
-add_library(exp_bindacl SHARED ${NNAPI_BINDACL_SRCS})
+add_library(exp_bindacl SHARED ${NNAPI_BINDACL_SRCS}
+                               ${ACL_GRAPH_UTILS_SRCS})
 target_include_directories(exp_bindacl PUBLIC ${NNAPI_INCLUDE_DIR}
                                               ${ACL_INCLUDES})
 target_link_libraries(exp_bindacl ${ACL_LIBS})
index 24a8bad..12731e3 100644 (file)
@@ -7,6 +7,7 @@
 #include <boost/format.hpp>
 // ACL Headers
 #include <arm_compute/graph/Graph.h>
+#include <arm_compute/graph/Nodes.h>
 #include <utils/GraphUtils.h>
 #include <utils/Utils.h>
 
@@ -152,24 +153,21 @@ ResultCode ANeuralNetworksExecution_create(ANeuralNetworksCompilation* compilati
   arm_compute::graph::Graph& graph = execlocal->graph;
 
   TargetHint target_hint;
-#if 0
   std::string image;
   std::string label;
   constexpr float mean_r = 122.68f; // Mean value to subtract from red channel
   constexpr float mean_g = 116.67f; // Mean value to subtract from green channel
   constexpr float mean_b = 104.01f; // Mean value to subtract from blue channel
-#endif
 
   // 0 = NEON, 1 = OpenCL
   // arm_compute::graph_utils can't be used with 'using'
   target_hint = arm_compute::graph_utils::set_target_hint(1);
 
   graph << target_hint
-#if 0
-  // TODO: fix load library fail when get_input_accessor() is used
         << Tensor(TensorInfo(TensorShape(224U, 224U, 3U, 1U), 1, DataType::F32),
                   arm_compute::graph_utils::get_input_accessor(image, mean_r, mean_g, mean_b))
-#endif
+        << arm_compute::graph::SoftmaxLayer()
+        << Tensor(arm_compute::graph_utils::get_output_accessor(label, 5));
         ;
 
   std::cout << __FUNCTION__ << " ---" << std::endl;
@@ -192,12 +190,10 @@ ResultCode ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution* execu
   std::cout << __FUNCTION__ << " +++" << std::endl;
   *event = new ANeuralNetworksEvent;
 
-#if 0
   // graph.run() fails with segment fail when only target_hint is added.
   // after fix adding 'Tensor' we may call graph.run()
   arm_compute::graph::Graph& graph = execution->graph;
   graph.run();
-#endif
 
   std::cout << __FUNCTION__ << " ---" << std::endl;
   return ANEURALNETWORKS_NO_ERROR;