[Pure ACL] Pass NNAPI model to execution (#544)
author박종현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 11 Apr 2018 01:31:23 +0000 (10:31 +0900)
committer김정현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh0822.kim@samsung.com>
Wed, 11 Apr 2018 01:31:23 +0000 (10:31 +0900)
The following functions need to access model information through
ANeuralNetworksExecution object:
 - ANeuralNetworksExecution_setInput
 - ANeuralNetworksExecution_setOutput

This commit renames class Model in internal::arm_compute namespace as
Plan, revises it to include a reference to NNAPI model.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
tools/nnapi_bindings/bindings/pure_arm_compute/src/compilation.h
tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.cc
tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.h
tools/nnapi_bindings/bindings/pure_arm_compute/src/internal/arm_compute.h

index 3f48a50..72b2b13 100644 (file)
@@ -8,24 +8,22 @@ struct ANeuralNetworksCompilation
 {
 public:
   ANeuralNetworksCompilation(const std::shared_ptr<const internal::tflite::Model> &model)
-    : _model{model}, _output{new internal::arm_compute::Model}
+    : _plan{new internal::arm_compute::Plan{model}}
   {
     // DO NOTHING
   }
 
 public:
-  const internal::tflite::Model &model(void) const { return *_model; }
-  internal::arm_compute::Model &output(void) { return *_output; }
+  internal::arm_compute::Plan &plan(void) { return *_plan; }
 
 public:
-  void publish(std::shared_ptr<const internal::arm_compute::Model> &output)
+  void publish(std::shared_ptr<const internal::arm_compute::Plan> &plan)
   {
-    output = _output;
+    plan = _plan;
   }
 
 private:
-  std::shared_ptr<const internal::tflite::Model> _model;
-  std::shared_ptr<internal::arm_compute::Model> _output;
+  std::shared_ptr<internal::arm_compute::Plan> _plan;
 };
 
 #endif
index cae7015..131afad 100644 (file)
@@ -8,11 +8,11 @@
 ResultCode
 ANeuralNetworksExecution_create(ANeuralNetworksCompilation* compilation, ANeuralNetworksExecution** execution)
 {
-  std::shared_ptr<const ::internal::arm_compute::Model> model;
+  std::shared_ptr<const ::internal::arm_compute::Plan> plan;
 
-  compilation->publish(model);
+  compilation->publish(plan);
 
-  *execution = new ANeuralNetworksExecution{model};
+  *execution = new ANeuralNetworksExecution{plan};
 
   return ANEURALNETWORKS_NO_ERROR;
 }
@@ -38,7 +38,7 @@ ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution* execution, ANeur
 {
   assert(execution != nullptr);
 
-  const auto &operations = execution->model().operations();
+  const auto &operations = execution->plan().operations();
 
   for (uint32_t n = 0; n < operations.size(); ++n)
   {
index ecc6ff9..7ac80ca 100644 (file)
@@ -6,17 +6,17 @@
 struct ANeuralNetworksExecution
 {
 public:
-  ANeuralNetworksExecution(const std::shared_ptr<const internal::arm_compute::Model> &model)
-    : _model{model}
+  ANeuralNetworksExecution(const std::shared_ptr<const internal::arm_compute::Plan> &plan)
+    : _plan{plan}
   {
     // DO NOTHING
   }
 
 public:
-  const internal::arm_compute::Model &model(void) const { return *_model; }
+  const internal::arm_compute::Plan &plan(void) const { return *_plan; }
 
 private:
-  std::shared_ptr<const internal::arm_compute::Model> _model;
+  std::shared_ptr<const internal::arm_compute::Plan> _plan;
 };
 
 #endif
index 6e2467d..24837a6 100644 (file)
@@ -101,9 +101,18 @@ namespace internal
 namespace arm_compute
 {
 
-class Model
+class Plan
 {
 public:
+  Plan(const std::shared_ptr<const ::internal::tflite::Model> &model) : _model(model)
+  {
+    // DO NOTHING
+  }
+
+public:
+  const ::internal::tflite::Model &model(void) const { return *_model; }
+
+public:
   operand::Context &operands(void) { return _operands; }
   const operand::Context &operands(void) const { return _operands; }
 
@@ -112,6 +121,7 @@ public:
   const op::Sequence &operations(void) const { return _ops; }
 
 private:
+  std::shared_ptr<const ::internal::tflite::Model> _model;
   operand::Context _operands;
   op::Sequence _ops;