From 43ce898014faabbe8ab1cdf714b7aad3d3c9b2a9 Mon Sep 17 00:00:00 2001 From: Isabella Gottardi Date: Wed, 8 Nov 2017 11:13:23 +0000 Subject: COMPMID-670 - Extend Sobel tests Change-Id: Ibf15544e8624977815ee355071a038c07e1f01c2 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/94874 Tested-by: Kaizen Reviewed-by: Georgios Pinitas --- tests/validation/CPP/HarrisCornerDetector.cpp | 2 +- tests/validation/CPP/Sobel.cpp | 32 ++++++++++++++++++++------- tests/validation/CPP/Sobel.h | 3 ++- 3 files changed, 27 insertions(+), 10 deletions(-) (limited to 'tests/validation/CPP') diff --git a/tests/validation/CPP/HarrisCornerDetector.cpp b/tests/validation/CPP/HarrisCornerDetector.cpp index 3babfeed42..6cfcd8ecc5 100644 --- a/tests/validation/CPP/HarrisCornerDetector.cpp +++ b/tests/validation/CPP/HarrisCornerDetector.cpp @@ -45,7 +45,7 @@ std::tuple, SimpleTensor, float> compute_sobel(const SimpleTe SimpleTensor grad_y; float norm_factor = 0.f; - std::tie(grad_x, grad_y) = sobel(src, gradient_size, border_mode, constant_border_value); + std::tie(grad_x, grad_y) = sobel(src, gradient_size, border_mode, constant_border_value, GradientDimension::GRAD_XY); switch(gradient_size) { diff --git a/tests/validation/CPP/Sobel.cpp b/tests/validation/CPP/Sobel.cpp index 314fbd4f8a..ff0e11d3a8 100644 --- a/tests/validation/CPP/Sobel.cpp +++ b/tests/validation/CPP/Sobel.cpp @@ -103,7 +103,7 @@ struct data_type } // namespace template -std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value) +std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension) { SimpleTensor dst_x(src.shape(), data_type::value, src.num_channels()); SimpleTensor dst_y(src.shape(), data_type::value, src.num_channels()); @@ -118,18 +118,34 @@ std::pair, SimpleTensor> sobel(const SimpleTensor &src, in { continue; } - - apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).first, 1.f, border_mode, - constant_border_value); - apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).second, 1.f, border_mode, - constant_border_value); + switch(gradient_dimension) + { + case GradientDimension::GRAD_X: + apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).first, 1.f, border_mode, + constant_border_value); + break; + case GradientDimension::GRAD_Y: + apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).second, 1.f, border_mode, + constant_border_value); + break; + case GradientDimension::GRAD_XY: + apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).first, 1.f, border_mode, + constant_border_value); + apply_2d_spatial_filter(coord, src, dst_y, TensorShape{ static_cast(filter_size), static_cast(filter_size) }, masks.at(filter_size).second, 1.f, border_mode, + constant_border_value); + break; + default: + ARM_COMPUTE_ERROR("Gradient dimension not supported"); + } } return std::make_pair(dst_x, dst_y); } -template std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value); -template std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value); +template std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, + GradientDimension gradient_dimension); +template std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, + GradientDimension gradient_dimension); } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/CPP/Sobel.h b/tests/validation/CPP/Sobel.h index ab046639dc..9099f1a932 100644 --- a/tests/validation/CPP/Sobel.h +++ b/tests/validation/CPP/Sobel.h @@ -26,6 +26,7 @@ #include "arm_compute/core/Types.h" #include "tests/SimpleTensor.h" +#include "tests/Types.h" namespace arm_compute { @@ -36,7 +37,7 @@ namespace validation namespace reference { template -std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value = 0); +std::pair, SimpleTensor> sobel(const SimpleTensor &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension); } // namespace reference } // namespace validation } // namespace test -- cgit v1.2.1