24 #ifndef ARM_COMPUTE_TEST_VALIDATION_UTILS_H 25 #define ARM_COMPUTE_TEST_VALIDATION_UTILS_H 33 #include <type_traits> 55 return ((x >= -border_size) && (y >= -border_size) && (x < (width + border_size)) && (y < height + border_size));
58 #pragma GCC diagnostic push 59 #pragma GCC diagnostic ignored "-Wstrict-overflow" 65 const int x = coord.
x();
66 const int y = coord.
y();
67 const int z = coord.
z();
68 const int width = src.
shape().x();
69 const int height = src.
shape().y();
70 const int depth = src.
shape().z();
73 if(x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= depth)
77 coord.
set(0, std::max(0, std::min(x, width - 1)));
78 coord.
set(1, std::max(0, std::min(y, height - 1)));
82 return constant_border_value;
89 #pragma GCC diagnostic pop 101 template <
typename T,
typename U,
typename V>
103 T constant_border_value = T(0))
106 const int x = coord.
x();
107 const int y = coord.
y();
108 for(
int j = y - static_cast<int>(filter_shape[1] / 2); j <= y + static_cast<int>(filter_shape[1] / 2); ++j)
110 for(
int i = x - static_cast<int>(filter_shape[0] / 2); i <= x + static_cast<int>(filter_shape[0] / 2); ++i)
114 val +=
static_cast<double>(*filter_itr) *
tensor_elem_at(src, coord, border_mode, constant_border_value);
BorderMode
Methods available to handle borders.
void set(size_t dimension, T value, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
T tensor_elem_at(const SimpleTensor< T > &src, Coordinates coord, BorderMode border_mode, T constant_border_value)
T trunc(T value)
Truncate floating-point value.
Subclass of SimpleTensor using uint8_t as value type.
void apply_2d_spatial_filter(Coordinates coord, const SimpleTensor< T > &src, SimpleTensor< U > &dst, const TensorShape &filter_shape, const V *filter_itr, double scale, BorderMode border_mode, T constant_border_value=T(0))
TensorShape shape() const override
Shape of the tensor.
bool is_valid_pixel_index(int x, int y, int width, int height, int border_size)
Checks if a pixel has valid coordinates.
SimpleTensor< float > src
Copyright (c) 2017-2022 Arm Limited.
int coord2index(const TensorShape &shape, const Coordinates &coord)
Linearise the given coordinate.
RawTensor transpose(const RawTensor &src, int chunk_width)
T x() const
Alias to access the size of the first dimension.
T z() const
Alias to access the size of the third dimension.
T bilinear_policy(const SimpleTensor< T > &in, Coordinates id, float xn, float yn, BorderMode border_mode, T constant_border_value)
Simple tensor object that stores elements in a consecutive chunk of memory.
Pixels outside the image are assumed to have the same value as the closest image pixel.
bool valid_bilinear_policy(float xn, float yn, int width, int height, BorderMode border_mode)
T y() const
Alias to access the size of the second dimension.