From: 오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Wed, 7 Nov 2018 07:17:33 +0000 (+0900) Subject: Introduce subtensor map (#3493) X-Git-Tag: 0.3~457 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b040c793f0696c461e00afaa1a42d40cd60de71;p=platform%2Fcore%2Fml%2Fnnfw.git Introduce subtensor map (#3493) - Introduce subtensor map in ACL tensor builder - TensorBuilder::at() and TensorBuilder::tensorAt() can return subtensor Signed-off-by: Hyeongseok Oh --- 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