24 #ifndef ARM_COMPUTE_WINDOW_H 25 #define ARM_COMPUTE_WINDOW_H 43 static constexpr
size_t DimX = 0;
45 static constexpr
size_t DimY = 1;
47 static constexpr
size_t DimZ = 2;
49 static constexpr
size_t DimW = 3;
51 static constexpr
size_t DimV = 4;
55 : _dims(), _is_broadcasted(utility::generate_array<bool,
Coordinates::num_max_dimensions, false>::value)
135 return (lhs._start == rhs._start) && (lhs._end == rhs._end) && (lhs._step == rhs._step);
186 void set(
size_t dimension,
const Dimension &dim);
214 void shift(
size_t dimension,
int shift_value);
232 void adjust(
size_t dimension,
int adjust_value,
bool is_at_start);
241 void scale(
size_t dimension,
float scale_value);
290 return first_slice_window<1>();
298 return first_slice_window<2>();
306 return first_slice_window<3>();
314 return first_slice_window<4>();
326 return slide_window_slice<1>(
slice);
338 return slide_window_slice<2>(
slice);
350 return slide_window_slice<3>(
slice);
362 return slide_window_slice<4>(
slice);
442 template <
unsigned int window_dimension>
443 Window first_slice_window()
const;
453 template <
unsigned int window_dimension>
457 std::array<Dimension, Coordinates::num_max_dimensions> _dims;
458 std::array<bool, Coordinates::num_max_dimensions> _is_broadcasted;
Window first_slice_window_2D() const
First 2D slice of the window.
void scale(size_t dimension, float scale_value)
Scale the values of a given dimension by the given scale_value.
void set_end(int end)
Set the dimension's end.
void shift(size_t dimension, int shift_value)
Shift the values of a given dimension by the given shift_value.
constexpr int step() const
Return the step of the dimension.
friend void swap(Window &lhs, Window &rhs)
Friend function that swaps the contents of two windows.
Store the tensor's metadata.
Window split_window(size_t dimension, size_t id, size_t total) const
Split a window into a set of sub windows along a given dimension.
Describe one of the image's dimensions with a start, end and step.
void validate() const
Will validate all the window's dimensions' values when asserts are enabled.
constexpr const Dimension & z() const
Alias to access the third dimension of the window.
constexpr size_t num_iterations(size_t dimension) const
Return the number of iterations needed to iterate through a given dimension.
friend bool operator==(const Dimension &lhs, const Dimension &rhs)
Check whether two Dimensions are equal.
void use_tensor_dimensions(const TensorShape &shape, size_t first_dimension=Window::DimX)
Use the tensor's dimensions to fill the window dimensions.
SimpleTensor< float > src
bool slide_window_slice_2D(Window &slice) const
Slide the passed 2D window slice.
Copyright (c) 2017-2022 Arm Limited.
Window collapse(const Window &full_window, size_t first, size_t last=Coordinates::num_max_dimensions) const
Collapse the dimensions between first and last.
Dimension & operator=(const Dimension &d)=default
Default assignment operator to allow dimensions to be copied.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
static constexpr size_t DimV
Alias for dimension 4 also known as V dimension.
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Window & operator=(const Window &rhs)
Copy assignment operator.
constexpr const Dimension & operator[](size_t dimension) const
Read only access to a given dimension of the window.
constexpr Window()
Default constructor: create a window containing a single element.
void set_step(int step)
Set the dimension's step.
static constexpr size_t DimW
Alias for dimension 3 also known as W dimension.
Window broadcast_if_dimension_le_one(const TensorShape &shape) const
Don't advance in the dimension where shape is less equal to 1.
bool is_broadcasted(size_t dimension) const
Return whether a dimension has been broadcasted.
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
constexpr Dimension(int start=0, int end=1, int step=1)
Constructor, by default creates a dimension of 1.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
void set_dimension_step(size_t dimension, int step)
Set the step of a given dimension.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Window collapse_if_possible(const Window &full_window, size_t first, bool *has_collapsed=nullptr) const
Collapse the dimensions higher than first if possible.
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
Window broadcast_if_dimension_le_one(const ITensorInfo &info) const
Don't advance in the dimension where shape of info is less equal to 1.
Window first_slice_window_4D() const
First 4D slice of the window.
bool slide_window_slice_4D(Window &slice) const
Slide the passed 4D window slice.
TensorShape shape() const
Return the shape of the window in number of steps.
constexpr int end() const
Return the end of the dimension.
void adjust(size_t dimension, int adjust_value, bool is_at_start)
Adjust the start or end of a given dimension by the given value.
void set_broadcasted(size_t dimension)
Set the dimension as broadcasted dimension.
static constexpr size_t num_max_dimensions
Number of dimensions the tensor has.
Window first_slice_window_3D() const
First 3D slice of the window.
bool slide_window_slice_1D(Window &slice) const
Slide the passed 1D window slice.
constexpr int start() const
Return the start of the dimension.
size_t num_iterations_total() const
Return the total number of iterations needed to iterate through the entire window.
Describe a multidimensional execution window.
Window shift_dimensions(unsigned int shift_value) const
Shift down all the dimensions of a window.
Window first_slice_window_1D() const
First 1D slice of the window.
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.