From b7b8e5eb48f3169e1aa09f82772cb4394b46e13a 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: Thu, 8 Nov 2018 10:10:32 +0900 Subject: [PATCH] Introduce subtensor allocation check API (#3510) Check API will be used in codegen Signed-off-by: Hyeongseok Oh --- runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc | 21 +++++++++++++++++++++ runtimes/neurun/src/backend/acl_cl/TensorBuilder.h | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc index ec717b8..e5fe4b7 100644 --- a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc +++ b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.cc @@ -130,6 +130,27 @@ TensorBuilder::at(const ::neurun::graph::operand::Index &ind) } } +bool TensorBuilder::isSubTensorOf(const graph::operand::Index &parent, + const graph::operand::Index &child) +{ + if (_subtensor_info_map.find(child) == _subtensor_info_map.end()) + { + return false; + } + + if (_subtensors.find(child) == _subtensors.end()) + { + return false; + } + + if (_subtensor_info_map.at(child).parent() != parent) + { + return false; + } + + return true; +} + } // namespace acl_cl } // namespace backend } // namespace neurun diff --git a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h index 12bb6ed..e7ae3b3 100644 --- a/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h +++ b/runtimes/neurun/src/backend/acl_cl/TensorBuilder.h @@ -64,6 +64,13 @@ public: virtual void iterate(const IterateFunction &fn) override; std::shared_ptr<::arm_compute::ICLTensor> at(const ::neurun::graph::operand::Index &ind); + /** + * @brief Check child tensor is allocated as subtensor of parent tensor + * @param[in] parent Index of parent + * @param[in] child Index of child + * @return @c true if child is allocated as subtensor of parent, otherwise @c false + */ + bool isSubTensorOf(const graph::operand::Index &parent, const graph::operand::Index &child); private: std::unordered_map _tensor_info_map; -- 2.7.4