24 #ifndef ARM_COMPUTE_TEST_VALIDATION_UTILS_H 25 #define ARM_COMPUTE_TEST_VALIDATION_UTILS_H 34 #include <type_traits> 56 return ((x >= -border_size) && (y >= -border_size) && (x < (width + border_size)) && (y < height + border_size));
59 #pragma GCC diagnostic push 60 #pragma GCC diagnostic ignored "-Wstrict-overflow" 66 const int x = coord.
x();
67 const int y = coord.
y();
68 const int z = coord.
z();
69 const int width = src.
shape().x();
70 const int height = src.
shape().y();
71 const int depth = src.
shape().z();
74 if(x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= depth)
78 coord.
set(0, std::max(0, std::min(x, width - 1)));
79 coord.
set(1, std::max(0, std::min(y, height - 1)));
83 return constant_border_value;
90 #pragma GCC diagnostic pop 102 template <
typename T,
typename U,
typename V>
104 T constant_border_value = T(0))
107 const int x = coord.
x();
108 const int y = coord.
y();
109 for(
int j = y - static_cast<int>(filter_shape[1] / 2); j <= y + static_cast<int>(filter_shape[1] / 2); ++j)
111 for(
int i = x - static_cast<int>(filter_shape[0] / 2); i <= x + static_cast<int>(filter_shape[0] / 2); ++i)
115 val +=
static_cast<double>(*filter_itr) *
tensor_elem_at(src, coord, border_mode, constant_border_value);
130 template <std::
size_t SIZE>
133 std::mt19937 gen(
library.get()->seed());
134 std::uniform_real_distribution<float> dist(-1, 1);
135 for(
auto &x : matrix)
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-2021 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.
std::unique_ptr< AssetsLibrary > library
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.
void fill_warp_matrix(std::array< float, SIZE > &matrix)
Fill matrix random.