Compute Library
 19.08
Helpers.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019 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_HELPERS_H__
25 #define __ARM_COMPUTE_HELPERS_H__
26 
28 #include "arm_compute/core/Error.h"
30 #include "arm_compute/core/Steps.h"
33 #include "arm_compute/core/Types.h"
35 
36 #include <array>
37 #include <cstddef>
38 #include <cstdint>
39 #include <memory>
40 #include <tuple>
41 #include <type_traits>
42 #include <utility>
43 
44 namespace arm_compute
45 {
46 class IKernel;
47 class ITensor;
48 class ITensorInfo;
49 
51 template <typename T>
53 {
54  static constexpr bool value = false;
55 };
56 
57 #ifndef DOXYGEN_SKIP_THIS
58 template <typename T>
59 typename std::enable_if<enable_bitwise_ops<T>::value, T>::type operator&(T lhs, T rhs)
60 {
61  using underlying_type = typename std::underlying_type<T>::type;
62  return static_cast<T>(static_cast<underlying_type>(lhs) & static_cast<underlying_type>(rhs));
63 }
64 #endif /* DOXYGEN_SKIP_THIS */
65 
73 template <typename Kernel, typename... T>
74 std::unique_ptr<Kernel> create_configure_kernel(T &&... args)
75 {
76  std::unique_ptr<Kernel> k = arm_compute::support::cpp14::make_unique<Kernel>();
77  k->configure(std::forward<T>(args)...);
78  return k;
79 }
80 
85 template <typename Kernel>
86 std::unique_ptr<Kernel> create_kernel()
87 {
88  std::unique_ptr<Kernel> k = arm_compute::support::cpp14::make_unique<Kernel>();
89  return k;
90 }
91 
92 namespace traits
93 {
95 template <typename T, typename Tuple>
96 struct is_contained;
97 
98 template <typename T>
99 struct is_contained<T, std::tuple<>> : std::false_type
100 {
101 };
102 
103 template <typename T, typename... Ts>
104 struct is_contained<T, std::tuple<T, Ts...>> : std::true_type
105 {
106 };
107 
108 template <typename T, typename U, typename... Ts>
109 struct is_contained<T, std::tuple<U, Ts...>> : is_contained<T, std::tuple<Ts...>>
110 {
111 };
112 }
113 
126 template <typename T>
127 inline T delta_bilinear_c1(const T *pixel_ptr, size_t stride, float dx, float dy)
128 {
129  ARM_COMPUTE_ERROR_ON(pixel_ptr == nullptr);
130 
131  const float dx1 = 1.0f - dx;
132  const float dy1 = 1.0f - dy;
133 
134  const T a00 = *pixel_ptr;
135  const T a01 = *(pixel_ptr + 1);
136  const T a10 = *(pixel_ptr + stride);
137  const T a11 = *(pixel_ptr + stride + 1);
138 
139  const float w1 = dx1 * dy1;
140  const float w2 = dx * dy1;
141  const float w3 = dx1 * dy;
142  const float w4 = dx * dy;
143 
144  return static_cast<T>(a00 * w1 + a01 * w2 + a10 * w3 + a11 * w4);
145 }
146 
161 inline uint8_t delta_bilinear_c1_quantized(const uint8_t *pixel_ptr, size_t stride, float dx, float dy, UniformQuantizationInfo iq_info, UniformQuantizationInfo oq_info)
162 {
163  ARM_COMPUTE_ERROR_ON(pixel_ptr == nullptr);
164 
165  const float dx1 = 1.0f - dx;
166  const float dy1 = 1.0f - dy;
167 
168  const float a00 = dequantize_qasymm8(*pixel_ptr, iq_info);
169  const float a01 = dequantize_qasymm8(*(pixel_ptr + 1), iq_info);
170  const float a10 = dequantize_qasymm8(*(pixel_ptr + stride), iq_info);
171  const float a11 = dequantize_qasymm8(*(pixel_ptr + stride + 1), iq_info);
172 
173  const float w1 = dx1 * dy1;
174  const float w2 = dx * dy1;
175  const float w3 = dx1 * dy;
176  const float w4 = dx * dy;
177  float res = a00 * w1 + a01 * w2 + a10 * w3 + a11 * w4;
178  return static_cast<uint8_t>(quantize_qasymm8(res, oq_info));
179 }
180 
192 template <typename T>
193 inline T delta_linear_c1_y(const T *pixel_ptr, size_t stride, float dy)
194 {
195  ARM_COMPUTE_ERROR_ON(pixel_ptr == nullptr);
196 
197  const float dy1 = 1.0f - dy;
198 
199  const T a00 = *pixel_ptr;
200  const T a10 = *(pixel_ptr + stride);
201 
202  const float w1 = dy1;
203  const float w3 = dy;
204 
205  return static_cast<T>(a00 * w1 + a10 * w3);
206 }
217 template <typename T>
218 inline T delta_linear_c1_x(const T *pixel_ptr, float dx)
219 {
220  ARM_COMPUTE_ERROR_ON(pixel_ptr == nullptr);
221 
222  const T a00 = *pixel_ptr;
223  const T a01 = *(pixel_ptr + 1);
224 
225  const float dx1 = 1.0f - dx;
226 
227  const float w1 = dx1;
228  const float w2 = dx;
229 
230  return static_cast<T>(a00 * w1 + a01 * w2);
231 }
243 template <typename T>
244 inline T pixel_bilinear_c1(const T *first_pixel_ptr, size_t stride, float x, float y)
245 {
246  ARM_COMPUTE_ERROR_ON(first_pixel_ptr == nullptr);
247 
248  const int32_t xi = std::floor(x);
249  const int32_t yi = std::floor(y);
250 
251  const float dx = x - xi;
252  const float dy = y - yi;
253 
254  return delta_bilinear_c1(first_pixel_ptr + xi + yi * stride, stride, dx, dy);
255 }
256 
270 template <typename T>
271 inline uint8_t pixel_bilinear_c1_clamp(const T *first_pixel_ptr, size_t stride, size_t width, size_t height, float x, float y)
272 {
273  ARM_COMPUTE_ERROR_ON(first_pixel_ptr == nullptr);
274 
275  x = std::max(-1.f, std::min(x, static_cast<float>(width)));
276  y = std::max(-1.f, std::min(y, static_cast<float>(height)));
277 
278  const float xi = std::floor(x);
279  const float yi = std::floor(y);
280 
281  const float dx = x - xi;
282  const float dy = y - yi;
283 
284  if(dx == 0.0f)
285  {
286  if(dy == 0.0f)
287  {
288  return static_cast<T>(first_pixel_ptr[static_cast<int32_t>(xi) + static_cast<int32_t>(yi) * stride]);
289  }
290  return delta_linear_c1_y(first_pixel_ptr + static_cast<int32_t>(xi) + static_cast<int32_t>(yi) * stride, stride, dy);
291  }
292  if(dy == 0.0f)
293  {
294  return delta_linear_c1_x(first_pixel_ptr + static_cast<int32_t>(xi) + static_cast<int32_t>(yi) * stride, dx);
295  }
296  return delta_bilinear_c1(first_pixel_ptr + static_cast<int32_t>(xi) + static_cast<int32_t>(yi) * stride, stride, dx, dy);
297 }
298 
315 inline uint8_t pixel_area_c1u8_clamp(const uint8_t *first_pixel_ptr, size_t stride, size_t width, size_t height, float wr, float hr, int x, int y);
316 
318 class Iterator
319 {
320 public:
322  constexpr Iterator();
328  Iterator(const ITensor *tensor, const Window &window);
329 
338  void increment(size_t dimension);
339 
344  constexpr int offset() const;
345 
352  constexpr uint8_t *ptr() const;
353 
358  void reset(size_t dimension);
359 
360 private:
361  uint8_t *_ptr;
362 
363  class Dimension
364  {
365  public:
366  constexpr Dimension()
367  : _dim_start(0), _stride(0)
368  {
369  }
370 
371  int _dim_start;
372  int _stride;
373  };
374 
375  std::array<Dimension, Coordinates::num_max_dimensions> _dims;
376 };
377 
386 template <typename L, typename... Ts>
387 inline void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators);
388 
401 template <typename... Ts>
402 bool update_window_and_padding(Window &win, Ts &&... patterns)
403 {
404  bool window_changed = false;
405 
406  utility::for_each([&](const IAccessWindow & w)
407  {
408  window_changed |= w.update_window_if_needed(win);
409  },
410  patterns...);
411 
412  bool padding_changed = false;
413 
415  {
416  padding_changed |= w.update_padding_if_needed(win);
417  },
418  patterns...);
419 
420  return window_changed;
421 }
422 
432 Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps = Steps(), bool skip_border = false, BorderSize border_size = BorderSize());
433 
443 inline Window calculate_max_window(const ITensorInfo &info, const Steps &steps = Steps(), bool skip_border = false, BorderSize border_size = BorderSize())
444 {
445  return calculate_max_window(info.valid_region(), steps, skip_border, border_size);
446 }
447 
457 Window calculate_max_window_horizontal(const ValidRegion &valid_region, const Steps &steps = Steps(), bool skip_border = false, BorderSize border_size = BorderSize());
458 
468 inline Window calculate_max_window_horizontal(const ITensorInfo &info, const Steps &steps = Steps(), bool skip_border = false, BorderSize border_size = BorderSize())
469 {
470  return calculate_max_window_horizontal(info.valid_region(), steps, skip_border, border_size);
471 }
472 
481 Window calculate_max_enlarged_window(const ValidRegion &valid_region, const Steps &steps = Steps(), BorderSize border_size = BorderSize());
482 
491 inline Window calculate_max_enlarged_window(const ITensorInfo &info, const Steps &steps = Steps(), BorderSize border_size = BorderSize())
492 {
493  return calculate_max_enlarged_window(info.valid_region(), steps, border_size);
494 }
495 
502 template <typename... Ts>
503 ValidRegion intersect_valid_regions(const Ts &... regions)
504 {
505  auto intersect = [](const ValidRegion & r1, const ValidRegion & r2) -> ValidRegion
506  {
507  ValidRegion region;
508 
509  for(size_t d = 0; d < std::min(r1.anchor.num_dimensions(), r2.anchor.num_dimensions()); ++d)
510  {
511  region.anchor.set(d, std::max(r1.anchor[d], r2.anchor[d]));
512  }
513 
514  for(size_t d = 0; d < std::min(r1.shape.num_dimensions(), r2.shape.num_dimensions()); ++d)
515  {
516  region.shape.set(d, std::min(r1.shape[d], r2.shape[d]));
517  }
518 
519  return region;
520  };
521 
522  return utility::foldl(intersect, regions...);
523 }
524 
534 template <typename T, typename... Ts>
535 inline Strides compute_strides(const ITensorInfo &info, T stride_x, Ts &&... fixed_strides)
536 {
537  const TensorShape &shape = info.tensor_shape();
538 
539  // Create strides object
540  Strides strides(stride_x, fixed_strides...);
541 
542  for(size_t i = 1 + sizeof...(Ts); i < info.num_dimensions(); ++i)
543  {
544  strides.set(i, shape[i - 1] * strides[i - 1]);
545  }
546 
547  return strides;
548 }
549 
556 template <typename... Ts>
558 {
559  return compute_strides(info, info.element_size());
560 }
561 
569 template <typename T>
570 inline void permute(Dimensions<T> &dimensions, const PermutationVector &perm)
571 {
572  auto dimensions_copy = utility::make_array<Dimensions<T>::num_max_dimensions>(dimensions.begin(), dimensions.end());
573  for(unsigned int i = 0; i < perm.num_dimensions(); ++i)
574  {
575  T dimension_val = (perm[i] < dimensions.num_dimensions()) ? dimensions_copy[perm[i]] : 0;
576  dimensions.set(i, dimension_val);
577  }
578 }
579 
587 inline void permute(TensorShape &shape, const PermutationVector &perm)
588 {
589  TensorShape shape_copy = shape;
590  for(unsigned int i = 0; i < perm.num_dimensions(); ++i)
591  {
592  size_t dimension_val = (perm[i] < shape.num_dimensions()) ? shape_copy[perm[i]] : 1;
593  shape.set(i, dimension_val, false); // Avoid changes in _num_dimension
594  }
595 }
596 
607 bool auto_init_if_empty(ITensorInfo &info,
608  const TensorShape &shape,
609  int num_channels, DataType data_type,
610  QuantizationInfo quantization_info = QuantizationInfo());
611 
619 bool auto_init_if_empty(ITensorInfo &info_sink, const ITensorInfo &info_source);
620 
628 bool set_shape_if_empty(ITensorInfo &info, const TensorShape &shape);
629 
638 bool set_format_if_unknown(ITensorInfo &info, Format format);
639 
648 bool set_data_type_if_unknown(ITensorInfo &info, DataType data_type);
649 
659 
668 bool set_quantization_info_if_empty(ITensorInfo &info, QuantizationInfo quantization_info);
669 
680 ValidRegion calculate_valid_region_scale(const ITensorInfo &src_info, const TensorShape &dst_shape,
681  InterpolationPolicy interpolate_policy, SamplingPolicy sampling_policy, bool border_undefined);
682 
690 inline Coordinates index2coords(const TensorShape &shape, int index);
691 
699 inline int coords2index(const TensorShape &shape, const Coordinates &coord);
700 
708 inline size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension);
709 
718 
727 {
728  const unsigned int width_idx = get_data_layout_dimension_index(layout, DataLayoutDimension::WIDTH);
729  const unsigned int channel_idx = get_data_layout_dimension_index(layout, DataLayoutDimension::CHANNEL);
730 
731  return info.is_in_map() ? width_idx : channel_idx;
732 }
733 
744 inline Size2D compute_winograd_convolution_tiles(const Size2D &in_dims, const Size2D &kernel_size, const Size2D &output_tile_size, const PadStrideInfo &conv_info)
745 {
746  int num_tiles_x = std::ceil((in_dims.width - (kernel_size.width - 1) + conv_info.pad_left() + conv_info.pad_right()) / static_cast<float>(output_tile_size.width));
747  int num_tiles_y = std::ceil((in_dims.height - (kernel_size.height - 1) + conv_info.pad_top() + conv_info.pad_bottom()) / static_cast<float>(output_tile_size.height));
748 
749  // Clamp in case we provide paddings but we have 1D convolution
750  num_tiles_x = std::min(num_tiles_x, static_cast<int>(in_dims.width));
751  num_tiles_y = std::min(num_tiles_y, static_cast<int>(in_dims.height));
752 
753  return Size2D(num_tiles_x, num_tiles_y);
754 }
755 
763 template <typename T>
764 inline T wrap_around(T x, T m)
765 {
766  return x >= 0 ? x % m : (x % m + m) % m;
767 }
768 
775 inline unsigned int get_next_power_two(unsigned int x)
776 {
777  // Decrement by 1
778  x--;
779 
780  // Shift right by 1
781  x |= x >> 1u;
782  // Shift right by 2
783  x |= x >> 2u;
784  // Shift right by 4
785  x |= x >> 4u;
786  // Shift right by 8
787  x |= x >> 8u;
788  // Shift right by 16
789  x |= x >> 16u;
790 
791  // Increment by 1
792  x++;
793 
794  return x;
795 }
796 } // namespace arm_compute
797 
799 #endif /*__ARM_COMPUTE_HELPERS_H__ */
InterpolationPolicy
Interpolation method.
Definition: Types.h:356
SimpleTensor< float > w
Definition: DFT.cpp:156
T delta_linear_c1_x(const T *pixel_ptr, float dx)
Computes linear interpolation using the pointer to the left pixel and the pixel's distance between th...
Definition: Helpers.h:218
Shape of a tensor.
Definition: TensorShape.h:39
const DataLayout data_layout
Definition: Im2Col.cpp:146
static constexpr bool value
Disabled.
Definition: Helpers.h:54
Disable bitwise operations by default.
Definition: Helpers.h:52
Coordinates index2coords(const TensorShape &shape, int index)
Convert a linear index into n-dimensional coordinates.
Definition: Helpers.inl:289
uint8_t delta_bilinear_c1_quantized(const uint8_t *pixel_ptr, size_t stride, float dx, float dy, UniformQuantizationInfo iq_info, UniformQuantizationInfo oq_info)
Computes bilinear interpolation for quantized input and output, using the pointer to the top-left pix...
Definition: Helpers.h:161
TensorShape shape
Shape of the valid region.
Definition: Types.h:247
Container for 2D border size.
Definition: Types.h:259
void increment(size_t dimension)
Increment the iterator along the specified dimension of the step value associated to the dimension.
Definition: Helpers.inl:167
unsigned int get_next_power_two(unsigned int x)
Given an integer value, this function returns the next power of two.
Definition: Helpers.h:775
float dequantize_qasymm8(uint8_t value, const UniformQuantizationInfo &qinfo)
Dequantize a value given a asymmetric quantization scheme.
DataLayoutDimension
[DataLayout enum definition]
Definition: Types.h:123
std::unique_ptr< Kernel > create_configure_kernel(T &&... args)
Helper function to create and return a unique_ptr pointed to a CL/GLES kernel object It also calls th...
Definition: Helpers.h:74
Normalization Layer Information class.
Definition: Types.h:1578
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
Store the tensor's metadata.
Definition: ITensorInfo.h:40
Quantization info when assuming per layer quantization.
bool set_data_layout_if_unknown(ITensorInfo &info, DataLayout data_layout)
Set the data layout to the specified value if the current data layout is unknown.
Definition: Helpers.inl:267
Size2D compute_winograd_convolution_tiles(const Size2D &in_dims, const Size2D &kernel_size, const Size2D &output_tile_size, const PadStrideInfo &conv_info)
Calculate the number of output tiles required by Winograd Convolution layer.
Definition: Helpers.h:744
void set(size_t dimension, T value)
Accessor to set the value of one of the dimensions.
Definition: Dimensions.h:74
Interface for NEON tensor.
Definition: ITensor.h:36
bool set_data_type_if_unknown(ITensorInfo &info, DataType data_type)
Set the data type and number of channels to the specified value if the current data type is unknown.
Definition: Helpers.inl:256
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps=Steps(), bool skip_border=false, BorderSize border_size=BorderSize())
Calculate the maximum window for a given tensor shape and border setting.
Definition: Helpers.cpp:28
Copyright (c) 2017-2018 ARM Limited.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
Definition: Helpers.inl:201
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:93
Strides compute_strides(const ITensorInfo &info, T stride_x, Ts &&... fixed_strides)
Create a strides object based on the provided strides and the tensor dimensions.
Definition: Helpers.h:535
void permute(Dimensions< T > &dimensions, const PermutationVector &perm)
Permutes given Dimensions according to a permutation vector.
Definition: Helpers.h:570
Window calculate_max_enlarged_window(const ValidRegion &valid_region, const Steps &steps=Steps(), BorderSize border_size=BorderSize())
Calculate the maximum window for a given tensor shape and border setting.
Definition: Helpers.cpp:82
T wrap_around(T x, T m)
Wrap-around a number within the range 0 <= x < m.
Definition: Helpers.h:764
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: Helpers.h:402
T && foldl(F &&, T &&value)
Base case of foldl.
Definition: Utility.h:115
T delta_linear_c1_y(const T *pixel_ptr, size_t stride, float dy)
Computes linear interpolation using the pointer to the top pixel and the pixel's distance between the...
Definition: Helpers.h:193
Format
Image colour formats.
Definition: Types.h:52
constexpr int offset() const
Return the offset in bytes from the first element to the current position of the iterator.
Definition: Helpers.inl:179
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Interface describing methods to update access window and padding based on kernel parameters.
Definition: IAccessWindow.h:71
Check if a type T is contained in a tuple Tuple of types.
Definition: Helpers.h:96
Dimensions with dimensionality.
Definition: Dimensions.h:41
int coords2index(const TensorShape &shape, const Coordinates &coord)
Convert n-dimensional coordinates into a linear index.
Definition: Helpers.inl:308
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
Definition: Helpers.inl:184
Padding and stride information class.
Definition: Types.h:676
ValidRegion intersect_valid_regions(const Ts &... regions)
Intersect multiple valid regions.
Definition: Helpers.h:503
std::array< T, num_max_dimensions >::iterator begin()
Returns a read/write iterator that points to the first element in the dimension array.
Definition: Dimensions.h:194
std::unique_ptr< Kernel > create_kernel()
Helper function to create and return a unique_ptr pointed to a CL/GLES kernel object.
Definition: Helpers.h:86
DataLayoutDimension get_index_data_layout_dimension(const DataLayout data_layout, const size_t index)
Get the DataLayoutDimension of a given index and layout.
Definition: Helpers.inl:355
constexpr Iterator()
Default constructor to create an empty iterator.
Definition: Helpers.inl:135
T delta_bilinear_c1(const T *pixel_ptr, size_t stride, float dx, float dy)
Computes bilinear interpolation using the pointer to the top-left pixel and the pixel's distance betw...
Definition: Helpers.h:127
void for_each(F &&)
Base case of for_each.
Definition: Utility.h:93
TensorInfo src_info(src_shape, 1, data_type)
Strides of an item in bytes.
Definition: Strides.h:37
ValidRegion calculate_valid_region_scale(const ITensorInfo &src_info, const TensorShape &dst_shape, InterpolationPolicy interpolate_policy, SamplingPolicy sampling_policy, bool border_undefined)
Helper function to calculate the Valid Region for Scale.
Definition: Helpers.cpp:184
uint8_t pixel_area_c1u8_clamp(const uint8_t *first_pixel_ptr, size_t stride, size_t width, size_t height, float wr, float hr, int x, int y)
Return the pixel at (x,y) using area interpolation by clamping when out of borders.
Definition: Helpers.inl:32
DatasetMode operator &(DatasetMode t1, DatasetMode t2)
Definition: DatasetModes.h:48
void reset(size_t dimension)
Move the iterator back to the beginning of the specified dimension.
Definition: Helpers.inl:189
std::array< T, num_max_dimensions >::iterator end()
Returns a read/write iterator that points one past the last element in the dimension array.
Definition: Dimensions.h:218
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:92
T pixel_bilinear_c1(const T *first_pixel_ptr, size_t stride, float x, float y)
Return the pixel at (x,y) using bilinear interpolation.
Definition: Helpers.h:244
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:122
bool set_shape_if_empty(ITensorInfo &info, const TensorShape &shape)
Set the shape to the specified value if the current assignment is empty.
Definition: Helpers.inl:234
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true)
Accessor to set the value of one of the dimensions.
Definition: TensorShape.h:78
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Definition: Helpers.inl:122
bool set_format_if_unknown(ITensorInfo &info, Format format)
Set the format, data type and number of channels to the specified value if the current data type is u...
Definition: Helpers.inl:245
Container for valid region of a window.
Definition: Types.h:174
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:326
uint8_t pixel_bilinear_c1_clamp(const T *first_pixel_ptr, size_t stride, size_t width, size_t height, float x, float y)
Return the pixel at (x,y) using bilinear interpolation by clamping when out of borders.
Definition: Helpers.h:271
Iterator updated by execute_window_loop for each window element.
Definition: Helpers.h:318
DataType
Available data types.
Definition: Types.h:74
unsigned int get_normalization_dimension_index(DataLayout layout, const NormalizationLayerInfo &info)
Calculate the normalization dimension index for a given normalization type.
Definition: Helpers.h:726
DataLayout
[DataLayout enum definition]
Definition: Types.h:114
bool set_quantization_info_if_empty(ITensorInfo &info, QuantizationInfo quantization_info)
Set the quantization info to the specified value if the current quantization info is empty and the da...
Definition: Helpers.inl:278
Describe a multidimensional execution window.
Definition: Window.h:39
Window calculate_max_window_horizontal(const ValidRegion &valid_region, const Steps &steps=Steps(), bool skip_border=false, BorderSize border_size=BorderSize())
Calculate the maximum window used by a horizontal kernel for a given tensor shape and border setting.
Definition: Helpers.cpp:131
Coordinates anchor
Anchor for the start of the valid region.
Definition: Types.h:246
SamplingPolicy
Available Sampling Policies.
Definition: Types.h:96
uint8_t quantize_qasymm8(float value, const UniformQuantizationInfo &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a asymmetric quantization scheme.