24 #ifndef ARM_COMPUTE_WINDOW_ITERATOR_H 25 #define ARM_COMPUTE_WINDOW_ITERATOR_H 46 position.
set(i, w[i].start() + offset[i] * w[i].
step());
61 : _first(tensor.ptr_to_element(
Coordinates())), _strides(tensor.
info()->strides_in_bytes())
70 inline size_t stride(
size_t dim)
const 73 return _strides[dim] /
sizeof(T);
102 inline T *
get_ptr(
unsigned int x,
unsigned int y = 0,
unsigned int z = 0,
unsigned int w = 0)
104 return reinterpret_cast<T *
>(_first + x * _strides[0] + y * _strides[1] + z * _strides[2] +
w * _strides[3]);
114 inline T *
operator()(
unsigned int x,
unsigned int y = 0,
unsigned int z = 0,
unsigned int w = 0)
125 return reinterpret_cast<T *
>(_first);
143 template <
typename L>
155 : _lambda_function(
std::move(lambda_function)),
165 template <
typename M>
168 while(_end.z() != _position.z())
170 iterate_2D_internal(on_new_row_size, _w.x().end() - _w.x().step(), _w.y().end() - _w.y().step());
171 _position[2] += _w.z().step();
172 _position[1] = _w.y().start();
173 _position[0] = _w.x().start();
176 iterate_2D(on_new_row_size);
183 template <
typename M>
186 iterate_2D_internal(on_new_row_size, _end.x(), _end.y());
198 _w.set_dimension_step(dim, step);
211 template <
typename M>
212 void iterate_2D_internal(
M &&on_new_row_size,
int end_x,
int end_y)
215 if(end_y == _position.y())
218 iterate_over_dim0(end_x + _w.x().step(), on_new_row_size);
223 if(_w.x().start() != _position.x())
226 iterate_over_dim0(_w.x().end(), on_new_row_size);
227 _position[1] += _w.y().step();
231 bool no_leftover = end_x + _w.x().step() == _w.x().end();
235 on_new_row_size(_w[0].start(), _w.x().end());
239 iterate_over_dim1(end_y + _w.y().step());
244 if(_position[1] != end_y)
247 on_new_row_size(_w[0].start(), _w.x().end());
248 iterate_over_dim1(end_y);
252 _position[0] = _w.x().start();
253 iterate_over_dim0(end_x + _w.x().step(), on_new_row_size);
262 void iterate_over_dim1(
int end)
264 for(; _position[1] !=
end; _position[1] += _w[1].step())
266 _position[0] = _w[0].start();
267 iterate_over_dim0(_w[0].
end());
276 template <
typename M>
277 void iterate_over_dim0(
int end,
M &&on_new_row_size)
279 on_new_row_size(_position.x(),
end);
280 iterate_over_dim0(end);
287 void iterate_over_dim0(
int end)
291 for(; _position.x() <
end; _position[0] += _w[0].step())
293 _lambda_function(_position);
312 template <
typename L>
void set(size_t dimension, T value, bool increase_dim_unit=true)
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.
size_t stride(size_t dim) const
Get the stride of the dimension dim expressed in number of Ts.
Iterate over a portion of a Window.
WindowIterator< L > create_window_iterator(const Window &w, const Coordinates &start, const Coordinates &end, L &&lambda_function)
Create a WindowIterator object.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
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)
Interface for CPU tensor.
Copyright (c) 2017-2021 Arm Limited.
void set_strides(const Strides &strides)
Manually set the strides.
WindowIterator(const Window &w, const Coordinates &start, const Coordinates &end, L &&lambda_function)
Construct a WindowIterator object.
Coordinates convert_window_coord_to_position(const Window &w, const Coordinates &offset)
Convert an offset in window steps into absolute coordinates.
void end(TokenStream &in, bool &valid)
void iterate_2D(M &&on_new_row_size)
Iterate over the lowest 2 dimensions of the window.
const Coordinates & end_position() const
Returns the coordinates in absolute coordinates of the end position.
Strides of an item in bytes.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
void set_stride(size_t dim, size_t size)
Manually set the stride of a dimension.
T * operator()()
Returns a pointer to the first element of the tensor.
void set_step(size_t dim, int step)
Change the step used for the iteration.
TensorAccessor(const ITensor &tensor)
Constructor:
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)
T * first_element()
Returns a pointer to the first element of the tensor.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
Tensor accessors to make it easier to interface with arm_gemm.
Describe a multidimensional execution window.
void iterate_3D(M &&on_new_row_size)
Iterate over the lowest 3 dimensions of the window.