From 876be2a0d11874d871860dbd22481f831d6878f6 Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Tue, 3 Jul 2018 12:22:09 +0100 Subject: COMPMID-1339 - Implementing Winograd Convolution Layer 1x5 and 5x1 kernels on OpenCL NCHW Change-Id: Ia293cd89651146a0e27e5f7c74ca9c924807e83c Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/138707 Tested-by: Jenkins Reviewed-by: Georgios Pinitas --- tests/datasets/LargeConvolutionLayerDataset.h | 36 ++++++++++++++ tests/datasets/ShapeDatasets.h | 64 +++++++++++++++++++++++++ tests/datasets/SmallConvolutionLayerDataset.h | 20 ++++++++ tests/datasets/WinogradInputTransformDataset.h | 54 +++++++++++++++++++++ tests/datasets/WinogradOutputTransformDataset.h | 28 +++++++++++ 5 files changed, 202 insertions(+) (limited to 'tests/datasets') diff --git a/tests/datasets/LargeConvolutionLayerDataset.h b/tests/datasets/LargeConvolutionLayerDataset.h index ae25c8cd66..3eb98dbeea 100644 --- a/tests/datasets/LargeConvolutionLayerDataset.h +++ b/tests/datasets/LargeConvolutionLayerDataset.h @@ -122,6 +122,42 @@ public: } }; +class LargeWinogradConvolutionLayer5x1Dataset final : public ConvolutionLayerDataset +{ +public: + LargeWinogradConvolutionLayer5x1Dataset() + { + // Batch size 1 + add_config(TensorShape(224U, 224U, 3U), TensorShape(5U, 1U, 3U, 64U), TensorShape(64U), TensorShape(222U, 224U, 64U), PadStrideInfo(1, 1, 1, 0)); + add_config(TensorShape(123U, 134U, 16U), TensorShape(5U, 1U, 16U, 7U), TensorShape(7U), TensorShape(121U, 134U, 7U), PadStrideInfo(1, 1, 1, 0)); + add_config(TensorShape(181U, 152U, 42U), TensorShape(5U, 1U, 42U, 100U), TensorShape(100U), TensorShape(177U, 152U, 100U), PadStrideInfo(1, 1, 0, 0)); + add_config(TensorShape(200U, 201U, 24U), TensorShape(5U, 1U, 24U, 61), TensorShape(61U), TensorShape(200U, 201U, 61), PadStrideInfo(1, 1, 2, 0)); + + // Batch size 2, 3 and 4 + add_config(TensorShape(224U, 224U, 3U, 2U), TensorShape(5U, 1U, 3U, 64U), TensorShape(64U), TensorShape(222U, 224U, 64U, 2U), PadStrideInfo(1, 1, 1, 0)); + add_config(TensorShape(123U, 134U, 16U, 3U), TensorShape(5U, 1U, 16U, 7U), TensorShape(7U), TensorShape(121U, 134U, 7U, 3U), PadStrideInfo(1, 1, 1, 0)); + add_config(TensorShape(181U, 152U, 42U, 4U), TensorShape(5U, 1U, 42U, 100U), TensorShape(100U), TensorShape(177U, 152U, 100U, 4U), PadStrideInfo(1, 1, 0, 0)); + } +}; + +class LargeWinogradConvolutionLayer1x5Dataset final : public ConvolutionLayerDataset +{ +public: + LargeWinogradConvolutionLayer1x5Dataset() + { + // Batch size 1 + add_config(TensorShape(224U, 224U, 3U), TensorShape(1U, 5U, 3U, 64U), TensorShape(64U), TensorShape(224U, 222U, 64U), PadStrideInfo(1, 1, 0, 1)); + add_config(TensorShape(123U, 134U, 16U), TensorShape(1U, 5U, 16U, 7U), TensorShape(7U), TensorShape(123U, 130U, 7U), PadStrideInfo(1, 1, 0, 0)); + add_config(TensorShape(181U, 152U, 42U), TensorShape(1U, 5U, 42U, 100U), TensorShape(100U), TensorShape(181U, 148U, 100U), PadStrideInfo(1, 1, 0, 0)); + add_config(TensorShape(200U, 201U, 24U), TensorShape(1U, 5U, 24U, 61), TensorShape(61U), TensorShape(200U, 201U, 61), PadStrideInfo(1, 1, 0, 2)); + + // Batch size 2, 3 and 4 + add_config(TensorShape(224U, 224U, 3U, 2U), TensorShape(1U, 5U, 3U, 64U), TensorShape(64U), TensorShape(224U, 222U, 64U, 2U), PadStrideInfo(1, 1, 0, 1)); + add_config(TensorShape(123U, 134U, 16U, 3U), TensorShape(1U, 5U, 16U, 7U), TensorShape(7U), TensorShape(123U, 130U, 7U, 3U), PadStrideInfo(1, 1, 0, 0)); + add_config(TensorShape(181U, 152U, 42U, 4U), TensorShape(1U, 5U, 42U, 100U), TensorShape(100U), TensorShape(181U, 148U, 100U, 4U), PadStrideInfo(1, 1, 0, 0)); + } +}; + class LargeConvolutionLayerDataset final : public ConvolutionLayerDataset { public: diff --git a/tests/datasets/ShapeDatasets.h b/tests/datasets/ShapeDatasets.h index 766530b0d7..bc98b1e471 100644 --- a/tests/datasets/ShapeDatasets.h +++ b/tests/datasets/ShapeDatasets.h @@ -500,6 +500,70 @@ public: } }; +/** Data set containing small 5x1 tensor shapes. */ +class Small5x1Shapes final : public ShapeDataset +{ +public: + Small5x1Shapes() + : ShapeDataset("Shape", + { + TensorShape{ 5U, 1U, 7U, 4U }, + TensorShape{ 5U, 1U, 4U, 13U }, + TensorShape{ 5U, 1U, 9U, 2U }, + TensorShape{ 5U, 1U, 3U, 5U }, + }) + { + } +}; + +/** Data set containing large 5x1 tensor shapes. */ +class Large5x1Shapes final : public ShapeDataset +{ +public: + Large5x1Shapes() + : ShapeDataset("Shape", + { + TensorShape{ 5U, 1U, 32U, 64U }, + TensorShape{ 5U, 1U, 51U, 13U }, + TensorShape{ 5U, 1U, 53U, 47U }, + TensorShape{ 5U, 1U, 128U, 384U }, + }) + { + } +}; + +/** Data set containing small 1x5 tensor shapes. */ +class Small1x5Shapes final : public ShapeDataset +{ +public: + Small1x5Shapes() + : ShapeDataset("Shape", + { + TensorShape{ 1U, 5U, 7U, 4U }, + TensorShape{ 1U, 5U, 4U, 13U }, + TensorShape{ 1U, 5U, 9U, 2U }, + TensorShape{ 1U, 5U, 3U, 5U }, + }) + { + } +}; + +/** Data set containing large 1x5 tensor shapes. */ +class Large1x5Shapes final : public ShapeDataset +{ +public: + Large1x5Shapes() + : ShapeDataset("Shape", + { + TensorShape{ 1U, 5U, 32U, 64U }, + TensorShape{ 1U, 5U, 51U, 13U }, + TensorShape{ 1U, 5U, 53U, 47U }, + TensorShape{ 1U, 5U, 128U, 384U }, + }) + { + } +}; + /** Data set containing small tensor shapes for deconvolution. */ class SmallDeconvolutionShapes final : public ShapeDataset { diff --git a/tests/datasets/SmallConvolutionLayerDataset.h b/tests/datasets/SmallConvolutionLayerDataset.h index f05cc15c06..ae12dd4b16 100644 --- a/tests/datasets/SmallConvolutionLayerDataset.h +++ b/tests/datasets/SmallConvolutionLayerDataset.h @@ -92,6 +92,26 @@ public: } }; +class SmallWinogradConvolutionLayer5x1Dataset final : public ConvolutionLayerDataset +{ +public: + SmallWinogradConvolutionLayer5x1Dataset() + { + add_config(TensorShape(8U, 8U, 2U), TensorShape(5U, 1U, 2U, 1U), TensorShape(1U), TensorShape(4U, 8U, 1U), PadStrideInfo(1, 1, 0, 0)); + add_config(TensorShape(8U, 8U, 2U), TensorShape(5U, 1U, 2U), TensorShape(1U), TensorShape(8U, 8U, 1U), PadStrideInfo(1, 1, 2, 0)); + } +}; + +class SmallWinogradConvolutionLayer1x5Dataset final : public ConvolutionLayerDataset +{ +public: + SmallWinogradConvolutionLayer1x5Dataset() + { + add_config(TensorShape(8U, 8U, 2U), TensorShape(1U, 5U, 2U, 1U), TensorShape(1U), TensorShape(8U, 4U, 1U), PadStrideInfo(1, 1, 0, 0)); + add_config(TensorShape(8U, 8U, 2U), TensorShape(1U, 5U, 2U), TensorShape(1U), TensorShape(8U, 8U, 1U), PadStrideInfo(1, 1, 0, 2)); + } +}; + class SmallConvolutionLayerDataset final : public ConvolutionLayerDataset { public: diff --git a/tests/datasets/WinogradInputTransformDataset.h b/tests/datasets/WinogradInputTransformDataset.h index ca23984a1d..bd910fb055 100644 --- a/tests/datasets/WinogradInputTransformDataset.h +++ b/tests/datasets/WinogradInputTransformDataset.h @@ -202,6 +202,36 @@ public: } }; +class SmallWinogradInputTransformDataset4x1_5x1 final : public WinogradInputTransformDataset +{ +public: + SmallWinogradInputTransformDataset4x1_5x1() + { + add_config(TensorShape(9U, 9U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(9U, 9U), PadStrideInfo(1, 1, 2, 0), DataLayout::NCHW)); + add_config(TensorShape(27U, 13U, 2U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(27U, 13U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW)); + add_config(TensorShape(128U, 64U, 1U, 3U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(128U, 64U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW)); + add_config(TensorShape(9U, 9U, 3U, 4U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(9U, 9U), PadStrideInfo(1, 1, 2, 0), DataLayout::NCHW)); + add_config(TensorShape(27U, 13U, 2U, 4U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(27U, 13U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW)); + add_config(TensorShape(9U, 9U, 3U, 5U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(14U, 14U, 512U, 2U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(14U, 14U), PadStrideInfo(1, 1, 2, 0), DataLayout::NCHW)); + } +}; + +class SmallWinogradInputTransformDataset1x4_1x5 final : public WinogradInputTransformDataset +{ +public: + SmallWinogradInputTransformDataset1x4_1x5() + { + add_config(TensorShape(9U, 9U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 2), DataLayout::NCHW)); + add_config(TensorShape(27U, 13U, 2U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(27U, 13U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW)); + add_config(TensorShape(128U, 64U, 1U, 3U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(128U, 64U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW)); + add_config(TensorShape(9U, 9U, 3U, 4U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 2), DataLayout::NCHW)); + add_config(TensorShape(27U, 13U, 2U, 4U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(27U, 13U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW)); + add_config(TensorShape(9U, 9U, 3U, 5U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(9U, 9U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(14U, 14U, 512U, 2U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(14U, 14U), PadStrideInfo(1, 1, 0, 2), DataLayout::NCHW)); + } +}; + class LargeWinogradInputTransformDataset2x2_3x3 final : public WinogradInputTransformDataset { public: @@ -285,6 +315,30 @@ public: add_config(TensorShape(83U, 72U, 14U, 5U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(83U, 72U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); } }; + +class LargeWinogradInputTransformDataset4x1_5x1 final : public WinogradInputTransformDataset +{ +public: + LargeWinogradInputTransformDataset4x1_5x1() + { + add_config(TensorShape(42U, 37U, 8U, 15U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(42U, 37U), PadStrideInfo(1, 1, 2, 0), DataLayout::NCHW)); + add_config(TensorShape(57U, 60U, 13U, 8U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(57U, 60U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW)); + add_config(TensorShape(128U, 64U, 21U, 13U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(128U, 64U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(83U, 72U, 14U, 5U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(83U, 72U), PadStrideInfo(1, 1, 2, 0), DataLayout::NCHW)); + } +}; + +class LargeWinogradInputTransformDataset1x4_1x5 final : public WinogradInputTransformDataset +{ +public: + LargeWinogradInputTransformDataset1x4_1x5() + { + add_config(TensorShape(42U, 37U, 8U, 15U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(42U, 37U), PadStrideInfo(1, 1, 0, 2), DataLayout::NCHW)); + add_config(TensorShape(57U, 60U, 13U, 8U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(57U, 60U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW)); + add_config(TensorShape(128U, 64U, 21U, 13U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(128U, 64U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(83U, 72U, 14U, 5U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(83U, 72U), PadStrideInfo(1, 1, 0, 2), DataLayout::NCHW)); + } +}; } // namespace datasets } // namespace test } // namespace arm_compute diff --git a/tests/datasets/WinogradOutputTransformDataset.h b/tests/datasets/WinogradOutputTransformDataset.h index a4689c6ef1..fc23e65258 100644 --- a/tests/datasets/WinogradOutputTransformDataset.h +++ b/tests/datasets/WinogradOutputTransformDataset.h @@ -154,6 +154,22 @@ public: add_config(TensorShape(7U, 2U, 64U, 3U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); add_config(TensorShape(24U, 9U, 64U, 2U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 1), DataLayout::NCHW)); add_config(TensorShape(7U, 2U, 64U, 5U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + + // (4x1, 5x1) + add_config(TensorShape(13U, 6U, 8U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(7U, 6U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(7U, 22U, 8U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(10U, 11U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(5U, 462U, 8U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(53U, 33U), PadStrideInfo(1, 1, 2, 0), DataLayout::NCHW)); + add_config(TensorShape(7U, 10U, 8U, 3U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(24U, 42U, 8U, 2U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(14U, 14U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW)); + add_config(TensorShape(7U, 20U, 8U, 5U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(8U, 10U), PadStrideInfo(1, 1, 2, 0), DataLayout::NCHW)); + + // (1x4, 1x5) + add_config(TensorShape(13U, 7U, 8U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(7U, 6U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(7U, 20U, 8U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(10U, 11U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(5U, 477U, 8U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(53U, 33U), PadStrideInfo(1, 1, 0, 2), DataLayout::NCHW)); + add_config(TensorShape(7U, 16U, 8U, 3U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(24U, 42U, 8U, 2U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(14U, 14U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW)); + add_config(TensorShape(7U, 24U, 8U, 5U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(8U, 10U), PadStrideInfo(1, 1, 0, 2), DataLayout::NCHW)); } }; @@ -238,6 +254,18 @@ public: add_config(TensorShape(13U, 182U, 64U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(56U, 56U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW)); add_config(TensorShape(32U, 756U, 64U, 2U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(112U, 112U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW)); add_config(TensorShape(13U, 182U, 64U, 5U), WinogradInfo(Size2D(4U, 4U), Size2D(5U, 5U), Size2D(56U, 56U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW)); + + // (4x1, 5x1) + add_config(TensorShape(32U, 3136U, 8U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(112U, 112U), PadStrideInfo(1, 1, 2, 0), DataLayout::NCHW)); + add_config(TensorShape(13U, 784U, 8U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(56U, 56U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW)); + add_config(TensorShape(32U, 3024U, 8U, 2U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(112U, 112U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(13U, 784U, 8U, 5U), WinogradInfo(Size2D(4U, 1U), Size2D(5U, 1U), Size2D(56U, 56U), PadStrideInfo(1, 1, 1, 0), DataLayout::NCHW)); + + // (1x4, 1x5) + add_config(TensorShape(32U, 3136U, 8U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(112U, 112U), PadStrideInfo(1, 1, 0, 2), DataLayout::NCHW)); + add_config(TensorShape(13U, 784U, 8U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(56U, 56U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW)); + add_config(TensorShape(32U, 3024U, 8U, 2U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(112U, 112U), PadStrideInfo(1, 1, 0, 0), DataLayout::NCHW)); + add_config(TensorShape(13U, 784U, 8U, 5U), WinogradInfo(Size2D(1U, 4U), Size2D(1U, 5U), Size2D(56U, 56U), PadStrideInfo(1, 1, 0, 1), DataLayout::NCHW)); } }; -- cgit v1.2.1