From: 오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 8 Nov 2018 01:10:32 +0000 (+0900) Subject: Introduce subtensor allocation check API (#3510) X-Git-Tag: 0.3~450 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7b8e5eb48f3169e1aa09f82772cb4394b46e13a;p=platform%2Fcore%2Fml%2Fnnfw.git Introduce subtensor allocation check API (#3510) Check API will be used in codegen 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 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;