23.08
|
Go to the documentation of this file.
24 #ifndef ARM_COMPUTE_HELPERS_H
25 #define ARM_COMPUTE_HELPERS_H
82 constexpr
size_t offset()
const;
90 constexpr uint8_t *
ptr()
const;
96 void reset(
size_t dimension);
108 void initialize(
size_t num_dims,
const Strides &strides, uint8_t *buffer,
size_t offset,
const Window &window);
115 constexpr Dimension()
116 : _dim_start(0), _stride(0)
124 std::array<Dimension, Coordinates::num_max_dimensions> _dims;
135 template <
typename L,
typename... Ts>
145 template <
typename T>
148 auto dimensions_copy = utility::make_array<Dimensions<T>::num_max_dimensions>(dimensions.
begin(), dimensions.
end());
151 T dimension_val = (perm[i] < dimensions.
num_dimensions()) ? dimensions_copy[perm[i]] : 0;
152 dimensions.
set(i, dimension_val);
168 size_t dimension_val = (perm[i] <
shape.num_dimensions()) ? shape_copy[perm[i]] : 1;
169 shape.set(i, dimension_val,
false,
false);
218 const std::map<DataLayout, std::vector<DataLayoutDimension>> &
get_layout_map();
250 int num_tiles_x = std::ceil((in_dims.
width - (kernel_size.
width - 1) +
conv_info.pad_left() +
conv_info.pad_right()) /
static_cast<float>(output_tile_size.
width));
254 num_tiles_x = std::min(num_tiles_x,
static_cast<int>(in_dims.
width));
255 num_tiles_y = std::min(num_tiles_y,
static_cast<int>(in_dims.
height));
257 return Size2D(num_tiles_x, num_tiles_y);
267 template <
typename T>
270 return x >= 0 ? x %
m : (x %
m +
m) %
m;
void set(size_t dimension, T value, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
DataLayout
[DataLayout enum definition]
void increment(size_t dimension)
Increment the iterator along the specified dimension of the step value associated to the dimension.
Size2D compute_winograd_convolution_tiles(const Size2D &in_dims, const Size2D &kernel_size, const Size2D &output_tile_size, const PadStrideInfo &conv_info)
Calculate the number of output tiles required by Winograd Convolution layer.
DataLayoutDimension
[DataLayout enum definition]
SamplingPolicy
Available Sampling Policies.
Class for specifying the size of an image or rectangle.
InterpolationPolicy
Interpolation method.
Coordinates index2coords(const TensorShape &shape, int index)
Convert a linear index into n-dimensional coordinates.
void permute(Dimensions< T > &dimensions, const PermutationVector &perm)
Permutes given Dimensions according to a permutation vector.
size_t height
Height of the image region or rectangle.
Interface for CPU tensor.
T wrap_around(T x, T m)
Wrap-around a number within the range 0 <= x < m.
Strides of an item in bytes.
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
const std::map< DataLayout, std::vector< DataLayoutDimension > > & get_layout_map()
Returns a static map used to find an index or dimension based on a data layout.
size_t width
Width of the image region or rectangle.
Iterator updated by execute_window_loop for each window element.
constexpr Iterator()
Default constructor to create an empty iterator.
CLTensor * tensor
Pointer to the auxiliary tensor.
void reset(size_t dimension)
Move the iterator back to the beginning of the specified dimension.
std::array< T, num_max_dimensions >::iterator begin()
Returns a read/write iterator that points to the first element in the dimension array.
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
int coords2index(const TensorShape &shape, const Coordinates &coord)
Convert n-dimensional coordinates into a linear index.
Describe a multidimensional execution window.
ValidRegion calculate_valid_region_scale(const ITensorInfo &src_info, const TensorShape &dst_shape, InterpolationPolicy interpolate_policy, SamplingPolicy sampling_policy, bool border_undefined)
Helper function to calculate the Valid Region for Scale.
constexpr size_t offset() const
Return the offset in bytes from the first element to the current position of the iterator.
Copyright (c) 2017-2023 Arm Limited.
TensorInfo src_info(src_shape, 1, data_type)
std::array< T, num_max_dimensions >::iterator end()
Returns a read/write iterator that points one past the last element in the dimension array.
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...
Dimensions with dimensionality.
Coordinates & convert_negative_axis(Coordinates &coords, int max_value)
Convert negative coordinates to positive in the range [0, num_dims_input].
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
DataLayoutDimension get_index_data_layout_dimension(const DataLayout &data_layout, const size_t index)
Get the DataLayoutDimension of a given index and layout.