From abcdea70828f2766df2a1af34dd2eff48c0c6e84 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Wed, 11 Apr 2018 10:31:23 +0900 Subject: [PATCH] [Pure ACL] Pass NNAPI model to execution (#544) 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 --- .../bindings/pure_arm_compute/src/compilation.h | 12 +++++------- .../bindings/pure_arm_compute/src/execution.cc | 8 ++++---- .../nnapi_bindings/bindings/pure_arm_compute/src/execution.h | 8 ++++---- .../bindings/pure_arm_compute/src/internal/arm_compute.h | 12 +++++++++++- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/tools/nnapi_bindings/bindings/pure_arm_compute/src/compilation.h b/tools/nnapi_bindings/bindings/pure_arm_compute/src/compilation.h index 3f48a507..72b2b13 100644 --- a/tools/nnapi_bindings/bindings/pure_arm_compute/src/compilation.h +++ b/tools/nnapi_bindings/bindings/pure_arm_compute/src/compilation.h @@ -8,24 +8,22 @@ struct ANeuralNetworksCompilation { public: ANeuralNetworksCompilation(const std::shared_ptr &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 &output) + void publish(std::shared_ptr &plan) { - output = _output; + plan = _plan; } private: - std::shared_ptr _model; - std::shared_ptr _output; + std::shared_ptr _plan; }; #endif diff --git a/tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.cc b/tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.cc index cae7015..131afad 100644 --- a/tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.cc +++ b/tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.cc @@ -8,11 +8,11 @@ ResultCode ANeuralNetworksExecution_create(ANeuralNetworksCompilation* compilation, ANeuralNetworksExecution** execution) { - std::shared_ptr model; + std::shared_ptr 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) { diff --git a/tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.h b/tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.h index ecc6ff9..7ac80ca 100644 --- a/tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.h +++ b/tools/nnapi_bindings/bindings/pure_arm_compute/src/execution.h @@ -6,17 +6,17 @@ struct ANeuralNetworksExecution { public: - ANeuralNetworksExecution(const std::shared_ptr &model) - : _model{model} + ANeuralNetworksExecution(const std::shared_ptr &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 _model; + std::shared_ptr _plan; }; #endif diff --git a/tools/nnapi_bindings/bindings/pure_arm_compute/src/internal/arm_compute.h b/tools/nnapi_bindings/bindings/pure_arm_compute/src/internal/arm_compute.h index 6e2467d..24837a6 100644 --- a/tools/nnapi_bindings/bindings/pure_arm_compute/src/internal/arm_compute.h +++ b/tools/nnapi_bindings/bindings/pure_arm_compute/src/internal/arm_compute.h @@ -101,9 +101,18 @@ namespace internal namespace arm_compute { -class Model +class Plan { public: + Plan(const std::shared_ptr &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 _model; operand::Context _operands; op::Sequence _ops; -- 2.7.4