From 94d5051bc56a59d857f8a09560e2da5c0d7894b0 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Thu, 2 Jul 2020 10:49:39 +0100 Subject: COMPMID-3539: Change indexing for nearest neighbor with aligned corners For nearest neighbor interpolation policy with aligned corners all of NEON, CL and reference use round() rather than float to find the nearest integer. Change-Id: If0360da870e983303bf0424ca1100084084c1efc Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3495 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- tests/validation/GLES_COMPUTE/Scale.cpp | 2 +- tests/validation/reference/Scale.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/validation/GLES_COMPUTE/Scale.cpp b/tests/validation/GLES_COMPUTE/Scale.cpp index 7a88159481..62b30da7a2 100644 --- a/tests/validation/GLES_COMPUTE/Scale.cpp +++ b/tests/validation/GLES_COMPUTE/Scale.cpp @@ -52,7 +52,7 @@ const auto ScaleDataTypes = framework::dataset::make("DataType", DataType::F16, }); -/** Align corners, this functionality is supported only by NEON */ +/** Aligned corners, this functionality is supported only by NEON and OpenCL backends */ const auto AlignCorners = framework::dataset::make("AlignCorners", { false, diff --git a/tests/validation/reference/Scale.cpp b/tests/validation/reference/Scale.cpp index 44beabb2d4..72f96d446d 100644 --- a/tests/validation/reference/Scale.cpp +++ b/tests/validation/reference/Scale.cpp @@ -25,6 +25,7 @@ #include "Scale.h" #include "Utils.h" +#include "arm_compute/core/utils/misc/Rounding.h" #include "arm_compute/core/utils/misc/Utility.h" #include "src/core/utils/ScaleUtils.h" @@ -81,8 +82,8 @@ SimpleTensor scale_core(const SimpleTensor &in, float scale_x, float scale switch(sampling_policy) { case SamplingPolicy::TOP_LEFT: - x_src = std::floor(idx * wr); - y_src = std::floor(idy * hr); + x_src = align_corners ? arm_compute::utils::rounding::round_half_away_from_zero(idx * wr) : std::floor(idx * wr); + y_src = align_corners ? arm_compute::utils::rounding::round_half_away_from_zero(idy * hr) : 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 -- cgit v1.2.1