From 1fab09f36bdd1e5473bb019cf9639f4a92b4daa1 Mon Sep 17 00:00:00 2001 From: Isabella Gottardi Date: Thu, 13 Jul 2017 15:55:57 +0100 Subject: COMPMID-424 Implemented reference implementation, new output valid region and validation tests (NEON and CL) for Scale Change-Id: I056fa3588b807a97cacf0b8afaec56e37ffc92af Reviewed-on: http://mpd-gerrit.cambridge.arm.com/83872 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- tests/validation/TensorOperations.h | 82 +++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'tests/validation/TensorOperations.h') diff --git a/tests/validation/TensorOperations.h b/tests/validation/TensorOperations.h index e68a344112..f157671c18 100644 --- a/tests/validation/TensorOperations.h +++ b/tests/validation/TensorOperations.h @@ -24,6 +24,8 @@ #ifndef __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ #define __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ +#include "arm_compute/core/FixedPoint.h" +#include "arm_compute/core/Helpers.h" #include "arm_compute/core/Types.h" #include "support/ToolchainSupport.h" #include "tests/Types.h" @@ -116,6 +118,46 @@ void apply_2d_spatial_filter(Coordinates coord, const Tensor &in, Tensor } } // namespace +template +T bilinear_policy(const Tensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value) +{ + int idx = std::floor(xn); + int idy = std::floor(yn); + + const float dx = xn - idx; + const float dy = yn - idy; + const float dx_1 = 1.0f - dx; + const float dy_1 = 1.0f - dy; + + id.set(0, idx); + id.set(1, idy); + const T tl = tensor_elem_at(in, id, border_mode, constant_border_value); + id.set(0, idx + 1); + id.set(1, idy); + const T tr = tensor_elem_at(in, id, border_mode, constant_border_value); + id.set(0, idx); + id.set(1, idy + 1); + const T bl = tensor_elem_at(in, id, border_mode, constant_border_value); + id.set(0, idx + 1); + id.set(1, idy + 1); + const T br = tensor_elem_at(in, id, border_mode, constant_border_value); + + return tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy); +} + +bool valid_bilinear_policy(float xn, float yn, int width, int height, BorderMode border_mode) +{ + if(border_mode != BorderMode::UNDEFINED) + { + return true; + } + if((0 <= yn + 1) && (yn + 1 < height) && (0 <= xn + 1) && (xn + 1 < width)) + { + return true; + } + return false; +} + // Sobel 3x3 template void sobel_3x3(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) @@ -881,46 +923,6 @@ void threshold(const Tensor &in, Tensor &out, uint8_t threshold, uint8_t f } } -template -T bilinear_policy(const Tensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value) -{ - int idx = std::floor(xn); - int idy = std::floor(yn); - - const float dx = xn - idx; - const float dy = yn - idy; - const float dx_1 = 1.0f - dx; - const float dy_1 = 1.0f - dy; - - id.set(0, idx); - id.set(1, idy); - const T tl = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx + 1); - id.set(1, idy); - const T tr = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx); - id.set(1, idy + 1); - const T bl = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx + 1); - id.set(1, idy + 1); - const T br = tensor_elem_at(in, id, border_mode, constant_border_value); - - return tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy); -} - -bool valid_bilinear_policy(float xn, float yn, int width, int height, BorderMode border_mode) -{ - if(border_mode != BorderMode::UNDEFINED) - { - return true; - } - if((0 <= yn + 1) && (yn + 1 < height) && (0 <= xn + 1) && (xn + 1 < width)) - { - return true; - } - return false; -} - // Warp Perspective template void warp_perspective(const Tensor &in, Tensor &out, Tensor &valid_mask, const float *matrix, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -- cgit v1.2.1