From 583137cc60580023abfd9d05abf933e7e117e29f Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Thu, 31 Aug 2017 18:12:42 +0100 Subject: COMPMID-417: Add support for floats in scale. Change-Id: I7d714ba13861509080a89817f54e9d32da83e970 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/86026 Reviewed-by: Pablo Tello Tested-by: Kaizen --- tests/validation/CPP/Utils.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'tests/validation/CPP/Utils.cpp') 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 &in, Coordinates coord, BorderMode border } else { - return constant_border_value; + return static_cast(constant_border_value); } } return in[coord2index(in.shape(), coord)]; } -template float tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, float constant_border_value); + template uint8_t tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, uint8_t constant_border_value); +template int16_t tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, int16_t constant_border_value); +template half tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, half constant_border_value); +template float tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, float constant_border_value); // Return the bilinear value at a specified coordinate with different border modes template -T bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value) +T bilinear_policy(const SimpleTensor &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 &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(tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy)); } + template uint8_t bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value); +template int16_t bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, int16_t constant_border_value); +template half bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, half constant_border_value); +template float bilinear_policy(const SimpleTensor &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 * -- cgit v1.2.1