aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2019-07-09 14:21:06 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2019-07-11 13:31:25 +0000
commitd473386e4d5e0edcf55e13a2bf3c422a23fac0de (patch)
tree64c4132e8a46c809639d719e0426a7e6b9dd0371 /tests
parent9c9b70b9d30482d34f4f9c9dbc6479df163f96a1 (diff)
downloadComputeLibrary-d473386e4d5e0edcf55e13a2bf3c422a23fac0de.tar.gz
COMPMID-2447: Align TFlite nearest neighbor NE/CL functions with ACL
Change-Id: Idd7b23247491d6e2e31d19b2a8aa522470ca174c Signed-off-by: Michalis Spyrou <michalis.spyrou@arm.com> Reviewed-on: https://review.mlplatform.org/c/1500 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/validation/reference/CropResize.cpp4
-rw-r--r--tests/validation/reference/Scale.cpp47
2 files changed, 31 insertions, 20 deletions
diff --git a/tests/validation/reference/CropResize.cpp b/tests/validation/reference/CropResize.cpp
index 8cfce97eec..f25a0317be 100644
--- a/tests/validation/reference/CropResize.cpp
+++ b/tests/validation/reference/CropResize.cpp
@@ -59,8 +59,8 @@ SimpleTensor<float> scale_image(const SimpleTensor<float> &in, const TensorShape
case InterpolationPolicy::NEAREST_NEIGHBOR:
{
//Calculate the source coords without -0.5f is equivalent to round the x_scr/y_src coords
- float x_src = (idw + 0.5f) * wr;
- float y_src = (idh + 0.5f) * hr;
+ float x_src = std::floor(idw * wr);
+ float y_src = std::floor(idh * hr);
in_id.set(1, x_src);
in_id.set(2, y_src);
diff --git a/tests/validation/reference/Scale.cpp b/tests/validation/reference/Scale.cpp
index 84f4fb83c1..63a2853c66 100644
--- a/tests/validation/reference/Scale.cpp
+++ b/tests/validation/reference/Scale.cpp
@@ -71,28 +71,25 @@ SimpleTensor<T> scale_core(const SimpleTensor<T> &in, float scale_x, float scale
float x_src = 0;
float y_src = 0;
- switch(sampling_policy)
- {
- case SamplingPolicy::TOP_LEFT:
- x_src = idx * wr;
- y_src = idy * hr;
- break;
- case SamplingPolicy::CENTER:
- x_src = (idx + 0.5f) * wr - 0.5f;
- y_src = (idy + 0.5f) * hr - 0.5f;
- break;
- default:
- ARM_COMPUTE_ERROR("Unsupported sampling policy.");
- break;
- }
-
switch(policy)
{
case InterpolationPolicy::NEAREST_NEIGHBOR:
{
- //Calculate the source coords without -0.5f is equivalent to round the x_scr/y_src coords
- x_src = (idx + 0.5f) * wr;
- y_src = (idy + 0.5f) * hr;
+ switch(sampling_policy)
+ {
+ case SamplingPolicy::TOP_LEFT:
+ x_src = std::floor(idx * wr);
+ y_src = std::floor(idy * hr);
+ break;
+ case SamplingPolicy::CENTER:
+ //Calculate the source coords without -0.5f is equivalent to round the x_scr/y_src coords
+ x_src = (idx + 0.5f) * wr;
+ y_src = (idy + 0.5f) * hr;
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Unsupported sampling policy.");
+ }
+
id.set(0, x_src);
id.set(1, y_src);
@@ -105,6 +102,20 @@ SimpleTensor<T> scale_core(const SimpleTensor<T> &in, float scale_x, float scale
}
case InterpolationPolicy::BILINEAR:
{
+ switch(sampling_policy)
+ {
+ case SamplingPolicy::TOP_LEFT:
+ x_src = idx * wr;
+ y_src = idy * hr;
+ break;
+ case SamplingPolicy::CENTER:
+ x_src = (idx + 0.5f) * wr - 0.5f;
+ y_src = (idy + 0.5f) * hr - 0.5f;
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Unsupported sampling policy.");
+ }
+
id.set(0, std::floor(x_src));
id.set(1, std::floor(y_src));
if(is_valid_pixel_index(x_src, y_src, width, height, border_size))