23.11
|
Go to the documentation of this file.
24 #ifndef ARM_COMPUTE_WINDOW_ITERATOR_H
25 #define ARM_COMPUTE_WINDOW_ITERATOR_H
69 inline size_t stride(
size_t dim)
const
72 return _strides[dim] /
sizeof(T);
101 inline T *
get_ptr(
unsigned int x,
unsigned int y = 0,
unsigned int z = 0,
unsigned int w = 0)
103 return reinterpret_cast<T *
>(_first + x * _strides[0] + y * _strides[1] + z * _strides[2] +
w * _strides[3]);
113 inline T *
operator()(
unsigned int x,
unsigned int y = 0,
unsigned int z = 0,
unsigned int w = 0)
124 return reinterpret_cast<T *
>(_first);
142 template <
typename L>
154 : _lambda_function(std::move(lambda_function)),
164 template <
typename M>
167 while (_end.
z() != _position.
z())
169 iterate_2D_internal(on_new_row_size, _w.
x().
end() - _w.
x().
step(), _w.
y().
end() - _w.
y().
step());
170 _position[2] += _w.
z().
step();
171 _position[1] = _w.
y().
start();
172 _position[0] = _w.
x().
start();
182 template <
typename M>
185 iterate_2D_internal(on_new_row_size, _end.
x(), _end.
y());
210 template <
typename M>
211 void iterate_2D_internal(
M &&on_new_row_size,
int end_x,
int end_y)
214 if (end_y == _position.
y())
217 iterate_over_dim0(end_x + _w.
x().
step(), on_new_row_size);
222 if (_w.
x().
start() != _position.
x())
225 iterate_over_dim0(_w.
x().
end(), on_new_row_size);
226 _position[1] += _w.
y().
step();
230 bool no_leftover = end_x + _w.
x().
step() == _w.
x().
end();
234 on_new_row_size(_w[0].start(), _w.
x().
end());
238 iterate_over_dim1(end_y + _w.
y().
step());
243 if (_position[1] != end_y)
246 on_new_row_size(_w[0].start(), _w.
x().
end());
247 iterate_over_dim1(end_y);
251 _position[0] = _w.
x().
start();
252 iterate_over_dim0(end_x + _w.
x().
step(), on_new_row_size);
261 void iterate_over_dim1(
int end)
263 for (; _position[1] !=
end; _position[1] += _w[1].step())
265 _position[0] = _w[0].start();
266 iterate_over_dim0(_w[0].
end());
275 template <
typename M>
276 void iterate_over_dim0(
int end,
M &&on_new_row_size)
278 on_new_row_size(_position.
x(),
end);
279 iterate_over_dim0(
end);
286 void iterate_over_dim0(
int end)
290 for (; _position.
x() <
end; _position[0] += _w[0].step())
292 _lambda_function(_position);
297 Coordinates _position;
311 template <
typename L>
WindowIterator< L > create_window_iterator(const Window &w, const Coordinates &start, const Coordinates &end, L &&lambda_function)
Create a WindowIterator object.
constexpr int start() const
Return the start of the dimension.
void set(size_t dimension, T value, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
T * operator()()
Returns a pointer to the first element of the tensor.
constexpr int step() const
Return the step of the dimension.
const Coordinates & end_position() const
Returns the coordinates in absolute coordinates of the end position.
WindowIterator(const Window &w, const Coordinates &start, const Coordinates &end, L &&lambda_function)
Construct a WindowIterator object.
Interface for CPU tensor.
void iterate_3D(M &&on_new_row_size)
Iterate over the lowest 3 dimensions of the window.
T z() const
Alias to access the size of the third dimension.
Strides of an item in bytes.
void set_step(size_t dim, int step)
Change the step used for the iteration.
void set_dimension_step(size_t dimension, int step)
Set the step of a given dimension.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Iterate over a portion of a Window.
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
T * first_element()
Returns a pointer to the first element of the tensor.
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
T x() const
Alias to access the size of the first dimension.
void iterate_2D(M &&on_new_row_size)
Iterate over the lowest 2 dimensions of the window.
Coordinates convert_window_coord_to_position(const Window &w, const Coordinates &offset)
Convert an offset in window steps into absolute coordinates.
CLTensor * tensor
Pointer to the auxiliary tensor.
size_t stride(size_t dim) const
Get the stride of the dimension dim expressed in number of Ts.
void set_strides(const Strides &strides)
Manually set the strides.
T * get_ptr(unsigned int x, unsigned int y=0, unsigned int z=0, unsigned int w=0)
Returns a pointer to the element at coordinates (x,y,z,w)
Describe a multidimensional execution window.
void set_stride(size_t dim, size_t size)
Manually set the stride of a dimension.
Copyright (c) 2017-2023 Arm Limited.
void end(TokenStream &in, bool &valid)
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
constexpr int end() const
Return the end of the dimension.
T y() const
Alias to access the size of the second dimension.
TensorAccessor(const ITensor &tensor)
Constructor:
T * operator()(unsigned int x, unsigned int y=0, unsigned int z=0, unsigned int w=0)
Returns a pointer to the element at coordinates (x,y,z,w)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
Tensor accessors to make it easier to interface with arm_gemm.
constexpr const Dimension & z() const
Alias to access the third dimension of the window.