diff options
Diffstat (limited to 'tests/validation/CPP/Utils.cpp')
-rw-r--r-- | tests/validation/CPP/Utils.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/tests/validation/CPP/Utils.cpp b/tests/validation/CPP/Utils.cpp index 15e9fc3138..2f54879818 100644 --- a/tests/validation/CPP/Utils.cpp +++ b/tests/validation/CPP/Utils.cpp @@ -24,7 +24,6 @@ #include "Utils.h" #include "tests/validation/Helpers.h" -#include "tests/validation/half.h" namespace arm_compute { @@ -51,17 +50,20 @@ T tensor_elem_at(const SimpleTensor<T> &in, Coordinates coord, BorderMode border } else { - return constant_border_value; + return static_cast<T>(constant_border_value); } } return in[coord2index(in.shape(), coord)]; } -template float tensor_elem_at(const SimpleTensor<float> &in, Coordinates coord, BorderMode border_mode, float constant_border_value); + template uint8_t tensor_elem_at(const SimpleTensor<uint8_t> &in, Coordinates coord, BorderMode border_mode, uint8_t constant_border_value); +template int16_t tensor_elem_at(const SimpleTensor<int16_t> &in, Coordinates coord, BorderMode border_mode, int16_t constant_border_value); +template half tensor_elem_at(const SimpleTensor<half> &in, Coordinates coord, BorderMode border_mode, half constant_border_value); +template float tensor_elem_at(const SimpleTensor<float> &in, Coordinates coord, BorderMode border_mode, float constant_border_value); // Return the bilinear value at a specified coordinate with different border modes template <typename T> -T bilinear_policy(const SimpleTensor<T> &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value) +T bilinear_policy(const SimpleTensor<T> &in, Coordinates id, float xn, float yn, BorderMode border_mode, T constant_border_value) { int idx = std::floor(xn); int idy = std::floor(yn); @@ -71,22 +73,28 @@ T bilinear_policy(const SimpleTensor<T> &in, Coordinates id, float xn, float yn, const float dx_1 = 1.0f - dx; const float dy_1 = 1.0f - dy; + const T border_value = constant_border_value; + id.set(0, idx); id.set(1, idy); - const T tl = tensor_elem_at(in, id, border_mode, constant_border_value); + const float tl = tensor_elem_at(in, id, border_mode, border_value); id.set(0, idx + 1); id.set(1, idy); - const T tr = tensor_elem_at(in, id, border_mode, constant_border_value); + const float tr = tensor_elem_at(in, id, border_mode, border_value); id.set(0, idx); id.set(1, idy + 1); - const T bl = tensor_elem_at(in, id, border_mode, constant_border_value); + const float bl = tensor_elem_at(in, id, border_mode, border_value); id.set(0, idx + 1); id.set(1, idy + 1); - const T br = tensor_elem_at(in, id, border_mode, constant_border_value); + const float br = tensor_elem_at(in, id, border_mode, border_value); - return tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy); + return static_cast<T>(tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy)); } + template uint8_t bilinear_policy(const SimpleTensor<uint8_t> &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value); +template int16_t bilinear_policy(const SimpleTensor<int16_t> &in, Coordinates id, float xn, float yn, BorderMode border_mode, int16_t constant_border_value); +template half bilinear_policy(const SimpleTensor<half> &in, Coordinates id, float xn, float yn, BorderMode border_mode, half constant_border_value); +template float bilinear_policy(const SimpleTensor<float> &in, Coordinates id, float xn, float yn, BorderMode border_mode, float constant_border_value); /* Apply 2D spatial filter on a single element of @p in at coordinates @p coord * |