From 3b040c793f0696c461e00afaa1a42d40cd60de71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Wed, 7 Nov 2018 16:17:33 +0900 Subject: [PATCH] Introduce subtensor map (#3493) - Introduce subtensor map in ACL tensor builder - TensorBuilder::at() and TensorBuilder::tensorAt() can return subtensor Signed-off-by: Hyeongseok Oh --- .../neurun/src/backend/acl_cl/TensorBuilder.cc | 22 +++++++++++++++++++--- runtimes/neurun/src/backend/acl_cl/TensorBuilder.h | 5 ++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc index 4ad7c36..ec717b8 100644 --- a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc +++ b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc @@ -66,7 +66,9 @@ void TensorBuilder::prepare(void) // TODO Handle SubTensor(subsumption) // Currently this TensorBuilder does not have subsumption info yet + // Allocated subtensor will be mapped to _subtensors instead of _tensors assert(_subtensor_info_map.size() == 0); + assert(_subtensors.size() == 0); for (auto &entry : _tensor_info_map) { @@ -91,7 +93,14 @@ void TensorBuilder::allocate(void) std::shared_ptr<::arm_compute::ITensor> TensorBuilder::tensorAt(const graph::operand::Index &ind) { - return _tensors.at(ind); + if (_tensors.find(ind) != _tensors.end()) + { + return _tensors.at(ind); + } + else + { + return _subtensors.at(ind); + } } std::shared_ptr @@ -108,10 +117,17 @@ void TensorBuilder::iterate(const IterateFunction &fn) } } -std::shared_ptr<::arm_compute::CLTensor> +std::shared_ptr<::arm_compute::ICLTensor> TensorBuilder::at(const ::neurun::graph::operand::Index &ind) { - return _tensors.at(ind); + if (_tensors.find(ind) != _tensors.end()) + { + return _tensors.at(ind); + } + else + { + return _subtensors.at(ind); + } } } // namespace acl_cl diff --git a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h index 307e827..12bb6ed 100644 --- a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h +++ b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h @@ -22,6 +22,7 @@ #include #include +#include namespace neurun { @@ -62,12 +63,14 @@ public: wrapTensor(const graph::operand::Index &ind) override; virtual void iterate(const IterateFunction &fn) override; - std::shared_ptr<::arm_compute::CLTensor> at(const ::neurun::graph::operand::Index &ind); + std::shared_ptr<::arm_compute::ICLTensor> at(const ::neurun::graph::operand::Index &ind); private: std::unordered_map _tensor_info_map; std::unordered_map _subtensor_info_map; std::unordered_map> _tensors; + std::unordered_map> + _subtensors; }; } // namespace acl_cl -- 2.7.4