blob: 211ebdec90c1b762cea73fa2f4a4ecb960d61974 [file] [log] [blame]
Pablo Tello89519332017-11-17 11:52:36 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2020 Arm Limited.
Pablo Tello89519332017-11-17 11:52:36 +00003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Michele Di Giorgio6ad60af2020-06-09 14:52:15 +010024#include "src/core/NEON/kernels/NEWinogradConvolutionLayerKernel.h"
Pablo Tello89519332017-11-17 11:52:36 +000025
26#include "arm_compute/core/Error.h"
27#include "arm_compute/core/Helpers.h"
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010028#include "arm_compute/core/IAccessWindow.h"
Pablo Tello89519332017-11-17 11:52:36 +000029#include "arm_compute/core/ITensor.h"
30#include "arm_compute/core/TensorInfo.h"
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010031#include "arm_compute/core/Validate.h"
32#include "arm_compute/core/Window.h"
33#include "arm_compute/core/utils/misc/ShapeCalculator.h"
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +010034#include "src/core/AccessWindowStatic.h"
35#include "src/core/NEON/kernels/convolution/common/utils.hpp"
36#include "src/core/helpers/AutoConfiguration.h"
37#include "src/core/helpers/WindowHelpers.h"
Matthew Bentham92046462020-03-07 22:15:55 +000038#include "support/MemorySupport.h"
Pablo Tello3d4968a2017-12-04 15:03:35 +000039
Michele Di Giorgio6ad60af2020-06-09 14:52:15 +010040#include "src/core/NEON/kernels/convolution/winograd/winograd_layer.hpp"
41
Pablo Tello89519332017-11-17 11:52:36 +000042namespace arm_compute
43{
Pablo Tello52140b42018-01-30 14:48:11 +000044//Batched Gemms
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010045
46namespace
47{
Georgios Pinitas5ce897f2020-04-29 11:44:10 +010048inline bool is_kernel_size_supported(DataType data_type, Size2D size)
Pablo Tellobda6e4b2018-08-22 11:40:33 +010049{
Georgios Pinitas5ce897f2020-04-29 11:44:10 +010050 const std::array<Size2D, 8> f32_support = { { Size2D(1, 3), Size2D(3, 1), Size2D(5, 5), Size2D(3, 3), Size2D(1, 5), Size2D(5, 1), Size2D(7, 1), Size2D(1, 7) } };
51 const std::array<Size2D, 8> f16_support = { { Size2D(3, 3) } };
52
53 switch(data_type)
54 {
55 case DataType::F16:
56 return std::end(f16_support) != std::find(std::begin(f16_support), std::end(f16_support), size);
57 case DataType::F32:
58 return std::end(f32_support) != std::find(std::begin(f32_support), std::end(f32_support), size);
59 default:
60 return false;
61 }
Pablo Tellobda6e4b2018-08-22 11:40:33 +010062}
63
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010064Status validate_arguments_winograd_weight_trans(const ITensorInfo *input, const ITensorInfo *output, const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010065{
66 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input);
67 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +010068 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010069
Pablo Tellobda6e4b2018-08-22 11:40:33 +010070 const size_t idx_width = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::WIDTH);
71 const size_t idx_height = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::HEIGHT);
72 const auto input_width = input->dimension(idx_width);
73 const auto input_height = input->dimension(idx_height);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +010074 ARM_COMPUTE_RETURN_ERROR_ON_MSG(!is_kernel_size_supported(input->data_type(), Size2D(input_width, input_height)),
75 "Only 1x3, 3x1, 1x5, 5x1, 7x1, 1x7, 3x3 and 5x5 kernels are supported");
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010076 ARM_COMPUTE_RETURN_ERROR_ON(input->num_dimensions() > 4);
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010077 const Size2D &output_tile = winograd_info.output_tile_size;
Pablo Tello000d33a2018-09-03 16:59:20 +010078 const std::array<Size2D, 8> supported_tile_sizes = { { Size2D(2U, 2U), Size2D(4U, 4U), Size2D(1U, 6U), Size2D(6U, 1U), Size2D(4, 1), Size2D(1, 4), Size2D(2, 1), Size2D(1, 2) } };
Pablo Tellobda6e4b2018-08-22 11:40:33 +010079 ARM_COMPUTE_RETURN_ERROR_ON(std::end(supported_tile_sizes) == std::find(std::begin(supported_tile_sizes), std::end(supported_tile_sizes), output_tile));
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010080
81 // Checks performed when output is configured
82 if(output->total_size() != 0)
83 {
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010084 const TensorInfo tensor_info_output = input->clone()->set_tensor_shape(arm_compute::misc::shape_calculator::compute_winograd_filter_transform_shape(*input, winograd_info));
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010085
86 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(output, &tensor_info_output);
87 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
88 }
89
90 return Status{};
91}
92
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010093std::pair<Status, Window> validate_and_configure_window_winograd_weight_trans(ITensorInfo *input, ITensorInfo *output, const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010094{
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010095 // Output tensor auto inizialitation if not yet initialized
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010096 auto_init_if_empty(*output, input->clone()->set_tensor_shape(arm_compute::misc::shape_calculator::compute_winograd_filter_transform_shape(*input, winograd_info)));
morgolockc6d9a8b2019-12-23 10:45:59 +000097 const Window win = calculate_max_window(*input, Steps(), true /* skip border*/);
98 return std::make_pair(Status{}, win);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010099}
100
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100101Status validate_arguments_winograd_input_trans(const ITensorInfo *input, const ITensorInfo *output, const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100102{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100103 const Size2D &kernel_dims = winograd_info.kernel_size;
104 const PadStrideInfo &conv_info = winograd_info.convolution_info;
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100105 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input);
106 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100107 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100108 ARM_COMPUTE_RETURN_ERROR_ON_MSG(conv_info.stride().first != 1 || conv_info.stride().second != 1, "Winograd input transform only supports unit strides");
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100109 ARM_COMPUTE_RETURN_ERROR_ON_MSG(!is_kernel_size_supported(input->data_type(), Size2D(kernel_dims.width, kernel_dims.height)),
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100110 "Only 1x3, 3x1, 3x3 and 5x5 kernels are supported");
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100111
112 // Validate configured output
113 if(output->total_size() != 0)
114 {
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100115 const TensorShape output_shape = misc::shape_calculator::compute_winograd_input_transform_shape(*input, winograd_info);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100116
117 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), output_shape);
118 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
119 }
120
121 return Status{};
122}
123
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100124std::pair<Status, Window> validate_and_configure_window_winograd_input_trans(ITensorInfo *input, ITensorInfo *output, const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100125{
morgolockc6d9a8b2019-12-23 10:45:59 +0000126 const TensorShape output_shape = misc::shape_calculator::compute_winograd_input_transform_shape(*input, winograd_info);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100127 // Output auto inizialitation if not yet initialized
128 auto_init_if_empty(*output, input->clone()->set_tensor_shape(output_shape));
morgolockc6d9a8b2019-12-23 10:45:59 +0000129 return std::make_pair(Status{}, calculate_max_window(*input, Steps(), true));
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100130}
131
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100132Status validate_arguments_winograd_output_trans(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100133{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100134 const PadStrideInfo &conv_info = winograd_info.convolution_info;
135 const Size2D kernel_dims = winograd_info.kernel_size;
136
137 // Number of tiles along the X and Y direction
Vidhya Sudhan Loganathancb0010b2018-05-11 16:23:53 +0100138 const unsigned int num_tiles_x = std::ceil((winograd_info.input_dimensions.x() - (kernel_dims.width - 1) + conv_info.pad_left() + conv_info.pad_right()) / static_cast<float>
139 (winograd_info.output_tile_size.width));
140 const unsigned int num_tiles_y = std::ceil((winograd_info.input_dimensions.y() - (kernel_dims.height - 1) + conv_info.pad_top() + conv_info.pad_bottom()) / static_cast<float>
141 (winograd_info.output_tile_size.height));
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100142 const Size2D num_tiles = Size2D(num_tiles_x, num_tiles_y);
143
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100144 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input);
145 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100146 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100147 ARM_COMPUTE_RETURN_ERROR_ON(input->dimension(1) != num_tiles.area());
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100148 ARM_COMPUTE_RETURN_ERROR_ON_MSG(!is_kernel_size_supported(input->data_type(), Size2D(kernel_dims.width, kernel_dims.height)),
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100149 "Only 1x3, 3x1, 3x3 and 5x5 kernels are supported");
150
151 const std::array<unsigned int, 3> supported_gemm_sizes = { { 8U, 16U, 36U } };
152 ARM_COMPUTE_RETURN_ERROR_ON(std::end(supported_gemm_sizes) == std::find(std::begin(supported_gemm_sizes), std::end(supported_gemm_sizes), input->dimension(2)));
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100153 ARM_COMPUTE_UNUSED(kernel_dims);
154 if(bias != nullptr)
155 {
156 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, bias);
157 ARM_COMPUTE_RETURN_ERROR_ON(input->dimension(0) != bias->dimension(0));
158 ARM_COMPUTE_RETURN_ERROR_ON(bias->num_dimensions() != size_t(1));
159 }
160
161 // Checks performed when output is configured
162 if(output->total_size() != 0)
163 {
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100164 const TensorInfo tensor_info_output = input->clone()->set_tensor_shape(arm_compute::misc::shape_calculator::compute_winograd_output_transform_shape(*input, winograd_info));
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100165 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(output, &tensor_info_output);
166 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
167 }
168 return Status{};
169}
170
morgolockc6d9a8b2019-12-23 10:45:59 +0000171std::pair<Status, Window> validate_and_configure_window_winograd_output_trans(ITensorInfo *input, ITensorInfo *output, const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100172{
173 // Output tensor auto initialization if not yet initialized
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100174 auto_init_if_empty(*output, input->clone()->set_tensor_shape(arm_compute::misc::shape_calculator::compute_winograd_output_transform_shape(*input, winograd_info)));
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100175
morgolockc6d9a8b2019-12-23 10:45:59 +0000176 return std::make_pair(Status{}, calculate_max_window(*input, Steps(), true));
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100177}
178} // namespace
Pablo Tellod6ca4782018-01-23 09:36:04 +0000179
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100180Status INEWinogradLayerTransformWeightsKernel::validate(const ITensorInfo *input, const ITensorInfo *weights)
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100181{
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100182 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100183 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, weights);
184 const DataLayout data_layout = input->data_layout();
185 const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
186 const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100187 ARM_COMPUTE_RETURN_ERROR_ON_MSG(!is_kernel_size_supported(input->data_type(), Size2D(weights->dimension(width_idx), weights->dimension(height_idx))),
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100188 "Only 1x3, 3x1, 3x3 and 5x5 kernels are supported");
189 ARM_COMPUTE_RETURN_ERROR_ON(weights->num_dimensions() > 4);
190 return Status{};
191}
192
Pablo Tellof6c572c2018-02-14 12:47:30 +0000193template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello7df27862018-05-30 11:44:26 +0100194unsigned int NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_weight_storage_size(int num_output_channels, int num_input_channels) const
Pablo Tellod6ca4782018-01-23 09:36:04 +0000195{
Pablo Tello7df27862018-05-30 11:44:26 +0100196 const KernelShape shape(num_output_channels, KernelRows, KernelCols, num_input_channels);
Pablo Tello52140b42018-01-30 14:48:11 +0000197 return static_cast<unsigned int>(
Pablo Tellof6c572c2018-02-14 12:47:30 +0000198 // WinogradConv returns the size in bytes, we divide by `sizeof(T)` to express that in units of T
Pablo Tello5264b7d2019-10-21 14:25:41 +0100199 WinogradConv::get_kernel_storage_size(num_input_channels, num_output_channels) / sizeof(T));
Pablo Tello52140b42018-01-30 14:48:11 +0000200}
201
Pablo Tellof6c572c2018-02-14 12:47:30 +0000202template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
203NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::NEWinogradLayerTransformWeightsKernel()
Pablo Tello8f43d742019-03-27 09:28:32 +0000204 : _transform(nullptr), _weights_hwio(nullptr), _output(nullptr), _matrix_stride(0), _num_output_channels(0), _num_input_channels(0)
Pablo Tello52140b42018-01-30 14:48:11 +0000205{
206}
207
Pablo Tellof6c572c2018-02-14 12:47:30 +0000208template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello5264b7d2019-10-21 14:25:41 +0100209int NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_matrix_stride(int num_output_channels, int num_input_channels) const
Pablo Tellof6c572c2018-02-14 12:47:30 +0000210{
Pablo Tello5264b7d2019-10-21 14:25:41 +0100211 return WinogradConv::get_kernel_matrix_stride(num_input_channels, num_output_channels);
Pablo Tellof6c572c2018-02-14 12:47:30 +0000212}
213
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000214#ifndef DOXYGEN_SKIP_THIS
Pablo Tellof6c572c2018-02-14 12:47:30 +0000215template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
216void NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::configure(
Pablo Tello52140b42018-01-30 14:48:11 +0000217 const ITensor *weights_hwio,
Anthony Barbiere1553372018-07-16 18:53:52 +0100218 ITensor *output,
Pablo Tello7df27862018-05-30 11:44:26 +0100219 const int matrix_stride, /** Stride across matrices in the output. */
220 const int num_output_channels, /** Number of filters. */
221 const int num_input_channels) /** Number of channels in each filter. */
Pablo Tello52140b42018-01-30 14:48:11 +0000222{
Pablo Tello7df27862018-05-30 11:44:26 +0100223 _weights_hwio = weights_hwio;
224 _output = output;
225 _matrix_stride = matrix_stride;
226 _num_output_channels = num_output_channels;
227 _num_input_channels = num_input_channels;
Pablo Tello8f43d742019-03-27 09:28:32 +0000228 _transform = arm_compute::support::cpp14::make_unique<WeightsTransform>(num_output_channels, num_input_channels);
Pablo Tello7df27862018-05-30 11:44:26 +0100229
Pablo Tello8f43d742019-03-27 09:28:32 +0000230 Window win;
231 auto win_last = _transform->get_window();
Pablo Tellod6ca4782018-01-23 09:36:04 +0000232 win.set(Window::DimX, Window::Dimension(0, win_last, 1));
233 INEKernel::configure(win);
234}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000235#endif /* DOXYGEN_SKIP_THIS */
Pablo Tellod6ca4782018-01-23 09:36:04 +0000236
Pablo Tellof6c572c2018-02-14 12:47:30 +0000237template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
238void NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::run(const Window &window, const ThreadInfo &info)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000239{
240 ARM_COMPUTE_UNUSED(info);
241 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
Pablo Tello8f43d742019-03-27 09:28:32 +0000242 const size_t fst = window.x().start();
243 const size_t lst = window.x().end();
244 _transform->set_weight_tensor(_weights_hwio->buffer());
245 const int matrix_row_stride = roundup(_num_output_channels, WinogradConv::N_BLOCK);
246 _transform->set_output_matrices(_output->buffer(), _matrix_stride, matrix_row_stride);
247 _transform->set_working_space(_output->buffer());
Pablo Tello7df27862018-05-30 11:44:26 +0100248
Pablo Tello8f43d742019-03-27 09:28:32 +0000249 _transform->run(fst, lst);
Pablo Tellod6ca4782018-01-23 09:36:04 +0000250}
251
Pablo Tellof6c572c2018-02-14 12:47:30 +0000252template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
253bool NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::is_parallelisable() const
Pablo Tellod6ca4782018-01-23 09:36:04 +0000254{
255 return false;
256}
257
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100258template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100259Status NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::validate(const ITensorInfo *input, const ITensorInfo *output,
260 const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100261{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100262 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_winograd_weight_trans(input, output, winograd_info));
263 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_winograd_weight_trans(input->clone().get(), output->clone().get(), winograd_info).first);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100264 return Status{};
265}
266
Pablo Tellof6c572c2018-02-14 12:47:30 +0000267template class NEWinogradLayerTransformWeightsKernel<float, 2, 2, 3, 3>;
Vidhya Sudhan Loganathancb0010b2018-05-11 16:23:53 +0100268template class NEWinogradLayerTransformWeightsKernel<float, 4, 4, 3, 3>;
Pablo Tellof6c572c2018-02-14 12:47:30 +0000269template class NEWinogradLayerTransformWeightsKernel<float, 2, 2, 5, 5>;
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100270template class NEWinogradLayerTransformWeightsKernel<float, 1, 6, 1, 3>;
271template class NEWinogradLayerTransformWeightsKernel<float, 6, 1, 3, 1>;
Pablo Tello52140b42018-01-30 14:48:11 +0000272
Pablo Tello000d33a2018-09-03 16:59:20 +0100273template class NEWinogradLayerTransformWeightsKernel<float, 1, 4, 1, 5>;
274template class NEWinogradLayerTransformWeightsKernel<float, 4, 1, 5, 1>;
275template class NEWinogradLayerTransformWeightsKernel<float, 1, 2, 1, 7>;
276template class NEWinogradLayerTransformWeightsKernel<float, 2, 1, 7, 1>;
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100277
278#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
279template class NEWinogradLayerTransformWeightsKernel<__fp16, 4, 4, 3, 3>;
280#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
281
Pablo Tellod6ca4782018-01-23 09:36:04 +0000282// Input transform
283
Pablo Tellof6c572c2018-02-14 12:47:30 +0000284template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
285unsigned int NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_input_storage_size(
Pablo Tello7df27862018-05-30 11:44:26 +0100286 int num_batches, /* Number of batches in the input tensor. */
287 int num_channels, /* Number of feature maps in the input tensor. */
288 int num_rows, /* Number of rows in each feature map. */
289 int num_cols, /* Number of columns in each feature map. */
290 bool same_padding /* Use "SAME" padding, otherwise use "VALID". */
Pablo Tellof6c572c2018-02-14 12:47:30 +0000291) const
Pablo Tellod6ca4782018-01-23 09:36:04 +0000292{
Pablo Tello52140b42018-01-30 14:48:11 +0000293 // Construct shapes for the input and kernel tensors.
Pablo Tello7df27862018-05-30 11:44:26 +0100294 const Tensor4DShape input_shape(num_batches, num_rows, num_cols, num_channels);
295 const KernelShape kern_shape(1, KernelRows, KernelCols, num_channels);
Pablo Tello52140b42018-01-30 14:48:11 +0000296 // Return the size, converted into units of TIn
Pablo Tello5264b7d2019-10-21 14:25:41 +0100297 return static_cast<unsigned int>(WinogradConv::get_input_storage_size(num_batches, num_rows, num_cols, num_channels, same_padding) / sizeof(T));
Pablo Tello52140b42018-01-30 14:48:11 +0000298}
299
Pablo Tellof6c572c2018-02-14 12:47:30 +0000300template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello8f43d742019-03-27 09:28:32 +0000301unsigned int NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_working_space_size(unsigned int num_threads) const
302{
303 return _transform->get_working_space_size(num_threads) / sizeof(T);
304}
305
306template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tellof6c572c2018-02-14 12:47:30 +0000307int NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_matrix_stride(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100308 int num_batches, /* Number of batches in the input tensor. */
309 int num_channels, /* Number of feature maps in the input tensor. */
310 int num_rows, /* Number of rows in each feature map. */
311 int num_cols, /* Number of columns in each feature map. */
312 bool same_padding /* Use "SAME" padding, otherwise use "VALID". */) const
Pablo Tellof6c572c2018-02-14 12:47:30 +0000313{
Pablo Tello5264b7d2019-10-21 14:25:41 +0100314 return WinogradConv::get_input_matrix_stride(num_batches, num_rows, num_cols, num_channels, same_padding);
Pablo Tellof6c572c2018-02-14 12:47:30 +0000315}
316
317template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
318NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::NEWinogradLayerTransformInputKernel()
Pablo Tello8f43d742019-03-27 09:28:32 +0000319 : _transform(nullptr), _input_nhwc(nullptr), _num_batches(0), _num_rows(0), _num_cols(0), _num_channels(0), _padding(), _output(nullptr), _matrix_stride(0), _padding_top(), _padding_left(),
320 _padding_right(), _padding_bottom(), _workspace(nullptr)
Pablo Tello52140b42018-01-30 14:48:11 +0000321{
322}
323
Pablo Tellof6c572c2018-02-14 12:47:30 +0000324template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
325void NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::configure(
Pablo Tello7df27862018-05-30 11:44:26 +0100326 const ITensor *input_nhwc,
327 const int num_batches, /* Number of batches in input tensor. */
328 const int num_rows, /* Number of rows in input tensor. */
329 const int num_cols, /* Number of columns in input tensor. */
330 const int num_channels, /* Number of channels in input tensor. */
331 const PaddingType padding, /* Padding type. */
Anthony Barbiere1553372018-07-16 18:53:52 +0100332 ITensor *output, /* Base of output matrices. */
Pablo Tello8f43d742019-03-27 09:28:32 +0000333 const int matrix_stride, /* Stride between output matrices. */
334 ITensor *workspace)
Pablo Tello52140b42018-01-30 14:48:11 +0000335{
Pablo Tello7df27862018-05-30 11:44:26 +0100336 _input_nhwc = input_nhwc;
337 _num_batches = num_batches;
338 _num_rows = num_rows;
339 _num_cols = num_cols;
340 _num_channels = num_channels;
341 _padding = padding;
342 _output = output;
343 _matrix_stride = matrix_stride;
Pablo Tello8f43d742019-03-27 09:28:32 +0000344 _workspace = workspace;
345
346 _padding_top = (padding == PADDING_SAME) ? (KernelRows - 1) / 2 : 0;
347 _padding_left = (padding == PADDING_SAME) ? (KernelCols - 1) / 2 : 0;
348 _padding_bottom = (padding == PADDING_SAME) ? iceildiv(KernelRows - 1, 2) : 0;
349 _padding_right = (padding == PADDING_SAME) ? iceildiv(KernelCols - 1, 2) : 0;
350
351 _transform = arm_compute::support::cpp14::make_unique<InputTransform>(
352 KernelRows,
353 KernelCols,
354 num_batches,
355 num_rows,
356 num_cols,
357 num_channels,
358 _padding_top, /**< Padding to apply to the top of the image. */
359 _padding_left, /**< Padding to apply to the left of the image. */
360 _padding_bottom, /**< Padding to apply to the bottom of the image. */
361 _padding_right /**< Padding to apply to the right of the image. */
362 );
363
364 Window win;
365 auto win_last = _transform->get_window();
Pablo Tellod6ca4782018-01-23 09:36:04 +0000366 win.set(Window::DimX, Window::Dimension(0, win_last, 1));
367 INEKernel::configure(win);
368}
369
Pablo Tellof6c572c2018-02-14 12:47:30 +0000370template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
371void NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::run(const Window &window, const ThreadInfo &info)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000372{
373 ARM_COMPUTE_UNUSED(info);
374 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
Pablo Tello8f43d742019-03-27 09:28:32 +0000375 ARM_COMPUTE_ERROR_ON_NULLPTR(_workspace);
Pablo Tello7df27862018-05-30 11:44:26 +0100376
Pablo Tello8f43d742019-03-27 09:28:32 +0000377 const int element_size_in_bytes = _input_nhwc->info()->element_size();
378 const int input_col_stride = _input_nhwc->info()->strides_in_bytes().y() / element_size_in_bytes;
379 const int input_row_stride = _input_nhwc->info()->strides_in_bytes().z() / element_size_in_bytes;
380 const int input_batch_stride = _input_nhwc->info()->strides_in_bytes()[3] / element_size_in_bytes;
381 const auto input_nhwc_ptr = reinterpret_cast<const T *>(_input_nhwc->buffer() + _input_nhwc->info()->offset_first_element_in_bytes());
382 auto output_ptr = reinterpret_cast<T *>(_output->buffer() + _output->info()->offset_first_element_in_bytes());
383 ARM_COMPUTE_ERROR_ON_NULLPTR(output_ptr);
384
385 _transform->set_input_tensor(input_nhwc_ptr, input_batch_stride, input_row_stride, input_col_stride);
386 _transform->set_output_matrices(output_ptr, _matrix_stride, _num_channels);
387
388 _transform->set_working_space(_workspace->buffer());
Pablo Tello7df27862018-05-30 11:44:26 +0100389
390 // The code below cannot be moved to configure because biases hasn't been allocated at that point
Pablo Tellod6ca4782018-01-23 09:36:04 +0000391 const size_t fst = window.x().start();
392 const size_t lst = window.x().end();
Pablo Tello8f43d742019-03-27 09:28:32 +0000393 _transform->run(fst, lst, info.thread_id);
Pablo Tellod6ca4782018-01-23 09:36:04 +0000394}
Pablo Tello52140b42018-01-30 14:48:11 +0000395
Pablo Tellof6c572c2018-02-14 12:47:30 +0000396template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100397Status NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::validate(const ITensorInfo *input, const ITensorInfo *output, const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100398{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100399 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_winograd_input_trans(input, output, winograd_info));
400 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_winograd_input_trans(input->clone().get(), output->clone().get(), winograd_info).first);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100401
402 return Status{};
403}
404
Pablo Tellof6c572c2018-02-14 12:47:30 +0000405template class NEWinogradLayerTransformInputKernel<float, 2, 2, 3, 3>;
Vidhya Sudhan Loganathancb0010b2018-05-11 16:23:53 +0100406template class NEWinogradLayerTransformInputKernel<float, 4, 4, 3, 3>;
Pablo Tellof6c572c2018-02-14 12:47:30 +0000407template class NEWinogradLayerTransformInputKernel<float, 2, 2, 5, 5>;
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100408template class NEWinogradLayerTransformInputKernel<float, 1, 6, 1, 3>;
409template class NEWinogradLayerTransformInputKernel<float, 6, 1, 3, 1>;
Pablo Tello52140b42018-01-30 14:48:11 +0000410
Pablo Tello000d33a2018-09-03 16:59:20 +0100411template class NEWinogradLayerTransformInputKernel<float, 1, 4, 1, 5>;
412template class NEWinogradLayerTransformInputKernel<float, 4, 1, 5, 1>;
413template class NEWinogradLayerTransformInputKernel<float, 1, 2, 1, 7>;
414template class NEWinogradLayerTransformInputKernel<float, 2, 1, 7, 1>;
415
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100416#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
417template class NEWinogradLayerTransformInputKernel<__fp16, 4, 4, 3, 3>;
418#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
419
Pablo Tellod6ca4782018-01-23 09:36:04 +0000420// Output transform
Pablo Tello52140b42018-01-30 14:48:11 +0000421
Pablo Tellof6c572c2018-02-14 12:47:30 +0000422template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
423unsigned int NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_output_storage_size(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100424 int num_batches, /* Number of batches in the output tensor. */
425 int num_rows, /* Number of rows in each feature map of the input tensor. */
426 int num_cols, /* Number of columns in each feature map of the input tensor. */
427 int num_output_channels /* Number of feature maps in the output tensor. */
Pablo Tellof6c572c2018-02-14 12:47:30 +0000428) const
Pablo Tello52140b42018-01-30 14:48:11 +0000429{
430 // Construct shapes for the input and kernel tensors.
Pablo Tello7df27862018-05-30 11:44:26 +0100431 const Tensor4DShape input_shape(num_batches, num_rows, num_cols, 1);
432 const KernelShape kern_shape(num_output_channels, KernelRows, KernelCols, 1);
Pablo Tello52140b42018-01-30 14:48:11 +0000433 // Return the size, converted into units of TOut
434 return static_cast<unsigned int>(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100435 WinogradConv::get_output_storage_size(num_batches, num_rows, num_cols, num_output_channels) / sizeof(T));
Pablo Tello52140b42018-01-30 14:48:11 +0000436}
437
Pablo Tellof6c572c2018-02-14 12:47:30 +0000438template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
439NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::NEWinogradLayerTransformOutputKernel()
Pablo Tello8f43d742019-03-27 09:28:32 +0000440 : _transform(nullptr), _biases(nullptr), _transformed_output(nullptr), _workspace(nullptr), _matrix_stride(0), _matrix_row_stride(0), _output_nhwc(nullptr), _num_batches(0), _num_rows(0),
441 _num_cols(0), _num_channels(0)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000442{
443}
444
Pablo Tellof6c572c2018-02-14 12:47:30 +0000445template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello8f43d742019-03-27 09:28:32 +0000446unsigned int NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_working_space_size(unsigned int num_threads) const
447{
448 return _transform->get_working_space_size(num_threads) / sizeof(T);
449}
450
451template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tellof6c572c2018-02-14 12:47:30 +0000452int NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_matrix_stride(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100453 int num_batches, /* Number of batches in the output tensor. */
454 int num_rows, /* Number of rows in each feature map of the input tensor. */
455 int num_cols, /* Number of columns in each feature map of the input tensor. */
456 int num_output_channels /* Number of feature maps in the output tensor. */
457) const
Pablo Tellof6c572c2018-02-14 12:47:30 +0000458{
Pablo Tello5264b7d2019-10-21 14:25:41 +0100459 return WinogradConv::get_output_matrix_stride(num_batches, num_rows, num_cols, num_output_channels);
Pablo Tellof6c572c2018-02-14 12:47:30 +0000460}
Pablo Tello5264b7d2019-10-21 14:25:41 +0100461
Pablo Tellof6c572c2018-02-14 12:47:30 +0000462template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello5264b7d2019-10-21 14:25:41 +0100463std::pair<unsigned int, unsigned int> NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_output_shape(
464 int num_rows, /* Number of rows in each feature map of the input tensor. */
465 int num_cols, /* Number of columns in each feature map of the input tensor. */
466 bool padding_same) const
Pablo Tellof6c572c2018-02-14 12:47:30 +0000467{
Pablo Tello5264b7d2019-10-21 14:25:41 +0100468 return WinogradConv::get_output_shape(std::make_pair<unsigned int, unsigned int>(num_rows, num_cols), padding_same);
Pablo Tellof6c572c2018-02-14 12:47:30 +0000469}
470
471template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
472void NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::configure(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100473 const ITensor *biases,
474 const ITensor *transformed_output,
475 const int matrix_stride,
476 ITensor *output_nhwc,
477 const int num_batches,
478 const int num_rows,
479 const int num_cols,
480 const int num_channels,
481 ITensor *workspace,
482 const arm_gemm::Activation &activation)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000483{
Pablo Tello8f43d742019-03-27 09:28:32 +0000484 _biases = biases;
485 _workspace = workspace;
486 _transformed_output = transformed_output;
487 _matrix_stride = matrix_stride;
488 _matrix_row_stride = roundup(num_channels, WinogradConv::N_BLOCK);
489 _output_nhwc = output_nhwc;
490 _num_batches = num_batches;
491 _num_rows = num_rows;
492 _num_cols = num_cols;
493 _num_channels = num_channels;
Pablo Tellod6ca4782018-01-23 09:36:04 +0000494 // We don't have the biases buffer at this stage as it hasn't been allocated, we pass in nullptr OutputTransform is only used here to compute the window
Pablo Tello5264b7d2019-10-21 14:25:41 +0100495 _transform = arm_compute::support::cpp14::make_unique<OutputTransform>(num_batches, num_rows, num_cols, num_channels, activation);
Pablo Tello7282d562018-06-14 15:35:49 +0100496 Window win;
Pablo Tello8f43d742019-03-27 09:28:32 +0000497 auto win_last = _transform->get_window();
Pablo Tellod6ca4782018-01-23 09:36:04 +0000498 win.set(Window::DimX, Window::Dimension(0, win_last, 1));
Pablo Tello7282d562018-06-14 15:35:49 +0100499 _output_nhwc->info()->set_valid_region(ValidRegion(Coordinates(), _output_nhwc->info()->tensor_shape()));
500
Pablo Tellod6ca4782018-01-23 09:36:04 +0000501 INEKernel::configure(win);
502}
503
Pablo Tellof6c572c2018-02-14 12:47:30 +0000504template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
505void NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::run(const Window &window, const ThreadInfo &info)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000506{
507 ARM_COMPUTE_UNUSED(info);
508 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
Pablo Tello8f43d742019-03-27 09:28:32 +0000509 ARM_COMPUTE_ERROR_ON_NULLPTR(_workspace);
510 ARM_COMPUTE_ERROR_ON_NULLPTR(_transformed_output);
Pablo Tello7df27862018-05-30 11:44:26 +0100511 ARM_COMPUTE_ERROR_ON_NULLPTR(_output_nhwc);
Pablo Tellod6ca4782018-01-23 09:36:04 +0000512
Pablo Tello8f43d742019-03-27 09:28:32 +0000513 const int out_batch_stride = _output_nhwc->info()->strides_in_bytes()[3] / sizeof(T);
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100514 const int out_row_stride = _output_nhwc->info()->strides_in_bytes()[2] / sizeof(T);
515 const int out_col_stride = _output_nhwc->info()->strides_in_bytes()[1] / sizeof(T);
516
Pablo Tello8f43d742019-03-27 09:28:32 +0000517 _transform->set_input_matrices(_transformed_output->buffer(), _matrix_stride, _matrix_row_stride);
518 _transform->set_bias((_biases ? reinterpret_cast<T *>(_biases->buffer() + _biases->info()->offset_first_element_in_bytes()) : nullptr));
519 _transform->set_output_tensor(_output_nhwc->buffer() + _output_nhwc->info()->offset_first_element_in_bytes(), out_batch_stride, out_row_stride, out_col_stride);
520 _transform->set_working_space(_workspace->buffer());
Pablo Tellod6ca4782018-01-23 09:36:04 +0000521 // The code below cannot be moved to configure because biases hasn't been allocated at that point
522 const size_t fst = window.x().start();
523 const size_t lst = window.x().end();
Pablo Tello8f43d742019-03-27 09:28:32 +0000524 _transform->run(fst, lst, info.thread_id);
Pablo Tellod6ca4782018-01-23 09:36:04 +0000525}
526
Pablo Tellof6c572c2018-02-14 12:47:30 +0000527template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100528Status NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output,
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100529 const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100530{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100531 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_winograd_output_trans(input, (bias != nullptr ? bias->clone().get() : nullptr), output, winograd_info));
morgolockc6d9a8b2019-12-23 10:45:59 +0000532 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_winograd_output_trans(input->clone().get(), output->clone().get(), winograd_info).first);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100533
534 return Status{};
535}
536
Pablo Tellof6c572c2018-02-14 12:47:30 +0000537template class NEWinogradLayerTransformOutputKernel<float, 2, 2, 3, 3>;
Vidhya Sudhan Loganathancb0010b2018-05-11 16:23:53 +0100538template class NEWinogradLayerTransformOutputKernel<float, 4, 4, 3, 3>;
Pablo Tellof6c572c2018-02-14 12:47:30 +0000539template class NEWinogradLayerTransformOutputKernel<float, 2, 2, 5, 5>;
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100540template class NEWinogradLayerTransformOutputKernel<float, 1, 6, 1, 3>;
541template class NEWinogradLayerTransformOutputKernel<float, 6, 1, 3, 1>;
Pablo Tello52140b42018-01-30 14:48:11 +0000542
Pablo Tello000d33a2018-09-03 16:59:20 +0100543template class NEWinogradLayerTransformOutputKernel<float, 1, 4, 1, 5>;
544template class NEWinogradLayerTransformOutputKernel<float, 4, 1, 5, 1>;
545template class NEWinogradLayerTransformOutputKernel<float, 1, 2, 1, 7>;
546template class NEWinogradLayerTransformOutputKernel<float, 2, 1, 7, 1>;
547
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100548#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
549template class NEWinogradLayerTransformOutputKernel<__fp16, 4, 4, 3, 3>;
550#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Pablo Tello89519332017-11-17 11:52:36 +0000551} // namespace arm_compute