From 3ac2f3a1d9297220d1b0ce920dd13fdd4edcc187 Mon Sep 17 00:00:00 2001 From: Vidhya Sudhan Loganathan Date: Thu, 17 Jan 2019 15:16:19 +0000 Subject: COMPMID-1814 : NEScale add support for TOP_LEFT and QASYMM8 Added support for TOP_LEFT sampling policy and QASYMM8 data type. Change-Id: Id9135bb4b6ebd93f1d6fb70b06e83684a167eb94 Reviewed-on: https://review.mlplatform.org/533 Tested-by: Arm Jenkins Reviewed-by: Michalis Spyrou Reviewed-by: Georgios Pinitas --- arm_compute/core/Helpers.h | 36 ++++++++++++++++++++++++++- arm_compute/core/NEON/kernels/NEScaleKernel.h | 3 ++- 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'arm_compute') diff --git a/arm_compute/core/Helpers.h b/arm_compute/core/Helpers.h index 8f4220fb80..91d85be086 100644 --- a/arm_compute/core/Helpers.h +++ b/arm_compute/core/Helpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 ARM Limited. + * Copyright (c) 2016-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -144,6 +144,40 @@ inline T delta_bilinear_c1(const T *pixel_ptr, size_t stride, float dx, float dy return static_cast(a00 * w1 + a01 * w2 + a10 * w3 + a11 * w4); } +/** 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. + * + * @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 uint8_t delta_bilinear_c1_quantized(const uint8_t *pixel_ptr, size_t stride, float dx, float dy, QuantizationInfo iq_info, QuantizationInfo oq_info) +{ + ARM_COMPUTE_ERROR_ON(pixel_ptr == nullptr); + + const float dx1 = 1.0f - dx; + const float dy1 = 1.0f - dy; + + const float a00 = iq_info.dequantize(*pixel_ptr); + const float a01 = iq_info.dequantize(*(pixel_ptr + 1)); + const float a10 = iq_info.dequantize(*(pixel_ptr + stride)); + const float a11 = iq_info.dequantize(*(pixel_ptr + stride + 1)); + + 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(oq_info.quantize(res, RoundingPolicy::TO_NEAREST_UP)); +} + /** 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/arm_compute/core/NEON/kernels/NEScaleKernel.h b/arm_compute/core/NEON/kernels/NEScaleKernel.h index c851b3d335..83d99643dc 100644 --- a/arm_compute/core/NEON/kernels/NEScaleKernel.h +++ b/arm_compute/core/NEON/kernels/NEScaleKernel.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 ARM Limited. + * Copyright (c) 2016-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -110,6 +110,7 @@ private: InterpolationPolicy _policy; BorderSize _border_size; BorderMode _border_mode; + float _sampling_offset; }; } // namespace arm_compute #endif /*__ARM_COMPUTE_NESCALEKERNEL_H__ */ -- cgit v1.2.1