aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/CPP
diff options
context:
space:
mode:
authorIsabella Gottardi <isabella.gottardi@arm.com>2017-11-08 11:13:23 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commit43ce898014faabbe8ab1cdf714b7aad3d3c9b2a9 (patch)
tree43a2f75b86c39628878b5697a388fefeac77c7ed /tests/validation/CPP
parentc1294faa1d60274aa14567338fc2a449c70c1801 (diff)
downloadComputeLibrary-43ce898014faabbe8ab1cdf714b7aad3d3c9b2a9.tar.gz
COMPMID-670 - Extend Sobel tests
Change-Id: Ibf15544e8624977815ee355071a038c07e1f01c2 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/94874 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'tests/validation/CPP')
-rw-r--r--tests/validation/CPP/HarrisCornerDetector.cpp2
-rw-r--r--tests/validation/CPP/Sobel.cpp32
-rw-r--r--tests/validation/CPP/Sobel.h3
3 files changed, 27 insertions, 10 deletions
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<T>, SimpleTensor<T>, float> compute_sobel(const SimpleTe
SimpleTensor<T> grad_y;
float norm_factor = 0.f;
- std::tie(grad_x, grad_y) = sobel<T>(src, gradient_size, border_mode, constant_border_value);
+ std::tie(grad_x, grad_y) = sobel<T>(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<int>
} // namespace
template <typename T, typename U>
-std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value)
+std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension)
{
SimpleTensor<T> dst_x(src.shape(), data_type<T>::value, src.num_channels());
SimpleTensor<T> dst_y(src.shape(), data_type<T>::value, src.num_channels());
@@ -118,18 +118,34 @@ std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, in
{
continue;
}
-
- apply_2d_spatial_filter(coord, src, dst_x, TensorShape{ static_cast<unsigned int>(filter_size), static_cast<unsigned int>(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<unsigned int>(filter_size), static_cast<unsigned int>(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<unsigned int>(filter_size), static_cast<unsigned int>(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<unsigned int>(filter_size), static_cast<unsigned int>(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<unsigned int>(filter_size), static_cast<unsigned int>(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<unsigned int>(filter_size), static_cast<unsigned int>(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<int16_t>, SimpleTensor<int16_t>> sobel(const SimpleTensor<uint8_t> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value);
-template std::pair<SimpleTensor<int>, SimpleTensor<int>> sobel(const SimpleTensor<uint8_t> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value);
+template std::pair<SimpleTensor<int16_t>, SimpleTensor<int16_t>> sobel(const SimpleTensor<uint8_t> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value,
+ GradientDimension gradient_dimension);
+template std::pair<SimpleTensor<int>, SimpleTensor<int>> sobel(const SimpleTensor<uint8_t> &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 <typename T, typename U>
-std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value = 0);
+std::pair<SimpleTensor<T>, SimpleTensor<T>> sobel(const SimpleTensor<U> &src, int filter_size, BorderMode border_mode, uint8_t constant_border_value, GradientDimension gradient_dimension);
} // namespace reference
} // namespace validation
} // namespace test