aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/CL/Convolution.cpp
diff options
context:
space:
mode:
authorSanghoon Lee <sanghoon.lee@arm.com>2017-12-13 11:28:50 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:42:33 +0000
commitd7ba5397b676c966cb5069c7187a12a0c35305f5 (patch)
treeab95a7e64c44b3505eec3e845a5fe049ae5ba66d /tests/validation/CL/Convolution.cpp
parent6db0ff5b4bb49f834c7caa532a7feab228df10f9 (diff)
downloadComputeLibrary-d7ba5397b676c966cb5069c7187a12a0c35305f5.tar.gz
COMPMID-727 - Implement reference and CL/NEON validation for CustomConvolutionRectangle
Change-Id: I108a48ad5e6dc3f331fd5ceb38ced8ccdb31d81a Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/113130 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests/validation/CL/Convolution.cpp')
-rw-r--r--tests/validation/CL/Convolution.cpp220
1 files changed, 135 insertions, 85 deletions
diff --git a/tests/validation/CL/Convolution.cpp b/tests/validation/CL/Convolution.cpp
index c836edabb8..d6405474e3 100644
--- a/tests/validation/CL/Convolution.cpp
+++ b/tests/validation/CL/Convolution.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 ARM Limited.
+ * Copyright (c) 2017, 2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -43,30 +43,17 @@ namespace validation
{
namespace
{
-/* Convolution3x3 */
-constexpr unsigned int filter_size_3x3 = 3; /* Size of the kernel/filter in number of elements. */
-constexpr BorderSize border_size_3x3(filter_size_3x3 / 2); /* Border size of the kernel/filter around its central element. */
-
-/* Convolution5x5 */
-constexpr unsigned int filter_size_5x5 = 5; /* Size of the kernel/filter in number of elements. */
-constexpr BorderSize border_size_5x5(filter_size_5x5 / 2); /* Border size of the kernel/filter around its central element. */
-
-/* Convolution7x7 */
-constexpr unsigned int filter_size_7x7 = 7; /* Size of the kernel/filter in number of elements. */
-constexpr BorderSize border_size_7x7(filter_size_7x7 / 2); /* Border size of the kernel/filter around its central element. */
-
-/* Convolution9x9 */
-constexpr unsigned int filter_size_9x9 = 9; /* Size of the kernel/filter in number of elements. */
-constexpr BorderSize border_size_9x9(filter_size_9x9 / 2); /* Border size of the kernel/filter around its central element. */
} // namespace
TEST_SUITE(CL)
TEST_SUITE(CustomConvolution)
+TEST_SUITE(CustomConvolutionSquare)
TEST_SUITE(CustomConvolution3x3)
-DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)),
- datasets::BorderModes()),
- shape, data_type, border_mode)
+DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)),
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 3 })),
+ shape, data_type, border_mode, filter_size)
{
// Create tensors
CLTensor src = create_tensor<CLTensor>(shape, data_type);
@@ -75,20 +62,15 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca
// Create conv matrix
int16_t conv[9];
- // Generate random scale value between 0 and 255.
- std::mt19937 gen(library->seed());
- std::uniform_int_distribution<uint8_t> distribution(0, 255);
- const uint32_t scale = distribution(gen);
-
ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
// Create and configure function
CLConvolution3x3 convolution;
- convolution.configure(&src, &dst, conv, scale, border_mode);
+ convolution.configure(&src, &dst, conv, 0, border_mode);
// Validate valid region
- const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), border_size_3x3);
+ const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_size / 2));
validate(dst.info()->valid_region(), dst_valid_region);
// Validate padding
@@ -108,29 +90,33 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca
}
template <typename T>
-using CLConvolutionFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLConvolution3x3, T, filter_size_3x3>;
+using CLConvolutionFixture = ConvolutionSquareValidationFixture<CLTensor, CLAccessor, CLConvolution3x3, T>;
-FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
+FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
DataType::U8)),
- datasets::BorderModes()))
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 3 })))
{
// Validate output
- validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), border_size_3x3));
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
}
-FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
+FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
DataType::U8)),
- datasets::BorderModes()))
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 3 })))
{
// Validate output
- validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), border_size_3x3));
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
}
TEST_SUITE_END() /* Custom_Convolution 3x3 */
TEST_SUITE(CustomConvolution5x5)
-DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)),
- datasets::BorderModes()),
- shape, data_type, border_mode)
+
+DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)),
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 5 })),
+ shape, data_type, border_mode, filter_size)
{
// Create tensors
CLTensor src = create_tensor<CLTensor>(shape, data_type);
@@ -139,20 +125,15 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca
// Create conv matrix
int16_t conv[25];
- // Generate random scale value between 0 and 255.
- std::mt19937 gen(library->seed());
- std::uniform_int_distribution<uint8_t> distribution(0, 255);
- const uint32_t scale = distribution(gen);
-
ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
// Create and configure function
CLConvolution5x5 convolution;
- convolution.configure(&src, &dst, conv, scale, border_mode);
+ convolution.configure(&src, &dst, conv, 0, border_mode);
// Validate valid region
- const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), border_size_5x5);
+ const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_size / 2));
validate(dst.info()->valid_region(), dst_valid_region);
// Validate padding
@@ -172,29 +153,31 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca
}
template <typename T>
-using CLConvolutionFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLConvolution5x5, T, filter_size_5x5>;
-
-FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
+using CLConvolutionFixture = ConvolutionSquareValidationFixture<CLTensor, CLAccessor, CLConvolution5x5, T>;
+FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
DataType::U8)),
- datasets::BorderModes()))
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 5 })))
{
// Validate output
- validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), border_size_5x5));
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
}
-FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
+FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
DataType::U8)),
- datasets::BorderModes()))
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 5 })))
{
// Validate output
- validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), border_size_5x5));
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
}
TEST_SUITE_END() /* Custom Convolution 5x5 */
TEST_SUITE(CustomConvolution7x7)
-DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)),
- datasets::BorderModes()),
- shape, data_type, border_mode)
+DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)),
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 7 })),
+ shape, data_type, border_mode, filter_size)
{
// Create tensors
CLTensor src = create_tensor<CLTensor>(shape, data_type);
@@ -203,20 +186,15 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca
// Create conv matrix
int16_t conv[49];
- // Generate random scale value between 0 and 255.
- std::mt19937 gen(library->seed());
- std::uniform_int_distribution<uint8_t> distribution(0, 255);
- const uint32_t scale = distribution(gen);
-
ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
// Create and configure function
CLConvolution7x7 convolution;
- convolution.configure(&src, &dst, conv, scale, border_mode);
+ convolution.configure(&src, &dst, conv, 0, border_mode);
// Validate valid region
- const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), border_size_7x7);
+ const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_size / 2));
validate(dst.info()->valid_region(), dst_valid_region);
// Validate padding
@@ -236,29 +214,32 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca
}
template <typename T>
-using CLConvolutionFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLConvolution7x7, T, filter_size_7x7>;
+using CLConvolutionFixture = ConvolutionSquareValidationFixture<CLTensor, CLAccessor, CLConvolution7x7, T>;
-FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
+FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
DataType::U8)),
- datasets::BorderModes()))
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 7 })))
{
// Validate output
- validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), border_size_7x7));
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
}
-FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
+FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
DataType::U8)),
- datasets::BorderModes()))
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 7 })))
{
// Validate output
- validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), border_size_7x7));
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
}
TEST_SUITE_END() /* Custom Convolution 7x7 */
TEST_SUITE(CustomConvolution9x9)
-DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)),
- datasets::BorderModes()),
- shape, data_type, border_mode)
+DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)),
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 9 })),
+ shape, data_type, border_mode, filter_size)
{
// Create tensors
CLTensor src = create_tensor<CLTensor>(shape, data_type);
@@ -267,20 +248,15 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca
// Create conv matrix
int16_t conv[81];
- // Generate random scale value between 0 and 255.
- std::mt19937 gen(library->seed());
- std::uniform_int_distribution<uint8_t> distribution(0, 255);
- const uint32_t scale = distribution(gen);
-
ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
// Create and configure function
CLConvolution9x9 convolution;
- convolution.configure(&src, &dst, conv, scale, border_mode);
+ convolution.configure(&src, &dst, conv, 0, border_mode);
// Validate valid region
- const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), border_size_9x9);
+ const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_size / 2));
validate(dst.info()->valid_region(), dst_valid_region);
// Validate padding
@@ -300,24 +276,98 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(conca
}
template <typename T>
-using CLConvolutionFixture = ConvolutionValidationFixture<CLTensor, CLAccessor, CLConvolution9x9, T, filter_size_9x9>;
+using CLConvolutionFixture = ConvolutionSquareValidationFixture<CLTensor, CLAccessor, CLConvolution9x9, T>;
-FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
+FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
DataType::U8)),
- datasets::BorderModes()))
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 9 })))
{
// Validate output
- validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), border_size_9x9));
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
}
-FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
+FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
DataType::U8)),
- datasets::BorderModes()))
+ datasets::BorderModes()),
+ framework::dataset::make("filter_size", { 9 })))
{
// Validate output
- validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), border_size_9x9));
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
}
TEST_SUITE_END() /* Custom Convolution 9x9 */
+TEST_SUITE_END() /* Custom Convolution Square */
+
+TEST_SUITE(CustomConvolutionRectangle)
+
+DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType",
+ DataType::U8)),
+ datasets::BorderModes()),
+ framework::dataset::make("filter_width", { 3, 5, 7, 9 })),
+ framework::dataset::make("filter_height", { 3, 5, 7, 9 })),
+ shape, data_type, border_mode, filter_width, filter_height)
+{
+ // Create tensors
+ CLTensor src = create_tensor<CLTensor>(shape, data_type);
+ CLTensor dst = create_tensor<CLTensor>(shape, data_type);
+
+ // Create conv matrix
+ int16_t conv[filter_width * filter_height];
+
+ ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
+
+ // Create and configure function
+ CLConvolutionRectangle convolution;
+ convolution.configure(&src, &dst, conv, filter_width, filter_height, 1, border_mode);
+
+ // Validate valid region
+ const ValidRegion dst_valid_region = shape_to_valid_region(shape, (border_mode == BorderMode::UNDEFINED), BorderSize(filter_height / 2, filter_width / 2));
+ validate(dst.info()->valid_region(), dst_valid_region);
+
+ // Validate padding
+ PaddingCalculator calculator(shape.x(), 8);
+ calculator.set_border_size(filter_width / 2);
+ calculator.set_border_mode(border_mode);
+
+ const PaddingSize dst_padding = calculator.required_padding();
+
+ calculator.set_accessed_elements(16);
+ calculator.set_access_offset(-(filter_width / 2));
+
+ const PaddingSize width_padding = calculator.required_padding();
+
+ calculator.set_border_size(filter_height / 2);
+ calculator.set_access_offset(-(filter_height / 2));
+ const PaddingSize height_padding = calculator.required_padding();
+
+ validate(src.info()->padding(), width_padding, height_padding);
+ validate(dst.info()->padding(), dst_padding);
+}
+
+template <typename T>
+using CLConvolutionFixture = ConvolutionRectangleValidationFixture<CLTensor, CLAccessor, CLConvolutionRectangle, T>;
+
+FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
+ DataType::U8)),
+ datasets::BorderModes()),
+ framework::dataset::make("filter_width", { 3, 5, 7, 9 })),
+ framework::dataset::make("filter_height", { 3, 5, 7, 9 })))
+{
+ // Validate output
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
+}
+
+FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
+ DataType::U8)),
+ datasets::BorderModes()),
+ framework::dataset::make("filter_width", { 3, 5, 7, 9 })),
+ framework::dataset::make("filter_height", { 3, 5, 7, 9 })))
+{
+ // Validate output
+ validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)));
+}
+TEST_SUITE_END() /* Custom Convolution Rectangle */
TEST_SUITE_END()
TEST_SUITE_END()
} // namespace validation