From c8d231626cc204034ab1053f9031ebbb631f1ba9 Mon Sep 17 00:00:00 2001 From: Sanghoon Lee Date: Fri, 12 Jan 2018 16:19:10 +0000 Subject: COMPMID-564: Implement reference and CL/NEON validation for CustomConvolution (output S16) Change-Id: Ic099336f558e994210a59e14ec0171fae68ccb80 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/116663 Reviewed-by: Pablo Tello Tested-by: Jenkins --- tests/validation/CL/Convolution.cpp | 239 ++++++++++++++++--- tests/validation/NEON/Convolution.cpp | 309 ++++++++++++++++++++++--- tests/validation/fixtures/ConvolutionFixture.h | 48 ++-- tests/validation/reference/Convolution.cpp | 55 +++-- tests/validation/reference/Convolution.h | 6 +- 5 files changed, 552 insertions(+), 105 deletions(-) diff --git a/tests/validation/CL/Convolution.cpp b/tests/validation/CL/Convolution.cpp index ccb0abcbd1..56f391965d 100644 --- a/tests/validation/CL/Convolution.cpp +++ b/tests/validation/CL/Convolution.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -48,16 +48,15 @@ namespace TEST_SUITE(CL) TEST_SUITE(CustomConvolution) TEST_SUITE(CustomConvolutionSquare) -TEST_SUITE(CustomConvolution3x3) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), +TEST_SUITE(CustomConvolutionSquare3x3) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), datasets::BorderModes()), framework::dataset::make("filter_size", { 3 })), - shape, data_type, border_mode, filter_size) + shape, output_data_type, border_mode, filter_size) { // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[9]; @@ -92,6 +91,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using CLConvolutionFixture = ConvolutionSquareValidationFixture; +TEST_SUITE(CustomConvolutionSqaure3x3_U8) FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -109,18 +109,37 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture, framework::Datas // 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 3x3 */ +TEST_SUITE_END() -TEST_SUITE(CustomConvolution5x5) +TEST_SUITE(CustomConvolutionSqaure3x3_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 3 }))) +{ + // 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, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 3 }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); +} +TEST_SUITE_END() +TEST_SUITE_END() /* Custom_Convolution 3x3 */ -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), +TEST_SUITE(CustomConvolutionSquare5x5) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), datasets::BorderModes()), framework::dataset::make("filter_size", { 5 })), - shape, data_type, border_mode, filter_size) + shape, output_data_type, border_mode, filter_size) { // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[25]; @@ -154,6 +173,8 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using CLConvolutionFixture = ConvolutionSquareValidationFixture; + +TEST_SUITE(CustomConvolutionSqaure5x5_U8) FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -171,17 +192,38 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture, framework::Datas // Validate output validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSqaure5x5_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // 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, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); +} +TEST_SUITE_END() TEST_SUITE_END() /* Custom Convolution 5x5 */ -TEST_SUITE(CustomConvolution7x7) -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), +TEST_SUITE(CustomConvolutionSquare7x7) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), datasets::BorderModes()), framework::dataset::make("filter_size", { 7 })), - shape, data_type, border_mode, filter_size) + shape, output_data_type, border_mode, filter_size) { // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[49]; @@ -216,6 +258,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using CLConvolutionFixture = ConvolutionSquareValidationFixture; +TEST_SUITE(CustomConvolutionSquare7x7_U8) FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -233,17 +276,38 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture, framework::Datas // Validate output validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSquare7x7_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // 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, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); +} +TEST_SUITE_END() TEST_SUITE_END() /* Custom Convolution 7x7 */ -TEST_SUITE(CustomConvolution9x9) -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), +TEST_SUITE(CustomConvolutionSquare9x9) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), datasets::BorderModes()), framework::dataset::make("filter_size", { 9 })), - shape, data_type, border_mode, filter_size) + shape, output_data_type, border_mode, filter_size) { // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[81]; @@ -278,6 +342,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using CLConvolutionFixture = ConvolutionSquareValidationFixture; +TEST_SUITE(CustomConvolutionSquare9x9_U8) FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -295,21 +360,41 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture, framework::Datas // Validate output validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSquare9x9_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 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, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 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() 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) +{ DataType::U8, DataType::S16 })), +datasets::BorderModes()), +framework::dataset::make("filter_width", { 3, 5, 7, 9 })), +framework::dataset::make("filter_height", { 3, 5, 7, 9 })), +shape, output_data_type, border_mode, filter_width, filter_height) { // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); + CLTensor src = create_tensor(shape, DataType::U8); + CLTensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[filter_width * filter_height]; @@ -348,6 +433,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using CLConvolutionFixture = ConvolutionRectangleValidationFixture; +TEST_SUITE(CustomConvolutionRectangle_U8) FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -367,6 +453,29 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture, framework::Datas // Validate output validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionRectangle_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + 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, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + 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() TEST_SUITE_END() /* Custom Convolution Rectangle */ TEST_SUITE(CustomConvolutionSeparable) @@ -374,6 +483,7 @@ TEST_SUITE(CustomConvolutionSeparable5x5) template using CLConvolutionFixture = ConvolutionSeparableValidationFixture; +TEST_SUITE(CustomConvolutionSeparable5x5_U8) FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -391,12 +501,34 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture, framework::Datas // Validate output validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSeparable5x5_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // 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, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); +} +TEST_SUITE_END() TEST_SUITE_END() /* Custom Convolution Separable 5x5 */ -TEST_SUITE(CustomConvolutionSeparablex7x7) +TEST_SUITE(CustomConvolutionSeparable7x7) template using CLConvolutionFixture = ConvolutionSeparableValidationFixture; +TEST_SUITE(CustomConvolutionSeparable7x7_U8) FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -414,12 +546,34 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture, framework::Datas // Validate output validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSeparable7x7_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // 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, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // Validate output + validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); +} +TEST_SUITE_END() TEST_SUITE_END() /* Custom Convolution Separable 7x7 */ TEST_SUITE(CustomConvolutionSeparable9x9) template using CLConvolutionFixture = ConvolutionSeparableValidationFixture; +TEST_SUITE(CustomConvolutionSeparable9x9_U8) FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -437,6 +591,27 @@ FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionFixture, framework::Datas // Validate output validate(CLAccessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2))); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSeparable9x9_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 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, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 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() TEST_SUITE_END() /* Custom Convolution Separable 9x9 */ TEST_SUITE_END() /* Custom Convolution Separable */ diff --git a/tests/validation/NEON/Convolution.cpp b/tests/validation/NEON/Convolution.cpp index 5af803010b..02c8abc419 100644 --- a/tests/validation/NEON/Convolution.cpp +++ b/tests/validation/NEON/Convolution.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -49,21 +49,22 @@ namespace * while reference performs direct division with scale. */ constexpr AbsoluteTolerance tolerance_u8(1); +constexpr AbsoluteTolerance tolerance_s16(1); } // namespace TEST_SUITE(NEON) TEST_SUITE(CustomConvolution) -TEST_SUITE(CustomConvolutionSuqare) -TEST_SUITE(CustomConvolution3x3) +TEST_SUITE(CustomConvolutionSquare) +TEST_SUITE(CustomConvolutionSquare3x3) -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), datasets::BorderModes()), framework::dataset::make("filter_size", { 3 })), - shape, data_type, border_mode, filter_size) + shape, output_data_type, border_mode, filter_size) { // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[9]; @@ -98,6 +99,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using NEConvolutionFixture = ConvolutionSquareValidationFixture; +TEST_SUITE(CustomConvolutionSquare3x3_U8) FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -115,17 +117,38 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::Datas // Validate output validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSquare3x3_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 3 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 3 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} +TEST_SUITE_END() TEST_SUITE_END() /* Custom Convolution3x3 */ -TEST_SUITE(CustomConvolution5x5) -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), +TEST_SUITE(CustomConvolutionSquare5x5) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), datasets::BorderModes()), framework::dataset::make("filter_size", { 5 })), - shape, data_type, border_mode, filter_size) + shape, output_data_type, border_mode, filter_size) { // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[25]; @@ -160,6 +183,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using NEConvolutionFixture = ConvolutionSquareValidationFixture; +TEST_SUITE(CustomConvolutionSquare5x5_U8) FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -177,17 +201,38 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::Datas // Validate output validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSquare5x5_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} +TEST_SUITE_END() TEST_SUITE_END() /* Custom Convolution 5x5 */ -TEST_SUITE(CustomConvolution7x7) -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), +TEST_SUITE(CustomConvolutionSquare7x7) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), datasets::BorderModes()), framework::dataset::make("filter_size", { 7 })), - shape, data_type, border_mode, filter_size) + shape, output_data_type, border_mode, filter_size) { // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[49]; @@ -222,6 +267,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using NEConvolutionFixture = ConvolutionSquareValidationFixture; +TEST_SUITE(CustomConvolutionSquare7x7_U8) FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -239,17 +285,38 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::Datas // Validate output validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSquare7x7_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} +TEST_SUITE_END() TEST_SUITE_END() /* Custom Convolution 7x7 */ -TEST_SUITE(CustomConvolution9x9) -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), +TEST_SUITE(CustomConvolutionSquare9x9) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", { DataType::U8, DataType::S16 })), datasets::BorderModes()), framework::dataset::make("filter_size", { 9 })), - shape, data_type, border_mode, filter_size) + shape, output_data_type, border_mode, filter_size) { // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[81]; @@ -284,6 +351,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using NEConvolutionFixture = ConvolutionSquareValidationFixture; +TEST_SUITE(CustomConvolutionSquare9x9_U8) FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -301,21 +369,41 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::Datas // Validate output validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); } +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSquare9x9_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 9 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 9 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} +TEST_SUITE_END() 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) +{ DataType::U8, DataType::S16 })), +datasets::BorderModes()), +framework::dataset::make("filter_width", { 3, 5, 7, 9 })), +framework::dataset::make("filter_height", { 3, 5, 7, 9 })), +shape, output_data_type, border_mode, filter_width, filter_height) { // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); + Tensor src = create_tensor(shape, DataType::U8); + Tensor dst = create_tensor(shape, output_data_type); // Create conv matrix int16_t conv[filter_width * filter_height]; @@ -354,6 +442,7 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combi template using NEConvolutionFixture = ConvolutionRectangleValidationFixture; +TEST_SUITE(CustomConvolutionRectangle_U8) FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::U8)), datasets::BorderModes()), @@ -374,7 +463,167 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::Datas validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); } TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionRectangle_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_width", { 3, 5, 7, 9 })), + framework::dataset::make("filter_height", { 3, 5, 7, 9 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_width", { 3, 5, 7, 9 })), + framework::dataset::make("filter_height", { 3, 5, 7, 9 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} +TEST_SUITE_END() +TEST_SUITE_END() /* Custom Convolution Rectangle */ + +TEST_SUITE(CustomConvolutionSeparable) +TEST_SUITE(CustomConvolutionSeparable5x5) +template +using NEConvolutionFixture = ConvolutionSeparableValidationFixture; + +TEST_SUITE(CustomConvolutionSeparable5x5_U8) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); +} +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSeparable5x5_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 5 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} +TEST_SUITE_END() +TEST_SUITE_END() /* Custom Convolution Separable 5x5 */ + +TEST_SUITE(CustomConvolutionSeparable7x7) +template +using NEConvolutionFixture = ConvolutionSeparableValidationFixture; + +TEST_SUITE(CustomConvolutionSeparable7x7_U8) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); +} +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSeparablex7x7_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 7 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} +TEST_SUITE_END() +TEST_SUITE_END() /* Custom Convolution Separable 7x7 */ + +TEST_SUITE(CustomConvolutionSeparable9x9) +template +using NEConvolutionFixture = ConvolutionSeparableValidationFixture; + +TEST_SUITE(CustomConvolutionSeparable9x9_U8) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::U8)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 9 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::U8)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 9 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_u8); +} +TEST_SUITE_END() + +TEST_SUITE(CustomConvolutionSeparable9x9_S16) +FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 9 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", + DataType::S16)), + datasets::BorderModes()), + framework::dataset::make("filter_size", { 9 }))) +{ + // Validate output + validate(Accessor(_target), _reference, shape_to_valid_region(_reference.shape(), (_border_mode == BorderMode::UNDEFINED), BorderSize(_height / 2, _width / 2)), tolerance_s16); +} TEST_SUITE_END() +TEST_SUITE_END() /* Custom Convolution Separable 9x9 */ +TEST_SUITE_END() /* Custom Convolution Separable */ +TEST_SUITE_END() /* Custom Convolution */ TEST_SUITE_END() } // namespace validation } // namespace test diff --git a/tests/validation/fixtures/ConvolutionFixture.h b/tests/validation/fixtures/ConvolutionFixture.h index 85070cff83..4d0d7a2a6f 100644 --- a/tests/validation/fixtures/ConvolutionFixture.h +++ b/tests/validation/fixtures/ConvolutionFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -46,7 +46,7 @@ class ConvolutionValidationFixture : public framework::Fixture { protected: template - void setup(TensorShape shape, DataType data_type, BorderMode border_mode, const unsigned int width, const unsigned int height, const bool is_separable = false) + void setup(TensorShape shape, DataType output_data_type, BorderMode border_mode, const unsigned int width, const unsigned int height, const bool is_separable = false) { std::mt19937 gen(library->seed()); std::uniform_int_distribution distribution(0, 255); @@ -73,8 +73,8 @@ protected: create_conv(conv); } - _target = compute_target(shape, data_type, conv, scale, border_mode, constant_border_value); - _reference = compute_reference(shape, data_type, conv, scale, border_mode, constant_border_value); + _target = compute_target(shape, output_data_type, conv, scale, border_mode, constant_border_value); + _reference = compute_reference(shape, output_data_type, conv, scale, border_mode, constant_border_value); } void @@ -122,21 +122,19 @@ protected: library->fill_tensor_uniform(tensor, i); } - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) + SimpleTensor compute_reference(const TensorShape &shape, DataType output_data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) { - ARM_COMPUTE_ERROR_ON(data_type != DataType::U8); - // Create reference - SimpleTensor src{ shape, data_type }; + SimpleTensor src{ shape, DataType::U8 }; // Fill reference fill(src, 0); // Compute reference - return reference::convolution(src, conv, scale, border_mode, constant_border_value, _width, _height); + return reference::convolution(src, output_data_type, conv, scale, border_mode, constant_border_value, _width, _height); } - virtual TensorType compute_target(const TensorShape &shape, DataType data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) = 0; + virtual TensorType compute_target(const TensorShape &shape, DataType output_data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) = 0; BorderMode _border_mode{}; TensorType _target{}; @@ -150,17 +148,17 @@ class ConvolutionSquareValidationFixture : public ConvolutionValidationFixture - void setup(TensorShape shape, DataType data_type, BorderMode border_mode, const unsigned int width) + void setup(TensorShape shape, DataType output_data_type, BorderMode border_mode, const unsigned int width) { - ConvolutionValidationFixture::setup(shape, data_type, border_mode, width, width); + ConvolutionValidationFixture::setup(shape, output_data_type, border_mode, width, width); } protected: - TensorType compute_target(const TensorShape &shape, DataType data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) + TensorType compute_target(const TensorShape &shape, DataType output_data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) { // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); + TensorType src = create_tensor(shape, DataType::U8); + TensorType dst = create_tensor(shape, output_data_type); // Create and configure function FunctionType convolution; @@ -192,17 +190,17 @@ class ConvolutionSeparableValidationFixture : public ConvolutionValidationFixtur { public: template - void setup(TensorShape shape, DataType data_type, BorderMode border_mode, const unsigned int width) + void setup(TensorShape shape, DataType output_data_type, BorderMode border_mode, const unsigned int width) { - ConvolutionValidationFixture::setup(shape, data_type, border_mode, width, width, true); + ConvolutionValidationFixture::setup(shape, output_data_type, border_mode, width, width, true); } protected: - TensorType compute_target(const TensorShape &shape, DataType data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) + TensorType compute_target(const TensorShape &shape, DataType output_data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) { // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); + TensorType src = create_tensor(shape, DataType::U8); + TensorType dst = create_tensor(shape, output_data_type); // Create and configure function FunctionType convolution; @@ -234,17 +232,17 @@ class ConvolutionRectangleValidationFixture : public ConvolutionValidationFixtur { public: template - void setup(TensorShape shape, DataType data_type, BorderMode border_mode, const unsigned int width, const unsigned int height) + void setup(TensorShape shape, DataType output_data_type, BorderMode border_mode, const unsigned int width, const unsigned int height) { - ConvolutionValidationFixture::setup(shape, data_type, border_mode, width, height); + ConvolutionValidationFixture::setup(shape, output_data_type, border_mode, width, height); } protected: - TensorType compute_target(const TensorShape &shape, DataType data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) + TensorType compute_target(const TensorShape &shape, DataType output_data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value) { // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); + TensorType src = create_tensor(shape, DataType::U8); + TensorType dst = create_tensor(shape, output_data_type); // Create and configure function FunctionType convolution; diff --git a/tests/validation/reference/Convolution.cpp b/tests/validation/reference/Convolution.cpp index 777e2df400..308c0b5a87 100644 --- a/tests/validation/reference/Convolution.cpp +++ b/tests/validation/reference/Convolution.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -35,34 +35,57 @@ namespace validation namespace reference { template -SimpleTensor convolution(const SimpleTensor &src, const int16_t *conv, uint32_t scale, BorderMode border_mode, T constant_border_value, const unsigned int width, const unsigned int height) +SimpleTensor convolution(const SimpleTensor &src, DataType output_data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value, + const unsigned int width, + const unsigned int height) { - SimpleTensor dst(src.shape(), src.data_type()); - SimpleTensor sum(src.shape(), src.data_type()); + ARM_COMPUTE_ERROR_ON(0 == scale); + + SimpleTensor dst(src.shape(), output_data_type); for(int element_idx = 0; element_idx < src.num_elements(); ++element_idx) { const Coordinates id = index2coord(src.shape(), element_idx); - apply_2d_spatial_filter(id, src, sum, TensorShape(width, height), conv, 1, border_mode, constant_border_value); - if(tensor_elem_at(sum, id, border_mode, constant_border_value) < 0) - { - dst[element_idx] = 0; - } - else if((tensor_elem_at(sum, id, border_mode, constant_border_value) / scale) > 255) + switch(output_data_type) { - dst[element_idx] = 255; - } - else - { - dst[element_idx] = tensor_elem_at(sum, id, border_mode, constant_border_value) / scale; + case DataType::S16: + { + SimpleTensor sum(src.shape(), output_data_type); + apply_2d_spatial_filter(id, src, sum, TensorShape(width, height), conv, 1 / static_cast(scale), border_mode, constant_border_value); + dst[element_idx] = tensor_elem_at(sum, id, border_mode, constant_border_value); + } + break; + case DataType::U8: + { + SimpleTensor sum(src.shape(), output_data_type); + apply_2d_spatial_filter(id, src, sum, TensorShape(width, height), conv, 1, border_mode, constant_border_value); + if(tensor_elem_at(sum, id, border_mode, constant_border_value) < 0) + { + dst[element_idx] = 0; + } + else if((tensor_elem_at(sum, id, border_mode, constant_border_value) / scale) > 255) + { + dst[element_idx] = 255; + } + else + { + dst[element_idx] = tensor_elem_at(sum, id, border_mode, constant_border_value) / scale; + } + } + break; + default: + ARM_COMPUTE_ERROR("Not supported DataType"); + break; } } return dst; } -template SimpleTensor convolution(const SimpleTensor &src, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value, +template SimpleTensor convolution(const SimpleTensor &src, DataType output_data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value, + const unsigned int widht, const unsigned int height); +template SimpleTensor convolution(const SimpleTensor &src, DataType output_data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value, const unsigned int widht, const unsigned int height); } // namespace reference } // namespace validation diff --git a/tests/validation/reference/Convolution.h b/tests/validation/reference/Convolution.h index ea9f4e444b..b217da7cd2 100644 --- a/tests/validation/reference/Convolution.h +++ b/tests/validation/reference/Convolution.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -35,7 +35,9 @@ namespace validation namespace reference { template -SimpleTensor convolution(const SimpleTensor &src, const int16_t *conv, uint32_t scale, BorderMode border_mode, T constant_border_value, const unsigned int width, const unsigned int height); +SimpleTensor convolution(const SimpleTensor &src, DataType output_data_type, const int16_t *conv, uint32_t scale, BorderMode border_mode, uint8_t constant_border_value, + const unsigned int width, + const unsigned int height); } // namespace reference } // namespace validation } // namespace test -- cgit v1.2.1