24 #ifndef ARM_COMPUTE_WINDOW_ITERATOR_H 25 #define ARM_COMPUTE_WINDOW_ITERATOR_H 33 #define ARM_COMPUTE_PRINTF(...) 64 : _first(tensor.ptr_to_element(
Coordinates())), _strides(tensor.
info()->strides_in_bytes())
73 inline size_t stride(
size_t dim)
const 76 return _strides[dim] /
sizeof(T);
105 inline T *
get_ptr(
unsigned int x,
unsigned int y = 0,
unsigned int z = 0,
unsigned int w = 0)
107 return reinterpret_cast<T *
>(_first + x * _strides[0] + y * _strides[1] + z * _strides[2] +
w * _strides[3]);
117 inline T *
operator()(
unsigned int x,
unsigned int y = 0,
unsigned int z = 0,
unsigned int w = 0)
128 return reinterpret_cast<T *
>(_first);
146 template <
typename L>
158 : _lambda_function(
std::move(lambda_function)),
168 template <
typename M>
171 while(_end.z() != _position.z())
174 iterate_2D_internal(on_new_row_size, _w.x().end() - _w.x().step(), _w.y().end() - _w.y().step());
175 _position[2] += _w.z().step();
176 _position[1] = _w.y().start();
177 _position[0] = _w.x().start();
181 iterate_2D(on_new_row_size);
188 template <
typename M>
191 iterate_2D_internal(on_new_row_size, _end.x(), _end.y());
203 _w.set_dimension_step(dim, step);
216 template <
typename M>
217 void iterate_2D_internal(
M &&on_new_row_size,
int end_x,
int end_y)
220 if(end_y == _position.y())
225 iterate_over_dim0(end_x + _w.x().step(), on_new_row_size);
230 if(_w.x().start() != _position.x())
234 iterate_over_dim0(_w.x().end(), on_new_row_size);
235 _position[1] += _w.y().step();
239 bool no_leftover = end_x + _w.x().step() == _w.x().end();
244 on_new_row_size(_w[0].
start(), _w.x().end());
248 iterate_over_dim1(end_y + _w.y().step());
254 if(_position[1] != end_y)
258 on_new_row_size(_w[0].
start(), _w.x().end());
259 iterate_over_dim1(end_y);
264 _position[0] = _w.x().start();
265 iterate_over_dim0(end_x + _w.x().step(), on_new_row_size);
274 void iterate_over_dim1(
int end)
276 for(; _position[1] !=
end; _position[1] += _w[1].step())
278 _position[0] = _w[0].start();
279 iterate_over_dim0(_w[0].
end());
288 template <
typename M>
289 void iterate_over_dim0(
int end,
M &&on_new_row_size)
291 on_new_row_size(_position.x(),
end);
292 iterate_over_dim0(end);
299 void iterate_over_dim0(
int end)
304 for(; _position.x() <
end; _position[0] += _w[0].step())
306 _lambda_function(_position);
325 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 Neon 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.
#define ARM_COMPUTE_PRINTF(...)
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.