38 const int idx = std::floor(xn);
39 const int idy = std::floor(yn);
41 const float dx = xn - idx;
42 const float dy = yn - idy;
43 const float dx_1 = 1.0f - dx;
44 const float dy_1 = 1.0f - dy;
46 const T border_value = constant_border_value;
50 const float tl =
tensor_elem_at(in,
id, border_mode, border_value);
53 const float tr =
tensor_elem_at(in,
id, border_mode, border_value);
56 const float bl =
tensor_elem_at(in,
id, border_mode, border_value);
59 const float br =
tensor_elem_at(in,
id, border_mode, border_value);
61 return static_cast<T
>(tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy));
80 uint8_t *out_ptr =
dst.data();
82 for(
int i = 0; i <
dst.num_elements(); i += chunk_width)
85 size_t coord_x = coord.
x();
86 coord.
set(0, coord.
y() * chunk_width);
87 coord.
set(1, coord_x / chunk_width);
89 const int num_elements = std::min<int>(chunk_width, src.
shape().
x() - coord.
x());
91 std::copy_n(static_cast<const uint8_t *>(
src(coord)), num_elements * src.
element_size(), out_ptr);
93 out_ptr += chunk_width *
dst.element_size();
105 if((0 <= yn + 1) && (yn + 1 < height) && (0 <= xn + 1) && (xn + 1 < width))
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)
size_t element_size() const override
Size of each element in the tensor in bytes.
Subclass of SimpleTensor using uint8_t as value type.
half_float::half half
16-bit floating point type
DataType data_type() const override
Data type of the tensor.
TensorShape shape() const override
Shape of the tensor.
SimpleTensor< float > src
Copyright (c) 2017-2021 Arm Limited.
RawTensor transpose(const RawTensor &src, int chunk_width)
T x() const
Alias to access the size of the first dimension.
T bilinear_policy(const SimpleTensor< T > &in, Coordinates id, float xn, float yn, BorderMode border_mode, T constant_border_value)
Coordinates index2coord(const TensorShape &shape, int index)
Convert a linear index into n-dimensional coordinates.
Simple tensor object that stores elements in a consecutive chunk of memory.
Borders are left undefined.
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.
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.