24 #ifndef __ARM_COMPUTE_HELPERS_H__ 25 #define __ARM_COMPUTE_HELPERS_H__ 39 #include <type_traits> 50 #ifndef DOXYGEN_SKIP_THIS 54 typedef std::unique_ptr<T> _Single_object;
58 struct _Unique_if<T[]>
60 typedef std::unique_ptr<T[]> _Unknown_bound;
63 template <
class T,
size_t N>
64 struct _Unique_if<T[N]>
66 typedef void _Known_bound;
69 template <
class T,
class... Args>
70 typename _Unique_if<T>::_Single_object
71 make_unique(Args &&... args)
73 return std::unique_ptr<T>(
new T(std::forward<Args>(args)...));
77 typename _Unique_if<T>::_Unknown_bound
80 typedef typename std::remove_extent<T>::type
U;
81 return std::unique_ptr<T>(
new U[n]());
84 template <
class T,
class... Args>
85 typename _Unique_if<T>::_Known_bound
86 make_unique(Args &&...) =
delete;
105 inline uint8_t delta_bilinear_c1u8(
const uint8_t *pixel_ptr,
size_t stride,
float dx,
float dy);
118 inline uint8_t pixel_bilinear_c1u8(
const uint8_t *first_pixel_ptr,
size_t stride,
float x,
float y);
133 inline uint8_t pixel_bilinear_c1u8_clamp(
const uint8_t *first_pixel_ptr,
size_t stride,
size_t width,
size_t height,
float x,
float y);
151 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);
161 template <
typename T>
162 inline T clamp(
const T &n,
const T &lower,
const T &upper)
164 return std::max(lower, std::min(n, upper));
168 template <
typename F>
169 inline void for_each(F &&)
179 template <
typename F,
typename T,
typename... Ts>
180 inline void for_each(F &&func, T &&arg, Ts &&... args)
183 for_each(func, args...);
187 template <
typename F,
typename T>
188 inline T foldl(F &&, T &&value)
200 template <
typename F,
typename I,
typename T,
typename... Ts>
201 inline I foldl(F &&func, I &&initial, T &&value, Ts &&... values)
203 return foldl(func, func(initial, value), values...);
230 void increment(
size_t dimension);
236 constexpr
int offset()
const;
244 constexpr uint8_t *ptr()
const;
250 void reset(
size_t dimension);
258 constexpr Dimension()
259 : _dim_start(0), _stride(0)
267 std::array<Dimension, Coordinates::num_max_dimensions> _dims;
278 template <
typename L,
typename... Ts>
293 template <
typename... Ts>
296 bool window_changed =
false;
304 bool padding_changed =
false;
312 return window_changed;
343 template <
typename... Ts>
363 return foldl(intersect, std::forward<Ts>(regions)...);
375 template <
typename T,
typename... Ts>
381 Strides strides(stride_x, fixed_strides...);
385 strides.
set(i, shape[i - 1] * strides[i - 1]);
397 template <
typename... Ts>
Container for 2D border size.
Window calculate_max_window(const TensorInfo &info, const Steps &steps=Steps(), bool skip_border=false, BorderSize border_size=BorderSize())
Calculate the maximum window for a given tensor shape and border setting.
size_t element_size() const
Element size in bytes calculated as data_size() * num_channels.
Strides compute_strides(const TensorInfo &info, T stride_x, Ts &&...fixed_strides)
Create a strides object based on the provided strides and the tensor dimensions.
bool update_window_and_padding(Window &win, Ts &&...patterns)
Update window and padding size for each of the access patterns.
void set(size_t dimension, T value)
Accessor to set the value of one of the dimensions.
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Interface for NEON tensor.
virtual bool update_window_if_needed(Window &window) const =0
Shrink the window if padding is not large enough.
const TensorShape & tensor_shape() const
Size for each dimension of the tensor.
ValidRegion intersect_valid_regions(Ts &&...regions)
Intersect multiple valid regions.
Window calculate_max_window_horizontal(const TensorInfo &info, 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...
Class to describe a number of elements in each dimension.
Interface describing methods to update access window and padding based on kernel parameters.
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...
Strides of an item in bytes.
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Store the tensor's metadata.
Iterator updated by execute_window_loop for each window element.
Describe a multidimensional execution window.
size_t num_dimensions() const
The number of dimensions of the tensor (rank)
virtual bool update_padding_if_needed(const Window &window) const =0
Increase the padding to be large enough for the window.