From 96e922e8ee4187906211ee0d1dd0f3e27667c170 Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Wed, 26 Sep 2018 11:25:15 +0100 Subject: COMPMID-1602: Added Winograd tests for kernel 7x1 and 1x7. Change-Id: I9250b2e8020fe87c6ed4de582bbc7460bbd8e94b Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/150287 Tested-by: bsgcomp Reviewed-by: Isabella Gottardi --- tests/validation/NEON/ConvolutionLayer.cpp | 44 ++++++++++++++++++++++ .../fixtures/WinogradConvolutionLayerFixture.h | 12 +++++- tests/validation/reference/Winograd.cpp | 36 ++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) (limited to 'tests/validation') diff --git a/tests/validation/NEON/ConvolutionLayer.cpp b/tests/validation/NEON/ConvolutionLayer.cpp index 61bf4a2c37..72e67a9acc 100644 --- a/tests/validation/NEON/ConvolutionLayer.cpp +++ b/tests/validation/NEON/ConvolutionLayer.cpp @@ -211,6 +211,50 @@ FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture, frame TEST_SUITE_END() // Conv5x1 +TEST_SUITE(Conv7x1) +FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(datasets::SmallWinogradConvolutionLayer7x1Dataset(), + framework::dataset::make("DataType", { DataType::F32 })), + ActivationFunctionsDataset), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) +{ + // Validate output + validate(Accessor(_target), _reference, abs_tolerance_f32); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + combine(combine(combine(datasets::LargeWinogradConvolutionLayer7x1Dataset(), + framework::dataset::make("DataType", { DataType::F32 })), + ActivationFunctionsDataset), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) +{ + // Validate output + validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); +} +TEST_SUITE_END() // Conv7x1 + +TEST_SUITE(Conv1x7) +FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, + combine(combine(combine(datasets::SmallWinogradConvolutionLayer1x7Dataset(), + framework::dataset::make("DataType", { DataType::F32 })), + ActivationFunctionsDataset), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) +{ + // Validate output + validate(Accessor(_target), _reference, abs_tolerance_f32); +} + +FIXTURE_DATA_TEST_CASE(RunLarge, NEWinogradConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, + combine(combine(combine(datasets::LargeWinogradConvolutionLayer7x1Dataset(), + framework::dataset::make("DataType", { DataType::F32 })), + ActivationFunctionsDataset), + framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC }))) +{ + // Validate output + validate(Accessor(_target), _reference, abs_tolerance_1xN_f32); +} +TEST_SUITE_END() // Conv1x7 + TEST_SUITE(Conv3x3) FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallWinogradConvolutionLayer3x3Dataset(), diff --git a/tests/validation/fixtures/WinogradConvolutionLayerFixture.h b/tests/validation/fixtures/WinogradConvolutionLayerFixture.h index 41f16d3a39..15ce201222 100644 --- a/tests/validation/fixtures/WinogradConvolutionLayerFixture.h +++ b/tests/validation/fixtures/WinogradConvolutionLayerFixture.h @@ -263,7 +263,17 @@ protected: // Set output tile Size2D output_tile(4U, 4U); - if(weights_shape[0] == 1) + if(weights_shape[0] == 7 && weights_shape[1] == 1) + { + output_tile.width = 2; + output_tile.height = 1; + } + else if(weights_shape[0] == 1 && weights_shape[1] == 7) + { + output_tile.width = 1; + output_tile.height = 2; + } + else if(weights_shape[0] == 1) { output_tile.width = 1; } diff --git a/tests/validation/reference/Winograd.cpp b/tests/validation/reference/Winograd.cpp index 3c2c11d632..294993b8d2 100644 --- a/tests/validation/reference/Winograd.cpp +++ b/tests/validation/reference/Winograd.cpp @@ -75,6 +75,18 @@ void initialize_matrix_transform(SimpleTensor &src, const Size2D &output_tile 0.f, -1.f, 0.f, 21.f / 4.f, 0.f, -21.f / 4.f, 0.f, 1.f }; + static const float imatrix2x1_7x7[] = + { + -36.0f, 0.0f, 49.0f, 0.0f, -14.0f, 0.0f, 1.0f, 0.0f, + 0.0f, -36.0f, 36.0f, 13.0f, -13.0f, -1.0f, 1.0f, 0.0f, + 0.0f, 36.0f, 36.0f, -13.0f, -13.0f, 1.0f, 1.0f, 0.0f, + 0.0f, -18.0f, 9.0f, 20.0f, -10.0f, -2.0f, 1.0f, 0.0f, + 0.0f, 18.0f, 9.0f, -20.0f, -10.0f, 2.0f, 1.0f, 0.0f, + 0.0f, -12.0f, 4.0f, 15.0f, -5.0f, -3.0f, 1.0f, 0.0f, + 0.0f, 12.0f, 4.0f, -15.0f, -5.0f, 3.0f, 1.0f, 0.0f, + 0.0f, -36.0f, 0.0f, 49.0f, 0.0f, -14.0f, 0.0f, 1.0f + }; + // ------------------------------------------ // Winograd filter transform matrices @@ -109,6 +121,18 @@ void initialize_matrix_transform(SimpleTensor &src, const Size2D &output_tile }; + static const float fmatrix2x1_7x7[] = + { + -1.0f / 36.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 1.0f / 48.0f, -1.0f / 48.0f, 1.0f / 48.0f, -1.0f / 48.0f, 1.0f / 48.0f, -1.0f / 48.0f, 1.0f / 48.0f, + 1.0f / 48.0f, 1.0f / 48.0f, 1.0f / 48.0f, 1.0f / 48.0f, 1.0f / 48.0f, 1.0f / 48.0f, 1.0f / 48.0f, + -1.0f / 120.0f, 1.0f / 60.0f, -1.0f / 30.0f, 1.0f / 15.0f, -2.0f / 15.0f, 4.0f / 15.0f, -8.0f / 15.0f, + -1.0f / 120.0f, -1.0f / 60.0f, -1.0f / 30.0f, -1.0f / 15.0f, -2.0f / 15.0f, -4.0f / 15.0f, -8.0f / 15.0f, + 1.0f / 720.0f, -1.0f / 240.0f, 1.0f / 80.0f, -3.0f / 80.0f, 9.0f / 80.0f, -27.0f / 80.0f, 81.0f / 80.0f, + 1.0f / 720.0f, 1.0f / 240.0f, 1.0f / 80.0f, 3.0f / 80.0f, 9.0f / 80.0f, 27.0f / 80.0f, 81.0f / 80.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f + }; + // ------------------------------------------ // Winograd output transform matrices @@ -134,6 +158,12 @@ void initialize_matrix_transform(SimpleTensor &src, const Size2D &output_tile 0.0f, 1.0f, -1.0f, 8.0f, -8.0f, 1.0f, -1.0f, 1.0f }; + static const float omatrix2x1_7x7[] = + { + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, + 0.0f, -1.0f, 1.0f, -2.0f, 2.0f, -3.0f, 3.0f, 1.0f + }; + // ------------------------------------------ using WinogradKey = std::tuple, std::pair, WinogradTransformType>; @@ -149,6 +179,8 @@ void initialize_matrix_transform(SimpleTensor &src, const Size2D &output_tile { WinogradKey(std::pair(1, 4), std::pair(1, 3), WinogradTransformType::INPUT), imatrix4x4_3x3 }, { WinogradKey(std::pair(4, 4), std::pair(5, 5), WinogradTransformType::INPUT), imatrix4x4_5x5 }, { WinogradKey(std::pair(4, 1), std::pair(5, 1), WinogradTransformType::INPUT), imatrix4x4_5x5 }, + { WinogradKey(std::pair(2, 1), std::pair(7, 1), WinogradTransformType::INPUT), imatrix2x1_7x7 }, + { WinogradKey(std::pair(1, 2), std::pair(1, 7), WinogradTransformType::INPUT), imatrix2x1_7x7 }, { WinogradKey(std::pair(1, 4), std::pair(1, 5), WinogradTransformType::INPUT), imatrix4x4_5x5 }, { WinogradKey(std::pair(2, 2), std::pair(3, 3), WinogradTransformType::FILTER), fmatrix2x2_3x3 }, { WinogradKey(std::pair(4, 4), std::pair(3, 3), WinogradTransformType::FILTER), fmatrix4x4_3x3 }, @@ -158,6 +190,8 @@ void initialize_matrix_transform(SimpleTensor &src, const Size2D &output_tile { WinogradKey(std::pair(1, 4), std::pair(1, 3), WinogradTransformType::FILTER), fmatrix4x4_3x3 }, { WinogradKey(std::pair(4, 4), std::pair(5, 5), WinogradTransformType::FILTER), fmatrix4x4_5x5 }, { WinogradKey(std::pair(4, 1), std::pair(5, 1), WinogradTransformType::FILTER), fmatrix4x4_5x5 }, + { WinogradKey(std::pair(2, 1), std::pair(7, 1), WinogradTransformType::FILTER), fmatrix2x1_7x7 }, + { WinogradKey(std::pair(1, 2), std::pair(1, 7), WinogradTransformType::FILTER), fmatrix2x1_7x7 }, { WinogradKey(std::pair(1, 4), std::pair(1, 5), WinogradTransformType::FILTER), fmatrix4x4_5x5 }, { WinogradKey(std::pair(2, 2), std::pair(3, 3), WinogradTransformType::OUTPUT), omatrix2x2_3x3 }, { WinogradKey(std::pair(4, 4), std::pair(3, 3), WinogradTransformType::OUTPUT), omatrix4x4_3x3 }, @@ -167,6 +201,8 @@ void initialize_matrix_transform(SimpleTensor &src, const Size2D &output_tile { WinogradKey(std::pair(1, 4), std::pair(1, 3), WinogradTransformType::OUTPUT), omatrix4x4_3x3 }, { WinogradKey(std::pair(4, 4), std::pair(5, 5), WinogradTransformType::OUTPUT), omatrix4x4_5x5 }, { WinogradKey(std::pair(4, 1), std::pair(5, 1), WinogradTransformType::OUTPUT), omatrix4x4_5x5 }, + { WinogradKey(std::pair(2, 1), std::pair(7, 1), WinogradTransformType::OUTPUT), omatrix2x1_7x7 }, + { WinogradKey(std::pair(1, 2), std::pair(1, 7), WinogradTransformType::OUTPUT), omatrix2x1_7x7 }, { WinogradKey(std::pair(1, 4), std::pair(1, 5), WinogradTransformType::OUTPUT), omatrix4x4_5x5 }, }; -- cgit v1.2.1