aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Di Giorgio <michele.digiorgio@arm.com>2020-07-30 14:52:16 +0100
committerMichele Di Giorgio <michele.digiorgio@arm.com>2020-07-31 14:04:56 +0000
commit7a81d2aaf33d1d134148d051b901567db5908922 (patch)
treed56e1d89fb1c94f7f2697ee61c8d886f38c56643
parentef6ec50eff04adb3e5d60ba96a1a7d9118b10c5a (diff)
downloadComputeLibrary-7a81d2aaf33d1d134148d051b901567db5908922.tar.gz
COMPMID-3624: CTS failure on Resize quantized in Neon and CL
Allow computations with aligned corners when the tensors have width/height equal to 1. Change-Id: Ia01733f6c02e0740835b26a794b9a79fa35319b4 Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3634 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Sadik Armagan <sadik.armagan@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--src/core/CL/kernels/CLScaleKernel.cpp4
-rw-r--r--src/core/NEON/kernels/NEScaleKernel.cpp2
-rw-r--r--src/core/utils/ScaleUtils.cpp9
-rw-r--r--src/core/utils/ScaleUtils.h9
-rw-r--r--src/runtime/NEON/functions/NEScale.cpp3
-rw-r--r--tests/validation/reference/Scale.cpp2
6 files changed, 5 insertions, 24 deletions
diff --git a/src/core/CL/kernels/CLScaleKernel.cpp b/src/core/CL/kernels/CLScaleKernel.cpp
index 108358bf2..2e7ee36bc 100644
--- a/src/core/CL/kernels/CLScaleKernel.cpp
+++ b/src/core/CL/kernels/CLScaleKernel.cpp
@@ -72,7 +72,7 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, c
ARM_COMPUTE_RETURN_ERROR_ON(output == input);
ARM_COMPUTE_RETURN_ERROR_ON(info.align_corners && !arm_compute::scale_utils::is_align_corners_allowed_sampling_policy(info.sampling_policy));
- const bool will_use_align_corners = info.align_corners && arm_compute::scale_utils::is_align_corners_allowed_output_shape(output->tensor_shape(), output->data_layout());
+ const bool will_use_align_corners = info.align_corners;
float wr = 0.f;
float hr = 0.f;
@@ -177,7 +177,7 @@ void CLScaleKernel::configure(const CLCompileContext &compile_context, const ICL
_output = output;
_interpolation_policy = info.interpolation_policy;
_data_layout = input->info()->data_layout();
- _align_corners = info.align_corners && arm_compute::scale_utils::is_align_corners_allowed_output_shape(output->info()->tensor_shape(), _data_layout);
+ _align_corners = info.align_corners;
float wr = 0.f;
float hr = 0.f;
diff --git a/src/core/NEON/kernels/NEScaleKernel.cpp b/src/core/NEON/kernels/NEScaleKernel.cpp
index 7ce1786d5..94fcfe2ff 100644
--- a/src/core/NEON/kernels/NEScaleKernel.cpp
+++ b/src/core/NEON/kernels/NEScaleKernel.cpp
@@ -369,7 +369,7 @@ void NEScaleKernel::configure(const ITensor *input, const ITensor *dx, const ITe
_border_mode = info.border_mode;
_constant_border_value = info.constant_border_value;
_use_padding = info.use_padding;
- _align_corners = info.align_corners && arm_compute::scale_utils::is_align_corners_allowed_output_shape(output->info()->tensor_shape(), data_layout);
+ _align_corners = info.align_corners;
if(info.sampling_policy == SamplingPolicy::CENTER)
{
diff --git a/src/core/utils/ScaleUtils.cpp b/src/core/utils/ScaleUtils.cpp
index bf059f7df..d46ca0ea8 100644
--- a/src/core/utils/ScaleUtils.cpp
+++ b/src/core/utils/ScaleUtils.cpp
@@ -26,7 +26,7 @@
float arm_compute::scale_utils::calculate_resize_ratio(size_t input_size, size_t output_size, bool align_corners)
{
- const size_t offset = align_corners ? 1 : 0;
+ const size_t offset = (align_corners && output_size > 1) ? 1 : 0;
const auto in = input_size - offset;
const auto out = output_size - offset;
@@ -34,11 +34,4 @@ float arm_compute::scale_utils::calculate_resize_ratio(size_t input_size, size_t
ARM_COMPUTE_ERROR_ON(out == 0);
return static_cast<float>(in) / static_cast<float>(out);
-}
-
-bool arm_compute::scale_utils::is_align_corners_allowed_output_shape(const TensorShape &output_shape, DataLayout layout)
-{
- const size_t idx_width = get_data_layout_dimension_index(layout, DataLayoutDimension::WIDTH);
- const size_t idx_height = get_data_layout_dimension_index(layout, DataLayoutDimension::HEIGHT);
- return (output_shape[idx_width] > 1) && (output_shape[idx_height] > 1);
} \ No newline at end of file
diff --git a/src/core/utils/ScaleUtils.h b/src/core/utils/ScaleUtils.h
index 894bd1edc..3cc986b1d 100644
--- a/src/core/utils/ScaleUtils.h
+++ b/src/core/utils/ScaleUtils.h
@@ -53,15 +53,6 @@ inline bool is_align_corners_allowed_sampling_policy(SamplingPolicy sampling_pol
{
return sampling_policy != SamplingPolicy::CENTER;
}
-
-/** Returns if aligned corners are allowed for the given output shape
- *
- * @param[in] output_shape The shape of the scaled output tensor
- * @param[in] layout The data layout of the output tensor
- *
- * @return True if aligned corners are allowed
- */
-bool is_align_corners_allowed_output_shape(const TensorShape &output_shape, DataLayout layout);
} // namespace scale_utils
} // namespace arm_compute
#endif /* UTILS_CORE_SCALEUTILS_H */ \ No newline at end of file
diff --git a/src/runtime/NEON/functions/NEScale.cpp b/src/runtime/NEON/functions/NEScale.cpp
index 411f663f4..424049f24 100644
--- a/src/runtime/NEON/functions/NEScale.cpp
+++ b/src/runtime/NEON/functions/NEScale.cpp
@@ -111,8 +111,7 @@ void NEScale::configure(ITensor *input, ITensor *output, const ScaleKernelInfo &
ARM_COMPUTE_ERROR_THROW_ON(NEScale::validate(input->info(), output->info(), info));
_use_padding = info.use_padding;
- const bool is_align_corners_used = info.align_corners && arm_compute::scale_utils::is_align_corners_allowed_sampling_policy(info.sampling_policy)
- && arm_compute::scale_utils::is_align_corners_allowed_output_shape(output->info()->tensor_shape(), output->info()->data_layout());
+ const bool is_align_corners_used = info.align_corners && arm_compute::scale_utils::is_align_corners_allowed_sampling_policy(info.sampling_policy);
// Get data layout and width/height indices
const DataLayout data_layout = input->info()->data_layout();
diff --git a/tests/validation/reference/Scale.cpp b/tests/validation/reference/Scale.cpp
index 0c8f5ba1c..aa265c26c 100644
--- a/tests/validation/reference/Scale.cpp
+++ b/tests/validation/reference/Scale.cpp
@@ -48,8 +48,6 @@ SimpleTensor<T> scale_core(const SimpleTensor<T> &in, float scale_x, float scale
shape_scaled.set(1, (in.shape()[1] + round_value) * scale_y, /* apply_dim_correction = */ false);
SimpleTensor<T> out(shape_scaled, in.data_type());
- align_corners = align_corners && arm_compute::scale_utils::is_align_corners_allowed_output_shape(out.shape(), DataLayout::NCHW);
-
// Compute the ratio between source width/height and destination width/height
const auto wr = arm_compute::scale_utils::calculate_resize_ratio(in.shape()[0], out.shape()[0], align_corners);
const auto hr = arm_compute::scale_utils::calculate_resize_ratio(in.shape()[1], out.shape()[1], align_corners);