From 49be2e32e697f3b7a124018bc3cee91adb5f9478 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 2 Sep 2019 13:18:55 +0100 Subject: COMPMID-2644: Add is_dynamic flag to ITensorInfo. Flag indicates if tensor shape is determined dynamically in kernel/function execution. Change-Id: I7f6f9557571316e1eaf8c7aaf9f5b9262c2e1751 Signed-off-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/1850 Tested-by: Arm Jenkins Reviewed-by: Michalis Spyrou Comments-Addressed: Arm Jenkins --- arm_compute/core/ITensorInfo.h | 16 ++++++++++++++-- arm_compute/core/SubTensorInfo.h | 15 +++++++++++++-- arm_compute/core/TensorInfo.h | 14 ++++++++++++-- 3 files changed, 39 insertions(+), 6 deletions(-) (limited to 'arm_compute/core') diff --git a/arm_compute/core/ITensorInfo.h b/arm_compute/core/ITensorInfo.h index f113445fb7..5aa243ecf8 100644 --- a/arm_compute/core/ITensorInfo.h +++ b/arm_compute/core/ITensorInfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 ARM Limited. + * Copyright (c) 2016-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -200,6 +200,11 @@ public: * @return True if the tensor size can be changed. */ virtual bool is_resizable() const = 0; + /** Flag indicating whether the shape of the tensor is dynamic, meaning that it can change on kernel/function execution. + * + * @return True if its dynamic else false + */ + virtual bool is_dynamic() const = 0; /** Set the flag whether the tensor size can be changed. * * @param[in] is_resizable Flag that marks the tensor if it can be changed or not. @@ -207,6 +212,13 @@ public: * @return Reference to this ITensorInfo object */ virtual ITensorInfo &set_is_resizable(bool is_resizable) = 0; + /** Set the flag whether the tensor size is dynamic. + * + * @param[in] is_dynamic Flag that marks the tensor if it's dynamic. + * + * @return Reference to this ITensorInfo object + */ + virtual ITensorInfo &set_is_dynamic(bool is_dynamic) = 0; /** Valid region of the tensor. All elements in the valid region have defined values, i.e. are not undefined. * * @return The valid region. @@ -274,5 +286,5 @@ public: return std::pair(bc_shape, bc_valid_region); } }; -} +} // namespace arm_compute #endif /*__ARM_COMPUTE_TENSORINFO_H__ */ diff --git a/arm_compute/core/SubTensorInfo.h b/arm_compute/core/SubTensorInfo.h index 681e27033e..3de31deb44 100644 --- a/arm_compute/core/SubTensorInfo.h +++ b/arm_compute/core/SubTensorInfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -186,12 +186,23 @@ public: ARM_COMPUTE_ERROR_ON(_parent == nullptr); return _parent->is_resizable(); } + bool is_dynamic() const override + { + ARM_COMPUTE_ERROR_ON(_parent == nullptr); + return _parent->is_dynamic(); + } ITensorInfo &set_is_resizable(bool is_resizable) override { ARM_COMPUTE_ERROR_ON(_parent == nullptr); _parent->set_is_resizable(is_resizable); return *this; } + ITensorInfo &set_is_dynamic(bool is_dynamic) override + { + ARM_COMPUTE_ERROR_ON(_parent == nullptr); + _parent->set_is_dynamic(is_dynamic); + return *this; + } ValidRegion valid_region() const override { return _valid_region; @@ -224,5 +235,5 @@ private: ValidRegion _valid_region; bool _extend_parent; }; -} +} // namespace arm_compute #endif /*__ARM_COMPUTE_SUBTENSORINFO_H__ */ diff --git a/arm_compute/core/TensorInfo.h b/arm_compute/core/TensorInfo.h index 1eaf052d8e..77913f52f9 100644 --- a/arm_compute/core/TensorInfo.h +++ b/arm_compute/core/TensorInfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 ARM Limited. + * Copyright (c) 2016-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -277,11 +277,20 @@ public: { return _is_resizable; } + bool is_dynamic() const override + { + return _is_dynamic; + } ITensorInfo &set_is_resizable(bool is_resizable) override { _is_resizable = is_resizable; return *this; } + ITensorInfo &set_is_dynamic(bool is_dynamic) override + { + _is_dynamic = is_dynamic; + return *this; + } ValidRegion valid_region() const override { return _valid_region; @@ -314,10 +323,11 @@ private: DataType _data_type; Format _format; bool _is_resizable; + bool _is_dynamic; ValidRegion _valid_region; PaddingSize _padding; QuantizationInfo _quantization_info; DataLayout _data_layout; }; -} +} // namespace arm_compute #endif /*__ARM_COMPUTE_TENSORINFO_H__ */ -- cgit v1.2.1