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 --- src/core/NEON/kernels/NESobel7x7Kernel.cpp | 2 +- tests/validation/CL/Sobel.cpp | 151 ++++++++++++++++++++++++-- tests/validation/CPP/HarrisCornerDetector.cpp | 2 +- tests/validation/CPP/Sobel.cpp | 32 ++++-- tests/validation/CPP/Sobel.h | 3 +- tests/validation/NEON/Sobel.cpp | 148 +++++++++++++++++++++++-- tests/validation/fixtures/SobelFixture.h | 29 +++-- 7 files changed, 325 insertions(+), 42 deletions(-) diff --git a/src/core/NEON/kernels/NESobel7x7Kernel.cpp b/src/core/NEON/kernels/NESobel7x7Kernel.cpp index 4cc80f8e2e..40a3e31a39 100644 --- a/src/core/NEON/kernels/NESobel7x7Kernel.cpp +++ b/src/core/NEON/kernels/NESobel7x7Kernel.cpp @@ -286,7 +286,7 @@ void NESobel7x7HorKernel::run(const Window &window, const ThreadInfo &info) } }; - const int32x4x2_t out = compute_hor_sobel_x(data_s32); + const int32x4x2_t out = compute_hor_sobel_y(data_s32); vst1q_s32(reinterpret_cast(output_y.ptr()), out.val[0]); vst1q_s32(reinterpret_cast(output_y.ptr()) + 4, out.val[1]); }, diff --git a/tests/validation/CL/Sobel.cpp b/tests/validation/CL/Sobel.cpp index cde93e77a9..16f411db3c 100644 --- a/tests/validation/CL/Sobel.cpp +++ b/tests/validation/CL/Sobel.cpp @@ -100,8 +100,50 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca validate(dst_y.info()->padding(), dst_padding); } -FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +TEST_SUITE(X) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); + validate(CLAccessor(_target.first), _reference.first, valid_region_x); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); + validate(CLAccessor(_target.first), _reference.first, valid_region_x); +} +TEST_SUITE_END() + +TEST_SUITE(Y) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); + validate(CLAccessor(_target.second), _reference.second, valid_region_y); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); + validate(CLAccessor(_target.second), _reference.second, valid_region_y); +} +TEST_SUITE_END() + +TEST_SUITE(XY) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); @@ -111,8 +153,9 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel3x3Fixture, framework::DatasetMode::PREC validate(CLAccessor(_target.second), _reference.second, valid_region_y); } -FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); @@ -122,6 +165,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel3x3Fixture, framework::DatasetMode::NIGH validate(CLAccessor(_target.second), _reference.second, valid_region_y); } TEST_SUITE_END() +TEST_SUITE_END() TEST_SUITE(W5x5) using CLSobel5x5Fixture = SobelValidationFixture; @@ -176,8 +220,48 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca validate(dst_y.info()->padding(), dst_padding); } -FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +TEST_SUITE(X) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); + validate(CLAccessor(_target.first), _reference.first, valid_region_x); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); + validate(CLAccessor(_target.first), _reference.first, valid_region_x); +} +TEST_SUITE_END() +TEST_SUITE(Y) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); + validate(CLAccessor(_target.second), _reference.second, valid_region_y); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); + validate(CLAccessor(_target.second), _reference.second, valid_region_y); +} +TEST_SUITE_END() +TEST_SUITE(XY) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); @@ -187,8 +271,9 @@ FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel5x5Fixture, framework::DatasetMode::PREC validate(CLAccessor(_target.second), _reference.second, valid_region_y); } -FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); @@ -198,6 +283,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel5x5Fixture, framework::DatasetMode::NIGH validate(CLAccessor(_target.second), _reference.second, valid_region_y); } TEST_SUITE_END() +TEST_SUITE_END() TEST_SUITE(W7x7) using CLSobel7x7Fixture = SobelValidationFixture; @@ -252,20 +338,60 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca validate(dst_x.info()->padding(), dst_padding); validate(dst_y.info()->padding(), dst_padding); } +TEST_SUITE(X) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); + validate(CLAccessor(_target.first), _reference.first, valid_region_x); +} -FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); validate(CLAccessor(_target.first), _reference.first, valid_region_x); +} +TEST_SUITE_END() +TEST_SUITE(Y) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); + validate(CLAccessor(_target.second), _reference.second, valid_region_y); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); validate(CLAccessor(_target.second), _reference.second, valid_region_y); } +TEST_SUITE_END() +TEST_SUITE(XY) +FIXTURE_DATA_TEST_CASE(RunSmall, CLSobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); + validate(CLAccessor(_target.first), _reference.first, valid_region_x); -FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); + validate(CLAccessor(_target.second), _reference.second, valid_region_y); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); @@ -275,6 +401,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLSobel7x7Fixture, framework::DatasetMode::NIGH validate(CLAccessor(_target.second), _reference.second, valid_region_y); } TEST_SUITE_END() +TEST_SUITE_END() TEST_SUITE_END() TEST_SUITE_END() 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 diff --git a/tests/validation/NEON/Sobel.cpp b/tests/validation/NEON/Sobel.cpp index 99f9e1ff5d..e757d1db3c 100644 --- a/tests/validation/NEON/Sobel.cpp +++ b/tests/validation/NEON/Sobel.cpp @@ -100,19 +100,60 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca validate(dst_y.info()->padding(), dst_padding); } -FIXTURE_DATA_TEST_CASE(RunSmall, NESobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +TEST_SUITE(X) +FIXTURE_DATA_TEST_CASE(RunSmall, NESobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); validate(Accessor(_target.first), _reference.first, valid_region_x); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NESobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); + validate(Accessor(_target.first), _reference.first, valid_region_x); +} +TEST_SUITE_END() +TEST_SUITE(Y) +FIXTURE_DATA_TEST_CASE(RunSmall, NESobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); validate(Accessor(_target.second), _reference.second, valid_region_y); } -FIXTURE_DATA_TEST_CASE(RunLarge, NESobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, NESobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); + validate(Accessor(_target.second), _reference.second, valid_region_y); +} +TEST_SUITE_END() +TEST_SUITE(XY) +FIXTURE_DATA_TEST_CASE(RunSmall, NESobel3x3Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); + validate(Accessor(_target.first), _reference.first, valid_region_x); + + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); + validate(Accessor(_target.second), _reference.second, valid_region_y); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NESobel3x3Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(1)); @@ -122,6 +163,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NESobel3x3Fixture, framework::DatasetMode::NIGH validate(Accessor(_target.second), _reference.second, valid_region_y); } TEST_SUITE_END() +TEST_SUITE_END() TEST_SUITE(W5x5) using NESobel5x5Fixture = SobelValidationFixture; @@ -176,9 +218,48 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca validate(dst_x.info()->padding(), dst_padding); validate(dst_y.info()->padding(), dst_padding); } +TEST_SUITE(X) +FIXTURE_DATA_TEST_CASE(RunSmall, NESobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); + validate(Accessor(_target.first), _reference.first, valid_region_x); +} -FIXTURE_DATA_TEST_CASE(RunSmall, NESobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, NESobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); + validate(Accessor(_target.first), _reference.first, valid_region_x); +} +TEST_SUITE_END() +TEST_SUITE(Y) +FIXTURE_DATA_TEST_CASE(RunSmall, NESobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); + validate(Accessor(_target.second), _reference.second, valid_region_y); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NESobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); + validate(Accessor(_target.second), _reference.second, valid_region_y); +} +TEST_SUITE_END() +TEST_SUITE(XY) +FIXTURE_DATA_TEST_CASE(RunSmall, NESobel5x5Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); @@ -188,8 +269,9 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NESobel5x5Fixture, framework::DatasetMode::PREC validate(Accessor(_target.second), _reference.second, valid_region_y); } -FIXTURE_DATA_TEST_CASE(RunLarge, NESobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, NESobel5x5Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(2)); @@ -199,6 +281,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NESobel5x5Fixture, framework::DatasetMode::NIGH validate(Accessor(_target.second), _reference.second, valid_region_y); } TEST_SUITE_END() +TEST_SUITE_END() TEST_SUITE(W7x7) using NESobel7x7Fixture = SobelValidationFixture; @@ -253,9 +336,48 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca validate(dst_x.info()->padding(), dst_padding); validate(dst_y.info()->padding(), dst_padding); } +TEST_SUITE(X) +FIXTURE_DATA_TEST_CASE(RunSmall, NESobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); + validate(Accessor(_target.first), _reference.first, valid_region_x); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NESobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_X))) +{ + // Validate output + ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); + validate(Accessor(_target.first), _reference.first, valid_region_x); +} +TEST_SUITE_END() +TEST_SUITE(Y) +FIXTURE_DATA_TEST_CASE(RunSmall, NESobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); + validate(Accessor(_target.second), _reference.second, valid_region_y); +} -FIXTURE_DATA_TEST_CASE(RunSmall, NESobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, NESobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_Y))) +{ + // Validate output + ValidRegion valid_region_y = shape_to_valid_region(_reference.second.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); + validate(Accessor(_target.second), _reference.second, valid_region_y); +} +TEST_SUITE_END() +TEST_SUITE(XY) +FIXTURE_DATA_TEST_CASE(RunSmall, NESobel7x7Fixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::Small2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); @@ -265,8 +387,9 @@ FIXTURE_DATA_TEST_CASE(RunSmall, NESobel7x7Fixture, framework::DatasetMode::PREC validate(Accessor(_target.second), _reference.second, valid_region_y); } -FIXTURE_DATA_TEST_CASE(RunLarge, NESobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", - Format::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, NESobel7x7Fixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::Large2DShapes(), datasets::BorderModes()), framework::dataset::make("Format", + Format::U8)), + framework::dataset::make("GradientDimension", GradientDimension::GRAD_XY))) { // Validate output ValidRegion valid_region_x = shape_to_valid_region(_reference.first.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(3)); @@ -276,6 +399,7 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NESobel7x7Fixture, framework::DatasetMode::NIGH validate(Accessor(_target.second), _reference.second, valid_region_y); } TEST_SUITE_END() +TEST_SUITE_END() TEST_SUITE_END() TEST_SUITE_END() diff --git a/tests/validation/fixtures/SobelFixture.h b/tests/validation/fixtures/SobelFixture.h index 2a592b87f7..f8041b9829 100644 --- a/tests/validation/fixtures/SobelFixture.h +++ b/tests/validation/fixtures/SobelFixture.h @@ -102,7 +102,7 @@ class SobelValidationFixture : public framework::Fixture { public: template - void setup(TensorShape shape, BorderMode border_mode, Format format) + void setup(TensorShape shape, BorderMode border_mode, Format format, GradientDimension gradient_dimension) { // Generate a random constant value std::mt19937 gen(library->seed()); @@ -110,8 +110,8 @@ public: const uint8_t constant_border_value = int_dist(gen); _border_mode = border_mode; - _target = compute_target(shape, border_mode, format, constant_border_value); - _reference = compute_reference(shape, info::filter_size, border_mode, format, constant_border_value); + _target = compute_target(shape, border_mode, format, constant_border_value, gradient_dimension); + _reference = compute_reference(shape, info::filter_size, border_mode, format, constant_border_value, gradient_dimension); } protected: @@ -121,7 +121,7 @@ protected: library->fill_tensor_uniform(tensor, 0); } - std::pair compute_target(const TensorShape &shape, BorderMode border_mode, Format format, uint8_t constant_border_value) + std::pair compute_target(const TensorShape &shape, BorderMode border_mode, Format format, uint8_t constant_border_value, GradientDimension gradient_dimension) { // Create tensors TensorType src = create_tensor(shape, data_type_from_format(format)); @@ -133,7 +133,21 @@ protected: dst_y.info()->set_format(info::dst_format); FunctionType sobel; - sobel.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); + + switch(gradient_dimension) + { + case GradientDimension::GRAD_X: + sobel.configure(&src, &dst_x, nullptr, border_mode, constant_border_value); + break; + case GradientDimension::GRAD_Y: + sobel.configure(&src, nullptr, &dst_y, border_mode, constant_border_value); + break; + case GradientDimension::GRAD_XY: + sobel.configure(&src, &dst_x, &dst_y, border_mode, constant_border_value); + break; + default: + ARM_COMPUTE_ERROR("Gradient dimension not supported"); + } ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(dst_x.info()->is_resizable(), framework::LogLevel::ERRORS); @@ -157,7 +171,8 @@ protected: return std::make_pair(std::move(dst_x), std::move(dst_y)); } - std::pair, SimpleTensor> compute_reference(const TensorShape &shape, int filter_size, BorderMode border_mode, Format format, uint8_t constant_border_value) + std::pair, SimpleTensor> compute_reference(const TensorShape &shape, int filter_size, BorderMode border_mode, Format format, uint8_t constant_border_value, + GradientDimension gradient_dimension) { // Create reference SimpleTensor src{ shape, format }; @@ -165,7 +180,7 @@ protected: // Fill reference fill(src); - return reference::sobel(src, filter_size, border_mode, constant_border_value); + return reference::sobel(src, filter_size, border_mode, constant_border_value, gradient_dimension); } BorderMode _border_mode{ BorderMode::UNDEFINED }; -- cgit v1.2.1