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