Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Ramy Elgammal | d2d9361 | 2022-12-22 15:21:03 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2023 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_TENSORINFO_H |
| 25 | #define ARM_COMPUTE_TENSORINFO_H |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/Coordinates.h" |
Isabella Gottardi | d56e770 | 2018-02-28 14:29:36 +0000 | [diff] [blame] | 28 | #include "arm_compute/core/Helpers.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/ITensorInfo.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 30 | #include "arm_compute/core/Strides.h" |
| 31 | #include "arm_compute/core/TensorShape.h" |
| 32 | #include "arm_compute/core/Types.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 33 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 34 | #include "ITensorInfo.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 35 | #include <cstddef> |
Georgios Pinitas | 283c179 | 2017-11-10 18:14:06 +0000 | [diff] [blame] | 36 | #include <memory> |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 37 | |
| 38 | namespace arm_compute |
| 39 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 40 | /** Store the tensor's metadata */ |
| 41 | class TensorInfo final : public ITensorInfo |
| 42 | { |
| 43 | public: |
| 44 | /** Default constructor */ |
| 45 | TensorInfo(); |
| 46 | /** Default destructor */ |
| 47 | ~TensorInfo() = default; |
| 48 | /** Allow instances of this class to be copy constructed */ |
| 49 | TensorInfo(const ITensorInfo &info); |
| 50 | /** Allow instances of this class to be copy constructed */ |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 51 | TensorInfo(const TensorInfo &); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 52 | /** Allow instances of this class to be copied */ |
| 53 | TensorInfo &operator=(const TensorInfo &) = default; |
| 54 | /** Allow instances of this class to be move constructed */ |
| 55 | TensorInfo(TensorInfo &&) = default; |
| 56 | /** Allow instances of this class to be moved */ |
| 57 | TensorInfo &operator=(TensorInfo &&) = default; |
| 58 | |
| 59 | /** Construct a tensor info with a format. |
| 60 | * |
| 61 | * Can be used for automatic derivation of the shape by the function. |
| 62 | * |
| 63 | * @param[in] format Format of the tensor. |
| 64 | */ |
| 65 | TensorInfo(Format format); |
| 66 | |
| 67 | /** 2D tensor constructor |
| 68 | * |
| 69 | * @param[in] width Width of the 2D tensor |
| 70 | * @param[in] height Height of the 2D tensor |
| 71 | * @param[in] format Single plane format of the tensor. |
| 72 | */ |
| 73 | TensorInfo(unsigned int width, unsigned int height, Format format); |
| 74 | /** Constructor |
| 75 | * |
| 76 | * @param[in] tensor_shape It specifies the size for each dimension of the tensor in number of elements. |
| 77 | * @param[in] format Single plane format of the tensor. |
| 78 | */ |
| 79 | TensorInfo(const TensorShape &tensor_shape, Format format); |
| 80 | |
| 81 | /** Construct a tensor info with a data type and number of channels. |
| 82 | * |
| 83 | * Can be used for automatic derivation of the shape by the function. |
| 84 | * |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 85 | * @param[in] num_channels It indicates the number of channels for each tensor element |
| 86 | * @param[in] data_type Data type to use for each tensor element |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 87 | */ |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 88 | TensorInfo(size_t num_channels, DataType data_type); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 89 | |
| 90 | /** Constructor |
| 91 | * |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 92 | * @param[in] tensor_shape It specifies the size for each dimension of the tensor in number of elements. |
| 93 | * @param[in] num_channels It indicates the number of channels for each tensor element |
| 94 | * @param[in] data_type Data type to use for each tensor element |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 95 | */ |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 96 | TensorInfo(const TensorShape &tensor_shape, size_t num_channels, DataType data_type); |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 97 | |
| 98 | /** Constructor |
| 99 | * |
Manuel Bottini | 581f178 | 2019-11-13 17:24:43 +0000 | [diff] [blame] | 100 | * @param[in] tensor_shape It specifies the size for each dimension of the tensor in number of elements. |
| 101 | * @param[in] num_channels It indicates the number of channels for each tensor element |
| 102 | * @param[in] data_type Data type to use for each tensor element |
| 103 | * @param[in] data_layout The data layout setting for the tensor data. |
| 104 | */ |
| 105 | TensorInfo(const TensorShape &tensor_shape, size_t num_channels, DataType data_type, DataLayout data_layout); |
| 106 | |
| 107 | /** Constructor |
| 108 | * |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 109 | * @param[in] tensor_shape It specifies the size for each dimension of the tensor in number of elements. |
| 110 | * @param[in] num_channels It indicates the number of channels for each tensor element |
| 111 | * @param[in] data_type Data type to use for each tensor element |
| 112 | * @param[in] quantization_info The quantization settings for the tensor data. |
| 113 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 114 | TensorInfo(const TensorShape &tensor_shape, |
| 115 | size_t num_channels, |
| 116 | DataType data_type, |
| 117 | QuantizationInfo quantization_info); |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 118 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 119 | /** Initialize the tensor info with just a format. |
| 120 | * |
| 121 | * Can be used for automatic derivation of the shape by the function. |
| 122 | * |
| 123 | * @param[in] format Single plane format of the tensor. |
| 124 | */ |
| 125 | void init(Format format); |
| 126 | |
| 127 | /** Initialize the metadata structure with the given parameters |
| 128 | * |
| 129 | * @param[in] tensor_shape Size for each dimension of the tensor in number of elements. |
| 130 | * @param[in] format Single plane format of the tensor. |
| 131 | */ |
| 132 | void init(const TensorShape &tensor_shape, Format format); |
| 133 | /** Initialize the metadata structure with the given parameters |
| 134 | * |
| 135 | * @param[in] tensor_shape Size for each dimension of the tensor in number of elements. |
| 136 | * @param[in] format Single plane format of the tensor. |
| 137 | * @param[in] strides_in_bytes Stride in bytes for accessing each dimension of the tensor. |
| 138 | * @param[in] offset_first_element_in_bytes Offset in bytes from the beginning of memory allocation to access the first element. |
| 139 | * @param[in] total_size_in_bytes Size in bytes of the memory allocation (including the offset to the first element). |
| 140 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 141 | void init(const TensorShape &tensor_shape, |
| 142 | Format format, |
| 143 | const Strides &strides_in_bytes, |
| 144 | size_t offset_first_element_in_bytes, |
| 145 | size_t total_size_in_bytes); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 146 | |
| 147 | /** Initialize the tensor info with just a format. |
| 148 | * |
| 149 | * Can be used for automatic derivation of the shape by the function. |
| 150 | * |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 151 | * @param[in] num_channels Desired number of channels for each tensor element. |
| 152 | * @param[in] data_type Data type to use for each tensor element. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 153 | */ |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 154 | void init(size_t num_channels, DataType data_type); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 155 | |
| 156 | /** Initialize the metadata structure with the given parameters |
| 157 | * |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 158 | * @param[in] tensor_shape Size for each dimension of the tensor in number of elements. |
| 159 | * @param[in] num_channels Desired number of channels for each tensor element. |
| 160 | * @param[in] data_type Data type to use for each tensor element. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 161 | */ |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 162 | void init(const TensorShape &tensor_shape, size_t num_channels, DataType data_type); |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 163 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 164 | /** Initialize the metadata structure with the given parameters |
| 165 | * |
| 166 | * @param[in] tensor_shape Size for each dimension of the tensor in number of elements. |
| 167 | * @param[in] num_channels Desired number of channels for each tensor element. |
| 168 | * @param[in] data_type Data type to use for each tensor element. |
| 169 | * @param[in] strides_in_bytes Stride in bytes for accessing each dimension of the tensor. |
| 170 | * @param[in] offset_first_element_in_bytes Offset in bytes from the beginning of memory allocation to access the first element. |
| 171 | * @param[in] total_size_in_bytes Size in bytes of the memory allocation (including the offset to the first element). |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 172 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 173 | void init(const TensorShape &tensor_shape, |
| 174 | size_t num_channels, |
| 175 | DataType data_type, |
| 176 | const Strides &strides_in_bytes, |
| 177 | size_t offset_first_element_in_bytes, |
| 178 | size_t total_size_in_bytes); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 179 | /** Initialize the metadata structure for the given tensor shape and single-plane format, (Padding is automatically calculated) |
| 180 | * |
| 181 | * @note The padding used by this method is really conservative so that the tensor can be used for most functions. |
| 182 | * |
| 183 | * @param[in] tensor_shape It specifies the size for each dimension of the tensor in number of elements |
| 184 | * @param[in] format Single plane format of the image. |
| 185 | * |
| 186 | * @return Total allocation size including padding in bytes. |
| 187 | */ |
| 188 | size_t init_auto_padding(const TensorShape &tensor_shape, Format format); |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 189 | /** Initialize the metadata structure for the given tensor shape, number of channels and |
| 190 | * data type. (Padding is automatically calculated) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 191 | * |
| 192 | * @note The padding used by this method is really conservative so that the tensor can be used for most functions. |
| 193 | * |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 194 | * @param[in] tensor_shape It specifies the size for each dimension of the tensor in number of elements |
| 195 | * @param[in] num_channels It indicates the number of channels for each tensor element |
| 196 | * @param[in] data_type Data type to use for each tensor element |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 197 | * |
| 198 | * @return Total allocation size including padding in bytes. |
| 199 | */ |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 200 | size_t init_auto_padding(const TensorShape &tensor_shape, size_t num_channels, DataType data_type); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 201 | |
| 202 | // Inherited methods overridden: |
Georgios Pinitas | 283c179 | 2017-11-10 18:14:06 +0000 | [diff] [blame] | 203 | std::unique_ptr<ITensorInfo> clone() const override; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 204 | ITensorInfo &set_data_type(DataType data_type) override; |
| 205 | ITensorInfo &set_num_channels(int num_channels) override; |
| 206 | ITensorInfo &set_format(Format format) override; |
| 207 | ITensorInfo &set_tensor_shape(const TensorShape &shape) override; |
| 208 | ITensorInfo &set_tensor_dims_state(const TensorDimsState &state) override; |
| 209 | ITensorInfo &set_quantization_info(const QuantizationInfo &quantization_info) override; |
| 210 | ITensorInfo &set_data_layout(const DataLayout &data_layout) override; |
| 211 | ITensorInfo &reset_padding() override; |
| 212 | bool auto_padding() override; |
| 213 | ITensorInfo &set_lock_paddings(bool flag) override; |
| 214 | bool lock_paddings() const override; |
| 215 | bool extend_padding(const PaddingSize &padding) override; |
| 216 | size_t dimension(size_t index) const override |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 217 | { |
| 218 | return _tensor_shape[index]; |
| 219 | } |
Isabella Gottardi | d56e770 | 2018-02-28 14:29:36 +0000 | [diff] [blame] | 220 | size_t dimension(DataLayoutDimension dimension) const override |
| 221 | { |
| 222 | return get_data_layout_dimension_index(_data_layout, dimension); |
| 223 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 224 | const Strides &strides_in_bytes() const override |
| 225 | { |
| 226 | return _strides_in_bytes; |
| 227 | } |
| 228 | size_t offset_first_element_in_bytes() const override |
| 229 | { |
| 230 | return _offset_first_element_in_bytes; |
| 231 | } |
Michalis Spyrou | 7c60c99 | 2019-10-10 14:33:47 +0100 | [diff] [blame] | 232 | int32_t offset_element_in_bytes(const Coordinates &pos) const override; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 233 | size_t element_size() const override |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 234 | { |
| 235 | return data_size_from_type(_data_type) * _num_channels; |
| 236 | } |
| 237 | size_t num_dimensions() const override |
| 238 | { |
| 239 | return _tensor_shape.num_dimensions(); |
| 240 | } |
| 241 | size_t num_channels() const override |
| 242 | { |
| 243 | return _num_channels; |
| 244 | } |
| 245 | const TensorShape &tensor_shape() const override |
| 246 | { |
| 247 | return _tensor_shape; |
| 248 | } |
Georgios Pinitas | b14a0f0 | 2021-01-08 03:14:31 +0000 | [diff] [blame] | 249 | const TensorDimsState &tensor_dims_state() const override |
| 250 | { |
| 251 | return _dims_state; |
| 252 | } |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 253 | DataType data_type() const override |
| 254 | { |
| 255 | return _data_type; |
| 256 | } |
| 257 | Format format() const override |
| 258 | { |
| 259 | return _format; |
| 260 | } |
| 261 | size_t total_size() const override |
| 262 | { |
| 263 | return _total_size; |
| 264 | } |
| 265 | PaddingSize padding() const override |
| 266 | { |
| 267 | return _padding; |
| 268 | } |
| 269 | bool has_padding() const override |
| 270 | { |
| 271 | return !_padding.empty(); |
| 272 | } |
| 273 | bool is_resizable() const override |
| 274 | { |
| 275 | return _is_resizable; |
| 276 | } |
Georgios Pinitas | 49be2e3 | 2019-09-02 13:18:55 +0100 | [diff] [blame] | 277 | bool is_dynamic() const override |
| 278 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 279 | return std::find(std::cbegin(_dims_state), std::cend(_dims_state), get_dynamic_state_value()) != |
| 280 | std::cend(_dims_state); |
Georgios Pinitas | 49be2e3 | 2019-09-02 13:18:55 +0100 | [diff] [blame] | 281 | } |
Giorgio Arena | 63e0beb | 2021-09-24 14:04:27 +0100 | [diff] [blame] | 282 | bool are_values_constant() const override |
| 283 | { |
| 284 | return _are_values_constant; |
| 285 | } |
Georgios Pinitas | a3b1b46 | 2017-11-16 19:24:39 +0000 | [diff] [blame] | 286 | ITensorInfo &set_is_resizable(bool is_resizable) override |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 287 | { |
| 288 | _is_resizable = is_resizable; |
Georgios Pinitas | a3b1b46 | 2017-11-16 19:24:39 +0000 | [diff] [blame] | 289 | return *this; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 290 | } |
| 291 | ValidRegion valid_region() const override |
| 292 | { |
| 293 | return _valid_region; |
| 294 | } |
Diego Lopez Recas | 35ceeb2 | 2017-12-04 18:56:10 +0000 | [diff] [blame] | 295 | void set_valid_region(const ValidRegion &valid_region) override |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 296 | { |
Diego Lopez Recas | 35ceeb2 | 2017-12-04 18:56:10 +0000 | [diff] [blame] | 297 | _valid_region = valid_region; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 298 | } |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 299 | QuantizationInfo quantization_info() const override |
| 300 | { |
| 301 | return _quantization_info; |
| 302 | } |
Isabella Gottardi | d17a677 | 2018-02-27 17:41:55 +0000 | [diff] [blame] | 303 | DataLayout data_layout() const override |
| 304 | { |
| 305 | return _data_layout; |
| 306 | } |
Giorgio Arena | 63e0beb | 2021-09-24 14:04:27 +0100 | [diff] [blame] | 307 | ITensorInfo &set_are_values_constant(bool are_values_constant) override |
| 308 | { |
| 309 | _are_values_constant = are_values_constant; |
| 310 | return *this; |
| 311 | } |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 312 | ITensorInfo::Id id() const override |
| 313 | { |
| 314 | return _id; |
| 315 | } |
| 316 | ITensorInfo &set_id(ITensorInfo::Id id) override |
| 317 | { |
| 318 | _id = id; |
| 319 | return *this; |
| 320 | } |
SiCong Li | b63b119 | 2022-01-28 18:24:39 +0000 | [diff] [blame] | 321 | inline friend bool operator==(const TensorInfo &lhs, const TensorInfo &rhs); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 322 | |
| 323 | private: |
| 324 | /** Calculates strides, offset and total size resulting from the specified padding around the XY plane. |
| 325 | * |
| 326 | * @param[in] padding Padding around the XY plane in elements. |
| 327 | */ |
| 328 | std::tuple<Strides, size_t, size_t> calculate_padding_requirements(const PaddingSize &padding); |
| 329 | |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 330 | size_t _total_size; |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 331 | size_t _offset_first_element_in_bytes; |
| 332 | Strides _strides_in_bytes; |
| 333 | size_t _num_channels; |
| 334 | TensorShape _tensor_shape; |
Georgios Pinitas | b14a0f0 | 2021-01-08 03:14:31 +0000 | [diff] [blame] | 335 | TensorDimsState _dims_state; |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 336 | DataType _data_type; |
| 337 | Format _format; |
| 338 | bool _is_resizable; |
| 339 | ValidRegion _valid_region; |
| 340 | PaddingSize _padding; |
| 341 | QuantizationInfo _quantization_info; |
Isabella Gottardi | d17a677 | 2018-02-27 17:41:55 +0000 | [diff] [blame] | 342 | DataLayout _data_layout; |
Giorgio Arena | 63e0beb | 2021-09-24 14:04:27 +0100 | [diff] [blame] | 343 | bool _are_values_constant; |
SiCong Li | f44bbc5 | 2022-08-29 18:25:51 +0100 | [diff] [blame] | 344 | ITensorInfo::Id _id; |
Ramy Elgammal | d2d9361 | 2022-12-22 15:21:03 +0000 | [diff] [blame] | 345 | bool _lock_paddings; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 346 | }; |
SiCong Li | b63b119 | 2022-01-28 18:24:39 +0000 | [diff] [blame] | 347 | |
| 348 | /** Check whether two tensor info are equal. |
| 349 | * |
| 350 | * @param[in] lhs LHS tensor info. |
| 351 | * @param[in] rhs RHS tensor info. |
| 352 | * |
| 353 | * @return True if the given tensor infos are the same. |
| 354 | */ |
| 355 | inline bool operator==(const TensorInfo &lhs, const TensorInfo &rhs) |
| 356 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 357 | return (lhs._total_size == rhs._total_size) && |
| 358 | (lhs._offset_first_element_in_bytes == rhs._offset_first_element_in_bytes) && |
| 359 | (lhs._strides_in_bytes == rhs._strides_in_bytes) && (lhs._num_channels == rhs._num_channels) && |
| 360 | (lhs._tensor_shape == rhs._tensor_shape) && (lhs._dims_state == rhs._dims_state) && |
| 361 | (lhs._data_type == rhs._data_type) && (lhs._format == rhs._format) && |
| 362 | (lhs._is_resizable == rhs._is_resizable) && (lhs._valid_region == rhs._valid_region) && |
| 363 | (lhs._padding == rhs._padding) && (lhs._quantization_info == rhs._quantization_info) && |
| 364 | (lhs._data_layout == rhs._data_layout) && (lhs._are_values_constant == rhs._are_values_constant) && |
| 365 | (lhs._id == rhs._id); |
SiCong Li | b63b119 | 2022-01-28 18:24:39 +0000 | [diff] [blame] | 366 | } |
Georgios Pinitas | 49be2e3 | 2019-09-02 13:18:55 +0100 | [diff] [blame] | 367 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 368 | #endif /*ARM_COMPUTE_TENSORINFO_H */ |