aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Di Giorgio <michele.digiorgio@arm.com>2020-05-04 16:44:28 +0100
committerTeresaARM <teresa.charlinreyes@arm.com>2020-05-04 20:09:24 +0000
commit6f7585b21a13f4792ef1a55ac943997491ba8aec (patch)
tree8dc89d75a5e1937f2a28e93be34675f51f602ea9
parent359c48eaf251cbb84b523e5a67a099c739482e6c (diff)
downloadComputeLibrary-6f7585b21a13f4792ef1a55ac943997491ba8aec.tar.gz
COMPMID-3441: Nightly failed due to NEScale QASYMM8_SIGNED output wrong result
Change-Id: I4a97523408f44c509ba0f6bf180c56ea33b964cf Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3138 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Sheri Zhang <sheri.zhang@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--arm_compute/core/Helpers.h36
-rw-r--r--src/core/NEON/kernels/NEScaleKernel.cpp10
2 files changed, 36 insertions, 10 deletions
diff --git a/arm_compute/core/Helpers.h b/arm_compute/core/Helpers.h
index 34e4e6f885..09c672ecfa 100644
--- a/arm_compute/core/Helpers.h
+++ b/arm_compute/core/Helpers.h
@@ -146,7 +146,7 @@ inline T delta_bilinear_c1(const T *pixel_ptr, size_t stride, float dx, float dy
}
/** Computes bilinear interpolation for quantized input and output, using the pointer to the top-left pixel and the pixel's distance between
- * the real coordinates and the smallest following integer coordinates. Input must be quantized and in single channel format.
+ * the real coordinates and the smallest following integer coordinates. Input must be QASYMM8 and in single channel format.
*
* @param[in] pixel_ptr Pointer to the top-left pixel value of a single channel input.
* @param[in] stride Stride to access the bottom-left and bottom-right pixel values
@@ -179,6 +179,40 @@ inline uint8_t delta_bilinear_c1_quantized(const uint8_t *pixel_ptr, size_t stri
return static_cast<uint8_t>(quantize_qasymm8(res, oq_info));
}
+/** Computes bilinear interpolation for quantized input and output, using the pointer to the top-left pixel and the pixel's distance between
+ * the real coordinates and the smallest following integer coordinates. Input must be QASYMM8_SIGNED and in single channel format.
+ *
+ * @param[in] pixel_ptr Pointer to the top-left pixel value of a single channel input.
+ * @param[in] stride Stride to access the bottom-left and bottom-right pixel values
+ * @param[in] dx Pixel's distance between the X real coordinate and the smallest X following integer
+ * @param[in] dy Pixel's distance between the Y real coordinate and the smallest Y following integer
+ * @param[in] iq_info Input QuantizationInfo
+ * @param[in] oq_info Output QuantizationInfo
+ *
+ * @note dx and dy must be in the range [0, 1.0]
+ *
+ * @return The bilinear interpolated pixel value
+ */
+inline int8_t delta_bilinear_c1_quantized(const int8_t *pixel_ptr, size_t stride, float dx, float dy, UniformQuantizationInfo iq_info, UniformQuantizationInfo oq_info)
+{
+ ARM_COMPUTE_ERROR_ON(pixel_ptr == nullptr);
+
+ const float dx1 = 1.0f - dx;
+ const float dy1 = 1.0f - dy;
+
+ const float a00 = dequantize_qasymm8_signed(*pixel_ptr, iq_info);
+ const float a01 = dequantize_qasymm8_signed(*(pixel_ptr + 1), iq_info);
+ const float a10 = dequantize_qasymm8_signed(*(pixel_ptr + stride), iq_info);
+ const float a11 = dequantize_qasymm8_signed(*(pixel_ptr + stride + 1), iq_info);
+
+ const float w1 = dx1 * dy1;
+ const float w2 = dx * dy1;
+ const float w3 = dx1 * dy;
+ const float w4 = dx * dy;
+ float res = a00 * w1 + a01 * w2 + a10 * w3 + a11 * w4;
+ return static_cast<int8_t>(quantize_qasymm8_signed(res, oq_info));
+}
+
/** Computes linear interpolation using the pointer to the top pixel and the pixel's distance between
* the real coordinates and the smallest following integer coordinates. Input must be in single channel format.
*
diff --git a/src/core/NEON/kernels/NEScaleKernel.cpp b/src/core/NEON/kernels/NEScaleKernel.cpp
index 47a02d77c5..4f2f925c3c 100644
--- a/src/core/NEON/kernels/NEScaleKernel.cpp
+++ b/src/core/NEON/kernels/NEScaleKernel.cpp
@@ -25,20 +25,12 @@
#include "arm_compute/core/AccessWindowStatic.h"
#include "arm_compute/core/CPP/Validate.h"
-#include "arm_compute/core/Coordinates.h"
-#include "arm_compute/core/Error.h"
#include "arm_compute/core/Helpers.h"
-#include "arm_compute/core/ITensor.h"
#include "arm_compute/core/NEON/wrapper/wrapper.h"
-#include "arm_compute/core/TensorInfo.h"
-#include "arm_compute/core/Utils.h"
-#include "arm_compute/core/Validate.h"
#include "arm_compute/core/Window.h"
#include "arm_compute/core/utils/misc/Utility.h"
#include <arm_neon.h>
-#include <cstddef>
-#include <cstdint>
namespace arm_compute
{
@@ -724,7 +716,7 @@ void NEScaleKernel::scale_bilinear_nchw(const Window &window)
const auto offsets_ptr = reinterpret_cast<const int32_t *>(offsets.ptr());
const auto dx_ptr = reinterpret_cast<const float *>(dx.ptr());
const auto dy_ptr = reinterpret_cast<const float *>(dy.ptr());
- const auto in_ptr = reinterpret_cast<const uint8_t *>(in.ptr());
+ const auto in_ptr = reinterpret_cast<const int8_t *>(in.ptr());
const int in_yi = std::floor((id.y() + _sampling_offset) * hr - _sampling_offset);
const int offset_row = in_yi * in_stide_in_bytes;