# 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)
+
+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})
-target_include_directories(exp_bindacl PUBLIC ${NNAPI_INCLUDE_DIR})
+target_include_directories(exp_bindacl PUBLIC ${NNAPI_INCLUDE_DIR}
+ ${ACL_INCLUDES})
+target_link_libraries(exp_bindacl ${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)
#include <map>
#include <cassert>
#include <boost/format.hpp>
+// ACL Headers
+#include <arm_compute/graph/Graph.h>
+#include <utils/GraphUtils.h>
+#include <utils/Utils.h>
//
// Asynchronous Event
struct ANeuralNetworksExecution
{
// ANeuralNetworksExecution corresponds to NPU::Interp::Session
+
+ arm_compute::graph::Graph graph;
};
ResultCode ANeuralNetworksExecution_create(ANeuralNetworksCompilation* compilation, ANeuralNetworksExecution** execution)
{
+ std::cout << __FUNCTION__ << " +++" << std::endl;
*execution = new ANeuralNetworksExecution;
+
+ using arm_compute::DataType;
+ using arm_compute::graph::Tensor;
+ using arm_compute::graph::TargetHint;
+ using arm_compute::graph::Graph;
+ using arm_compute::TensorInfo;
+ using arm_compute::TensorShape;
+
+ ANeuralNetworksExecution* execlocal = *execution;
+ 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
+ ;
+
+ std::cout << __FUNCTION__ << " ---" << std::endl;
return ANEURALNETWORKS_NO_ERROR;
}
ResultCode ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution* execution, ANeuralNetworksEvent** event)
{
+ 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;
}