From d2fab7315bac3a586f2f1b1c8d64f2441f89ca64 Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Fri, 2 Mar 2018 11:18:12 +0000 Subject: COMPMID-935 - Implementing Convolution with Winograd on OpenCL (part 4) Implemented Winograd Output Transform (2x2,3x3) on OpenCL Implemented CLWinogradConvolutionLayer on OpenCL Change-Id: I6a113fc5f052ca07f878d2b800d2ab003f84af65 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/125148 Reviewed-by: Georgios Pinitas Tested-by: Jenkins --- tests/datasets/WinogradOutputTransformDataset.h | 153 ++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 tests/datasets/WinogradOutputTransformDataset.h (limited to 'tests/datasets/WinogradOutputTransformDataset.h') diff --git a/tests/datasets/WinogradOutputTransformDataset.h b/tests/datasets/WinogradOutputTransformDataset.h new file mode 100644 index 0000000000..c42d6c8ebd --- /dev/null +++ b/tests/datasets/WinogradOutputTransformDataset.h @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2018 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_WINOGRAD_OUTPUT_TRANSFORM_DATASET +#define ARM_COMPUTE_TEST_WINOGRAD_OUTPUT_TRANSFORM_DATASET + +#include "utils/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class WinogradOutputTransformDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator a_it, + std::vector::const_iterator b_it, + std::vector::const_iterator c_it, + std::vector::const_iterator d_it, + std::vector::const_iterator data_layout_it) + : _a_it{ std::move(a_it) }, + _b_it{ std::move(b_it) }, + _c_it{ std::move(c_it) }, + _d_it{ std::move(d_it) }, + _data_layout_it{ std::move(data_layout_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "Input=" << *_a_it << ":"; + description << "KernelDims=" << *_b_it << ":"; + description << "OutputDims=" << *_c_it << ":"; + description << "NumTiles=" << *_d_it << ":"; + description << "DataLayout=" << *_data_layout_it; + return description.str(); + } + + WinogradOutputTransformDataset::type operator*() const + { + return std::make_tuple(*_a_it, *_b_it, *_c_it, *_d_it, *_data_layout_it); + } + + iterator &operator++() + { + ++_a_it; + ++_b_it; + ++_c_it; + ++_d_it; + ++_data_layout_it; + + return *this; + } + + private: + std::vector::const_iterator _a_it; + std::vector::const_iterator _b_it; + std::vector::const_iterator _c_it; + std::vector::const_iterator _d_it; + std::vector::const_iterator _data_layout_it; + }; + + iterator begin() const + { + return iterator(_a_shapes.begin(), _b_dims.begin(), _c_dims.begin(), _d_dims.begin(), _data_layout.begin()); + } + + int size() const + { + return std::min(_a_shapes.size(), std::min(_b_dims.size(), std::min(_c_dims.size(), std::min(_d_dims.size(), _data_layout.size())))); + } + + void add_config(TensorShape a, Size2D b, Size2D c, Size2D d, DataLayout data_layout) + { + _a_shapes.emplace_back(std::move(a)); + _b_dims.emplace_back(std::move(b)); + _c_dims.emplace_back(std::move(c)); + _d_dims.emplace_back(std::move(d)); + _data_layout.emplace_back(std::move(data_layout)); + } + +protected: + WinogradOutputTransformDataset() = default; + WinogradOutputTransformDataset(WinogradOutputTransformDataset &&) = default; + +private: + std::vector _a_shapes{}; + std::vector _b_dims{}; + std::vector _c_dims{}; + std::vector _d_dims{}; + std::vector _data_layout{}; +}; + +class SmallWinogradOutputTransformDataset final : public WinogradOutputTransformDataset +{ +public: + SmallWinogradOutputTransformDataset() + { + add_config(TensorShape(24U, 49U, 16U), Size2D(3, 3), Size2D(14U, 14U), Size2D(7U, 7U), DataLayout::NCHW); + add_config(TensorShape(13U, 6U, 16U), Size2D(3, 3), Size2D(5U, 4U), Size2D(3U, 2U), DataLayout::NCHW); + add_config(TensorShape(7U, 20U, 16U), Size2D(3, 3), Size2D(8U, 9U), Size2D(4U, 5U), DataLayout::NCHW); + add_config(TensorShape(24U, 49U, 16U, 3U), Size2D(3, 3), Size2D(14U, 14U), Size2D(7U, 7U), DataLayout::NCHW); + add_config(TensorShape(13U, 6U, 16U, 2U), Size2D(3, 3), Size2D(5U, 4U), Size2D(3U, 2U), DataLayout::NCHW); + add_config(TensorShape(7U, 20U, 16U, 5U), Size2D(3, 3), Size2D(8U, 9U), Size2D(4U, 5U), DataLayout::NCHW); + } +}; + +class LargeWinogradOutputTransformDataset final : public WinogradOutputTransformDataset +{ +public: + LargeWinogradOutputTransformDataset() + { + add_config(TensorShape(128U, 3136U, 16U), Size2D(3, 3), Size2D(112U, 112U), Size2D(56U, 56U), DataLayout::NCHW); + add_config(TensorShape(256U, 784U, 16U), Size2D(3, 3), Size2D(55U, 55U), Size2D(28U, 28U), DataLayout::NCHW); + add_config(TensorShape(512U, 169U, 16U), Size2D(3, 3), Size2D(26U, 26U), Size2D(13U, 13U), DataLayout::NCHW); + add_config(TensorShape(128U, 3136U, 16U, 3U), Size2D(3, 3), Size2D(112U, 112U), Size2D(56U, 56U), DataLayout::NCHW); + add_config(TensorShape(256U, 784U, 16U, 2U), Size2D(3, 3), Size2D(55U, 55U), Size2D(28U, 28U), DataLayout::NCHW); + add_config(TensorShape(512U, 169U, 16U, 5U), Size2D(3, 3), Size2D(26U, 26U), Size2D(13U, 13U), DataLayout::NCHW); + } +}; +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_WINOGRAD_OUTPUT_TRANSFORM_DATASET */ -- cgit v1.2.1