X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=documentation%2F_i_tensor_info_8h_source.xhtml;h=35bbe646cd48856095327e8759f4fa221952e8a5;hb=HEAD;hp=40db2b540a4534ba35a5ec46251f17609c98b179;hpb=67c8c91522e5be8156b77f57e63c0253535c902a;p=platform%2Fupstream%2Farmcl.git diff --git a/documentation/_i_tensor_info_8h_source.xhtml b/documentation/_i_tensor_info_8h_source.xhtml index 40db2b5..35bbe64 100644 --- a/documentation/_i_tensor_info_8h_source.xhtml +++ b/documentation/_i_tensor_info_8h_source.xhtml @@ -40,7 +40,7 @@
Compute Library -  18.03 +  18.05
@@ -117,16 +117,16 @@ $(document).ready(function(){initNavTree('_i_tensor_info_8h_source.xhtml','');})
ITensorInfo.h
-Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2018 ARM Limited.
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  */
24 #ifndef __ARM_COMPUTE_ITENSORINFO_H__
25 #define __ARM_COMPUTE_ITENSORINFO_H__
26 
30 #include "arm_compute/core/Types.h"
31 #include "arm_compute/core/Utils.h"
34 
35 #include <cstddef>
36 
37 namespace arm_compute
38 {
40 class ITensorInfo : public misc::ICloneable<ITensorInfo>
41 {
42 public:
44  virtual ~ITensorInfo() = default;
62  virtual ITensorInfo &set_num_channels(int num_channels) = 0;
73  virtual ITensorInfo &set_format(Format format) = 0;
83  virtual ITensorInfo &set_tensor_shape(const TensorShape &shape) = 0;
104  virtual ITensorInfo &reset_padding() = 0;
111  virtual bool auto_padding() = 0;
120  virtual bool extend_padding(const PaddingSize &padding) = 0;
127  virtual size_t dimension(size_t index) const = 0;
132  virtual const Strides &strides_in_bytes() const = 0;
138  virtual size_t offset_first_element_in_bytes() const = 0;
146  virtual size_t offset_element_in_bytes(const Coordinates &pos) const = 0;
151  virtual int fixed_point_position() const = 0;
156  virtual size_t element_size() const = 0;
161  virtual size_t num_dimensions() const = 0;
166  virtual size_t num_channels() const = 0;
171  virtual const TensorShape &tensor_shape() const = 0;
176  virtual DataType data_type() const = 0;
181  virtual Format format() const = 0;
186  virtual size_t total_size() const = 0;
191  virtual PaddingSize padding() const = 0;
196  virtual bool has_padding() const = 0;
201  virtual bool is_resizable() const = 0;
208  virtual ITensorInfo &set_is_resizable(bool is_resizable) = 0;
213  virtual ValidRegion valid_region() const = 0;
218  virtual void set_valid_region(const ValidRegion &valid_region) = 0;
219 
224  virtual QuantizationInfo quantization_info() const = 0;
225 
240  template <typename... Infos>
241  static std::pair<TensorShape, ValidRegion> broadcast_shape_and_valid_region(const Infos &... infos)
242  {
243  TensorShape bc_shape = TensorShape::broadcast_shape(infos.tensor_shape()...);
244  ValidRegion bc_valid_region{ Coordinates(), bc_shape };
245 
246  auto broadcast_valid_region = [&bc_valid_region](const ITensorInfo & info)
247  {
248  if(info.num_dimensions() != 0)
249  {
250  for(size_t d = 0; d < bc_valid_region.shape.num_dimensions(); ++d)
251  {
252  const bool is_broadcast = (info.tensor_shape()[d] == 1);
253 
254  const int anchor_max = std::max(bc_valid_region.anchor[d], info.valid_region().anchor[d]);
255  const size_t valid_min = std::min(bc_valid_region.shape[d], info.valid_region().shape[d]);
256 
257  if(!is_broadcast || (valid_min == 0))
258  {
259  bc_valid_region.anchor.set(d, anchor_max);
260  bc_valid_region.shape.set(d, valid_min);
261  }
262  }
263  }
264  };
265 
266  utility::for_each(broadcast_valid_region, infos...);
267 
268  return std::pair<TensorShape, ValidRegion>(bc_shape, bc_valid_region);
269  }
270 };
271 }
272 #endif /*__ARM_COMPUTE_TENSORINFO_H__ */
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2018 ARM Limited.
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  */
24 #ifndef __ARM_COMPUTE_ITENSORINFO_H__
25 #define __ARM_COMPUTE_ITENSORINFO_H__
26 
30 #include "arm_compute/core/Types.h"
31 #include "arm_compute/core/Utils.h"
34 
35 #include <cstddef>
36 
37 namespace arm_compute
38 {
40 class ITensorInfo : public misc::ICloneable<ITensorInfo>
41 {
42 public:
44  virtual ~ITensorInfo() = default;
62  virtual ITensorInfo &set_num_channels(int num_channels) = 0;
73  virtual ITensorInfo &set_format(Format format) = 0;
83  virtual ITensorInfo &set_tensor_shape(const TensorShape &shape) = 0;
106  virtual ITensorInfo &set_data_layout(const DataLayout &data_layout) = 0;
111  virtual ITensorInfo &reset_padding() = 0;
118  virtual bool auto_padding() = 0;
127  virtual bool extend_padding(const PaddingSize &padding) = 0;
134  virtual size_t dimension(size_t index) const = 0;
141  virtual size_t dimension(DataLayoutDimension dimension) const = 0;
146  virtual const Strides &strides_in_bytes() const = 0;
152  virtual size_t offset_first_element_in_bytes() const = 0;
160  virtual size_t offset_element_in_bytes(const Coordinates &pos) const = 0;
165  virtual int fixed_point_position() const = 0;
170  virtual size_t element_size() const = 0;
175  virtual size_t num_dimensions() const = 0;
180  virtual size_t num_channels() const = 0;
185  virtual const TensorShape &tensor_shape() const = 0;
190  virtual DataType data_type() const = 0;
195  virtual Format format() const = 0;
200  virtual size_t total_size() const = 0;
205  virtual PaddingSize padding() const = 0;
210  virtual bool has_padding() const = 0;
215  virtual bool is_resizable() const = 0;
222  virtual ITensorInfo &set_is_resizable(bool is_resizable) = 0;
227  virtual ValidRegion valid_region() const = 0;
232  virtual void set_valid_region(const ValidRegion &valid_region) = 0;
233 
238  virtual QuantizationInfo quantization_info() const = 0;
243  virtual DataLayout data_layout() const = 0;
244 
259  template <typename... Infos>
260  static std::pair<TensorShape, ValidRegion> broadcast_shape_and_valid_region(const Infos &... infos)
261  {
262  TensorShape bc_shape = TensorShape::broadcast_shape(infos.tensor_shape()...);
263  ValidRegion bc_valid_region{ Coordinates(), bc_shape };
264 
265  auto broadcast_valid_region = [&bc_valid_region](const ITensorInfo & info)
266  {
267  if(info.num_dimensions() != 0)
268  {
269  for(size_t d = 0; d < bc_valid_region.shape.num_dimensions(); ++d)
270  {
271  const bool is_broadcast = (info.tensor_shape()[d] == 1);
272 
273  const int anchor_max = std::max(bc_valid_region.anchor[d], info.valid_region().anchor[d]);
274  const size_t valid_min = std::min(bc_valid_region.shape[d], info.valid_region().shape[d]);
275 
276  if(!is_broadcast || (valid_min == 0))
277  {
278  bc_valid_region.anchor.set(d, anchor_max);
279  bc_valid_region.shape.set(d, valid_min);
280  }
281  }
282  }
283  };
284 
285  utility::for_each(broadcast_valid_region, infos...);
286 
287  return std::pair<TensorShape, ValidRegion>(bc_shape, bc_valid_region);
288  }
289 };
290 }
291 #endif /*__ARM_COMPUTE_TENSORINFO_H__ */
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
virtual ITensorInfo & set_num_channels(int num_channels)=0
Set the number of channels to the specified value.
-
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:884
- +
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:897
Shape of a tensor.
Definition: TensorShape.h:39
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
-
Container for 2D border size.
Definition: Types.h:229
+
Container for 2D border size.
Definition: Types.h:291
virtual ITensorInfo & set_fixed_point_position(int fixed_point_position)=0
Set the fixed point position to the specified value.
virtual ITensorInfo & set_tensor_shape(const TensorShape &shape)=0
Set the shape of an already initialized tensor.
+
DataLayoutDimension
Supported tensor data layout dimensions.
Definition: Types.h:118
virtual DataType data_type() const =0
Data type used for each element of the tensor.
virtual size_t offset_element_in_bytes(const Coordinates &pos) const =0
The offset in bytes from the beginning of the memory allocation to access the element at position (x...
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
@@ -141,6 +141,7 @@ $(document).ready(function(){initNavTree('_i_tensor_info_8h_source.xhtml','');})
virtual bool auto_padding()=0
Update the offset to the first element and the strides to automatically computed values.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
+
virtual ITensorInfo & set_data_layout(const DataLayout &data_layout)=0
Set the data layout of the tensor.
Format
Image colour formats.
Definition: Types.h:50
virtual int fixed_point_position() const =0
Fixed point position used when the tensor data type is QS8 or QS16.
Coordinates of an item.
Definition: Coordinates.h:37
@@ -149,35 +150,38 @@ $(document).ready(function(){initNavTree('_i_tensor_info_8h_source.xhtml','');})
virtual ITensorInfo & set_quantization_info(const QuantizationInfo &quantization_info)=0
Set the quantization settings (scale and offset) of the tensor.
virtual ITensorInfo & set_data_type(DataType data_type)=0
Set the data type to the specified value.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
-
static TensorShape broadcast_shape(const Shapes &...shapes)
If shapes are broadcast compatible, return the broadcasted shape.
Definition: TensorShape.h:192
-
void for_each(F &&)
Base case of for_each.
Definition: utility.h:91
+
static TensorShape broadcast_shape(const Shapes &...shapes)
If shapes are broadcast compatible, return the broadcasted shape.
Definition: TensorShape.h:196
+
void for_each(F &&)
Base case of for_each.
Definition: Utility.h:91
Strides of an item in bytes.
Definition: Strides.h:37
virtual size_t offset_first_element_in_bytes() const =0
The offset from the beginning of the memory allocation to the first element of the tensor...
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
-
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:889
-
Quantization settings (used for QASYMM8 data type)
Definition: Types.h:117
+
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:902
+
Quantization settings (used for QASYMM8 data type)
Definition: Types.h:127
virtual const Strides & strides_in_bytes() const =0
The strides in bytes for accessing each dimension of the tensor.
Clonable Interface.
Definition: ICloneable.h:35
- +
Container for valid region of a window.
Definition: Types.h:206
virtual ITensorInfo & set_format(Format format)=0
Set the format of an already initialized tensor.
+
DataType
Available data types.
Definition: Types.h:72
virtual ~ITensorInfo()=default
Default virtual destructor.
+
DataLayout
Supported tensor data layouts.
Definition: Types.h:110
virtual bool extend_padding(const PaddingSize &padding)=0
Update the offset to the first element, the strides and the total size.
-
static std::pair< TensorShape, ValidRegion > broadcast_shape_and_valid_region(const Infos &...infos)
If infos are broadcast compatible tensor info&#39;s, return the broadcasted shape and the intersection of...
Definition: ITensorInfo.h:241
+
static std::pair< TensorShape, ValidRegion > broadcast_shape_and_valid_region(const Infos &...infos)
If infos are broadcast compatible tensor info&#39;s, return the broadcasted shape and the intersection of...
Definition: ITensorInfo.h:260
virtual size_t num_channels() const =0
The number of channels for each tensor element.
virtual bool has_padding() const =0
Checks if the tensor has been allocated with padding or not.
virtual ITensorInfo & set_is_resizable(bool is_resizable)=0
Set the flag whether the tensor size can be changed.
+
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.