blob: bfe97bfbdb85f5d9ff70e7db7f8cc2ccfdbf6a9b [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
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010026#include "arm_compute/core/AccessWindowStatic.h"
Pablo Tello89519332017-11-17 11:52:36 +000027#include "arm_compute/core/Error.h"
28#include "arm_compute/core/Helpers.h"
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010029#include "arm_compute/core/IAccessWindow.h"
Pablo Tello89519332017-11-17 11:52:36 +000030#include "arm_compute/core/ITensor.h"
Pablo Tello5264b7d2019-10-21 14:25:41 +010031#include "arm_compute/core/NEON/kernels/convolution/common/utils.hpp"
Pablo Tello89519332017-11-17 11:52:36 +000032#include "arm_compute/core/TensorInfo.h"
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010033#include "arm_compute/core/Validate.h"
34#include "arm_compute/core/Window.h"
35#include "arm_compute/core/utils/misc/ShapeCalculator.h"
Matthew Bentham92046462020-03-07 22:15:55 +000036#include "support/MemorySupport.h"
Pablo Tello3d4968a2017-12-04 15:03:35 +000037
Michele Di Giorgio6ad60af2020-06-09 14:52:15 +010038#include "src/core/NEON/kernels/convolution/winograd/winograd_layer.hpp"
39
Pablo Tello89519332017-11-17 11:52:36 +000040namespace arm_compute
41{
Pablo Tello52140b42018-01-30 14:48:11 +000042//Batched Gemms
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010043
44namespace
45{
Georgios Pinitas5ce897f2020-04-29 11:44:10 +010046inline bool is_kernel_size_supported(DataType data_type, Size2D size)
Pablo Tellobda6e4b2018-08-22 11:40:33 +010047{
Georgios Pinitas5ce897f2020-04-29 11:44:10 +010048 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) } };
49 const std::array<Size2D, 8> f16_support = { { Size2D(3, 3) } };
50
51 switch(data_type)
52 {
53 case DataType::F16:
54 return std::end(f16_support) != std::find(std::begin(f16_support), std::end(f16_support), size);
55 case DataType::F32:
56 return std::end(f32_support) != std::find(std::begin(f32_support), std::end(f32_support), size);
57 default:
58 return false;
59 }
Pablo Tellobda6e4b2018-08-22 11:40:33 +010060}
61
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010062Status validate_arguments_winograd_weight_trans(const ITensorInfo *input, const ITensorInfo *output, const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010063{
64 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input);
65 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +010066 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010067
Pablo Tellobda6e4b2018-08-22 11:40:33 +010068 const size_t idx_width = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::WIDTH);
69 const size_t idx_height = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::HEIGHT);
70 const auto input_width = input->dimension(idx_width);
71 const auto input_height = input->dimension(idx_height);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +010072 ARM_COMPUTE_RETURN_ERROR_ON_MSG(!is_kernel_size_supported(input->data_type(), Size2D(input_width, input_height)),
73 "Only 1x3, 3x1, 1x5, 5x1, 7x1, 1x7, 3x3 and 5x5 kernels are supported");
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010074 ARM_COMPUTE_RETURN_ERROR_ON(input->num_dimensions() > 4);
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010075 const Size2D &output_tile = winograd_info.output_tile_size;
Pablo Tello000d33a2018-09-03 16:59:20 +010076 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 +010077 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 +010078
79 // Checks performed when output is configured
80 if(output->total_size() != 0)
81 {
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010082 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 +010083
84 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(output, &tensor_info_output);
85 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
86 }
87
88 return Status{};
89}
90
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010091std::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 +010092{
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010093 // Output tensor auto inizialitation if not yet initialized
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010094 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 +000095 const Window win = calculate_max_window(*input, Steps(), true /* skip border*/);
96 return std::make_pair(Status{}, win);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +010097}
98
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +010099Status validate_arguments_winograd_input_trans(const ITensorInfo *input, const ITensorInfo *output, const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100100{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100101 const Size2D &kernel_dims = winograd_info.kernel_size;
102 const PadStrideInfo &conv_info = winograd_info.convolution_info;
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100103 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input);
104 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100105 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100106 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 +0100107 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 +0100108 "Only 1x3, 3x1, 3x3 and 5x5 kernels are supported");
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100109
110 // Validate configured output
111 if(output->total_size() != 0)
112 {
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100113 const TensorShape output_shape = misc::shape_calculator::compute_winograd_input_transform_shape(*input, winograd_info);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100114
115 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), output_shape);
116 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
117 }
118
119 return Status{};
120}
121
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100122std::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 +0100123{
morgolockc6d9a8b2019-12-23 10:45:59 +0000124 const TensorShape output_shape = misc::shape_calculator::compute_winograd_input_transform_shape(*input, winograd_info);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100125 // Output auto inizialitation if not yet initialized
126 auto_init_if_empty(*output, input->clone()->set_tensor_shape(output_shape));
morgolockc6d9a8b2019-12-23 10:45:59 +0000127 return std::make_pair(Status{}, calculate_max_window(*input, Steps(), true));
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100128}
129
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100130Status 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 +0100131{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100132 const PadStrideInfo &conv_info = winograd_info.convolution_info;
133 const Size2D kernel_dims = winograd_info.kernel_size;
134
135 // Number of tiles along the X and Y direction
Vidhya Sudhan Loganathancb0010b2018-05-11 16:23:53 +0100136 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>
137 (winograd_info.output_tile_size.width));
138 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>
139 (winograd_info.output_tile_size.height));
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100140 const Size2D num_tiles = Size2D(num_tiles_x, num_tiles_y);
141
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100142 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input);
143 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100144 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100145 ARM_COMPUTE_RETURN_ERROR_ON(input->dimension(1) != num_tiles.area());
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100146 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 +0100147 "Only 1x3, 3x1, 3x3 and 5x5 kernels are supported");
148
149 const std::array<unsigned int, 3> supported_gemm_sizes = { { 8U, 16U, 36U } };
150 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 +0100151 ARM_COMPUTE_UNUSED(kernel_dims);
152 if(bias != nullptr)
153 {
154 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, bias);
155 ARM_COMPUTE_RETURN_ERROR_ON(input->dimension(0) != bias->dimension(0));
156 ARM_COMPUTE_RETURN_ERROR_ON(bias->num_dimensions() != size_t(1));
157 }
158
159 // Checks performed when output is configured
160 if(output->total_size() != 0)
161 {
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100162 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 +0100163 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(output, &tensor_info_output);
164 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
165 }
166 return Status{};
167}
168
morgolockc6d9a8b2019-12-23 10:45:59 +0000169std::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 +0100170{
171 // Output tensor auto initialization if not yet initialized
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100172 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 +0100173
morgolockc6d9a8b2019-12-23 10:45:59 +0000174 return std::make_pair(Status{}, calculate_max_window(*input, Steps(), true));
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100175}
176} // namespace
Pablo Tellod6ca4782018-01-23 09:36:04 +0000177
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100178Status INEWinogradLayerTransformWeightsKernel::validate(const ITensorInfo *input, const ITensorInfo *weights)
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100179{
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100180 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100181 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, weights);
182 const DataLayout data_layout = input->data_layout();
183 const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
184 const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100185 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 +0100186 "Only 1x3, 3x1, 3x3 and 5x5 kernels are supported");
187 ARM_COMPUTE_RETURN_ERROR_ON(weights->num_dimensions() > 4);
188 return Status{};
189}
190
Pablo Tellof6c572c2018-02-14 12:47:30 +0000191template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello7df27862018-05-30 11:44:26 +0100192unsigned 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 +0000193{
Pablo Tello7df27862018-05-30 11:44:26 +0100194 const KernelShape shape(num_output_channels, KernelRows, KernelCols, num_input_channels);
Pablo Tello52140b42018-01-30 14:48:11 +0000195 return static_cast<unsigned int>(
Pablo Tellof6c572c2018-02-14 12:47:30 +0000196 // 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 +0100197 WinogradConv::get_kernel_storage_size(num_input_channels, num_output_channels) / sizeof(T));
Pablo Tello52140b42018-01-30 14:48:11 +0000198}
199
Pablo Tellof6c572c2018-02-14 12:47:30 +0000200template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
201NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::NEWinogradLayerTransformWeightsKernel()
Pablo Tello8f43d742019-03-27 09:28:32 +0000202 : _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 +0000203{
204}
205
Pablo Tellof6c572c2018-02-14 12:47:30 +0000206template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello5264b7d2019-10-21 14:25:41 +0100207int 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 +0000208{
Pablo Tello5264b7d2019-10-21 14:25:41 +0100209 return WinogradConv::get_kernel_matrix_stride(num_input_channels, num_output_channels);
Pablo Tellof6c572c2018-02-14 12:47:30 +0000210}
211
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000212#ifndef DOXYGEN_SKIP_THIS
Pablo Tellof6c572c2018-02-14 12:47:30 +0000213template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
214void NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::configure(
Pablo Tello52140b42018-01-30 14:48:11 +0000215 const ITensor *weights_hwio,
Anthony Barbiere1553372018-07-16 18:53:52 +0100216 ITensor *output,
Pablo Tello7df27862018-05-30 11:44:26 +0100217 const int matrix_stride, /** Stride across matrices in the output. */
218 const int num_output_channels, /** Number of filters. */
219 const int num_input_channels) /** Number of channels in each filter. */
Pablo Tello52140b42018-01-30 14:48:11 +0000220{
Pablo Tello7df27862018-05-30 11:44:26 +0100221 _weights_hwio = weights_hwio;
222 _output = output;
223 _matrix_stride = matrix_stride;
224 _num_output_channels = num_output_channels;
225 _num_input_channels = num_input_channels;
Pablo Tello8f43d742019-03-27 09:28:32 +0000226 _transform = arm_compute::support::cpp14::make_unique<WeightsTransform>(num_output_channels, num_input_channels);
Pablo Tello7df27862018-05-30 11:44:26 +0100227
Pablo Tello8f43d742019-03-27 09:28:32 +0000228 Window win;
229 auto win_last = _transform->get_window();
Pablo Tellod6ca4782018-01-23 09:36:04 +0000230 win.set(Window::DimX, Window::Dimension(0, win_last, 1));
231 INEKernel::configure(win);
232}
Vidhya Sudhan Loganathand646ae12018-11-19 15:18:20 +0000233#endif /* DOXYGEN_SKIP_THIS */
Pablo Tellod6ca4782018-01-23 09:36:04 +0000234
Pablo Tellof6c572c2018-02-14 12:47:30 +0000235template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
236void NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::run(const Window &window, const ThreadInfo &info)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000237{
238 ARM_COMPUTE_UNUSED(info);
239 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
Pablo Tello8f43d742019-03-27 09:28:32 +0000240 const size_t fst = window.x().start();
241 const size_t lst = window.x().end();
242 _transform->set_weight_tensor(_weights_hwio->buffer());
243 const int matrix_row_stride = roundup(_num_output_channels, WinogradConv::N_BLOCK);
244 _transform->set_output_matrices(_output->buffer(), _matrix_stride, matrix_row_stride);
245 _transform->set_working_space(_output->buffer());
Pablo Tello7df27862018-05-30 11:44:26 +0100246
Pablo Tello8f43d742019-03-27 09:28:32 +0000247 _transform->run(fst, lst);
Pablo Tellod6ca4782018-01-23 09:36:04 +0000248}
249
Pablo Tellof6c572c2018-02-14 12:47:30 +0000250template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
251bool NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::is_parallelisable() const
Pablo Tellod6ca4782018-01-23 09:36:04 +0000252{
253 return false;
254}
255
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100256template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100257Status NEWinogradLayerTransformWeightsKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::validate(const ITensorInfo *input, const ITensorInfo *output,
258 const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100259{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100260 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_winograd_weight_trans(input, output, winograd_info));
261 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 +0100262 return Status{};
263}
264
Pablo Tellof6c572c2018-02-14 12:47:30 +0000265template class NEWinogradLayerTransformWeightsKernel<float, 2, 2, 3, 3>;
Vidhya Sudhan Loganathancb0010b2018-05-11 16:23:53 +0100266template class NEWinogradLayerTransformWeightsKernel<float, 4, 4, 3, 3>;
Pablo Tellof6c572c2018-02-14 12:47:30 +0000267template class NEWinogradLayerTransformWeightsKernel<float, 2, 2, 5, 5>;
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100268template class NEWinogradLayerTransformWeightsKernel<float, 1, 6, 1, 3>;
269template class NEWinogradLayerTransformWeightsKernel<float, 6, 1, 3, 1>;
Pablo Tello52140b42018-01-30 14:48:11 +0000270
Pablo Tello000d33a2018-09-03 16:59:20 +0100271template class NEWinogradLayerTransformWeightsKernel<float, 1, 4, 1, 5>;
272template class NEWinogradLayerTransformWeightsKernel<float, 4, 1, 5, 1>;
273template class NEWinogradLayerTransformWeightsKernel<float, 1, 2, 1, 7>;
274template class NEWinogradLayerTransformWeightsKernel<float, 2, 1, 7, 1>;
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100275
276#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
277template class NEWinogradLayerTransformWeightsKernel<__fp16, 4, 4, 3, 3>;
278#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
279
Pablo Tellod6ca4782018-01-23 09:36:04 +0000280// Input transform
281
Pablo Tellof6c572c2018-02-14 12:47:30 +0000282template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
283unsigned int NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_input_storage_size(
Pablo Tello7df27862018-05-30 11:44:26 +0100284 int num_batches, /* Number of batches in the input tensor. */
285 int num_channels, /* Number of feature maps in the input tensor. */
286 int num_rows, /* Number of rows in each feature map. */
287 int num_cols, /* Number of columns in each feature map. */
288 bool same_padding /* Use "SAME" padding, otherwise use "VALID". */
Pablo Tellof6c572c2018-02-14 12:47:30 +0000289) const
Pablo Tellod6ca4782018-01-23 09:36:04 +0000290{
Pablo Tello52140b42018-01-30 14:48:11 +0000291 // Construct shapes for the input and kernel tensors.
Pablo Tello7df27862018-05-30 11:44:26 +0100292 const Tensor4DShape input_shape(num_batches, num_rows, num_cols, num_channels);
293 const KernelShape kern_shape(1, KernelRows, KernelCols, num_channels);
Pablo Tello52140b42018-01-30 14:48:11 +0000294 // Return the size, converted into units of TIn
Pablo Tello5264b7d2019-10-21 14:25:41 +0100295 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 +0000296}
297
Pablo Tellof6c572c2018-02-14 12:47:30 +0000298template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello8f43d742019-03-27 09:28:32 +0000299unsigned int NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_working_space_size(unsigned int num_threads) const
300{
301 return _transform->get_working_space_size(num_threads) / sizeof(T);
302}
303
304template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tellof6c572c2018-02-14 12:47:30 +0000305int NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_matrix_stride(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100306 int num_batches, /* Number of batches in the input tensor. */
307 int num_channels, /* Number of feature maps in the input tensor. */
308 int num_rows, /* Number of rows in each feature map. */
309 int num_cols, /* Number of columns in each feature map. */
310 bool same_padding /* Use "SAME" padding, otherwise use "VALID". */) const
Pablo Tellof6c572c2018-02-14 12:47:30 +0000311{
Pablo Tello5264b7d2019-10-21 14:25:41 +0100312 return WinogradConv::get_input_matrix_stride(num_batches, num_rows, num_cols, num_channels, same_padding);
Pablo Tellof6c572c2018-02-14 12:47:30 +0000313}
314
315template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
316NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::NEWinogradLayerTransformInputKernel()
Pablo Tello8f43d742019-03-27 09:28:32 +0000317 : _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(),
318 _padding_right(), _padding_bottom(), _workspace(nullptr)
Pablo Tello52140b42018-01-30 14:48:11 +0000319{
320}
321
Pablo Tellof6c572c2018-02-14 12:47:30 +0000322template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
323void NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::configure(
Pablo Tello7df27862018-05-30 11:44:26 +0100324 const ITensor *input_nhwc,
325 const int num_batches, /* Number of batches in input tensor. */
326 const int num_rows, /* Number of rows in input tensor. */
327 const int num_cols, /* Number of columns in input tensor. */
328 const int num_channels, /* Number of channels in input tensor. */
329 const PaddingType padding, /* Padding type. */
Anthony Barbiere1553372018-07-16 18:53:52 +0100330 ITensor *output, /* Base of output matrices. */
Pablo Tello8f43d742019-03-27 09:28:32 +0000331 const int matrix_stride, /* Stride between output matrices. */
332 ITensor *workspace)
Pablo Tello52140b42018-01-30 14:48:11 +0000333{
Pablo Tello7df27862018-05-30 11:44:26 +0100334 _input_nhwc = input_nhwc;
335 _num_batches = num_batches;
336 _num_rows = num_rows;
337 _num_cols = num_cols;
338 _num_channels = num_channels;
339 _padding = padding;
340 _output = output;
341 _matrix_stride = matrix_stride;
Pablo Tello8f43d742019-03-27 09:28:32 +0000342 _workspace = workspace;
343
344 _padding_top = (padding == PADDING_SAME) ? (KernelRows - 1) / 2 : 0;
345 _padding_left = (padding == PADDING_SAME) ? (KernelCols - 1) / 2 : 0;
346 _padding_bottom = (padding == PADDING_SAME) ? iceildiv(KernelRows - 1, 2) : 0;
347 _padding_right = (padding == PADDING_SAME) ? iceildiv(KernelCols - 1, 2) : 0;
348
349 _transform = arm_compute::support::cpp14::make_unique<InputTransform>(
350 KernelRows,
351 KernelCols,
352 num_batches,
353 num_rows,
354 num_cols,
355 num_channels,
356 _padding_top, /**< Padding to apply to the top of the image. */
357 _padding_left, /**< Padding to apply to the left of the image. */
358 _padding_bottom, /**< Padding to apply to the bottom of the image. */
359 _padding_right /**< Padding to apply to the right of the image. */
360 );
361
362 Window win;
363 auto win_last = _transform->get_window();
Pablo Tellod6ca4782018-01-23 09:36:04 +0000364 win.set(Window::DimX, Window::Dimension(0, win_last, 1));
365 INEKernel::configure(win);
366}
367
Pablo Tellof6c572c2018-02-14 12:47:30 +0000368template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
369void NEWinogradLayerTransformInputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::run(const Window &window, const ThreadInfo &info)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000370{
371 ARM_COMPUTE_UNUSED(info);
372 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
Pablo Tello8f43d742019-03-27 09:28:32 +0000373 ARM_COMPUTE_ERROR_ON_NULLPTR(_workspace);
Pablo Tello7df27862018-05-30 11:44:26 +0100374
Pablo Tello8f43d742019-03-27 09:28:32 +0000375 const int element_size_in_bytes = _input_nhwc->info()->element_size();
376 const int input_col_stride = _input_nhwc->info()->strides_in_bytes().y() / element_size_in_bytes;
377 const int input_row_stride = _input_nhwc->info()->strides_in_bytes().z() / element_size_in_bytes;
378 const int input_batch_stride = _input_nhwc->info()->strides_in_bytes()[3] / element_size_in_bytes;
379 const auto input_nhwc_ptr = reinterpret_cast<const T *>(_input_nhwc->buffer() + _input_nhwc->info()->offset_first_element_in_bytes());
380 auto output_ptr = reinterpret_cast<T *>(_output->buffer() + _output->info()->offset_first_element_in_bytes());
381 ARM_COMPUTE_ERROR_ON_NULLPTR(output_ptr);
382
383 _transform->set_input_tensor(input_nhwc_ptr, input_batch_stride, input_row_stride, input_col_stride);
384 _transform->set_output_matrices(output_ptr, _matrix_stride, _num_channels);
385
386 _transform->set_working_space(_workspace->buffer());
Pablo Tello7df27862018-05-30 11:44:26 +0100387
388 // The code below cannot be moved to configure because biases hasn't been allocated at that point
Pablo Tellod6ca4782018-01-23 09:36:04 +0000389 const size_t fst = window.x().start();
390 const size_t lst = window.x().end();
Pablo Tello8f43d742019-03-27 09:28:32 +0000391 _transform->run(fst, lst, info.thread_id);
Pablo Tellod6ca4782018-01-23 09:36:04 +0000392}
Pablo Tello52140b42018-01-30 14:48:11 +0000393
Pablo Tellof6c572c2018-02-14 12:47:30 +0000394template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100395Status 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 +0100396{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100397 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_winograd_input_trans(input, output, winograd_info));
398 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 +0100399
400 return Status{};
401}
402
Pablo Tellof6c572c2018-02-14 12:47:30 +0000403template class NEWinogradLayerTransformInputKernel<float, 2, 2, 3, 3>;
Vidhya Sudhan Loganathancb0010b2018-05-11 16:23:53 +0100404template class NEWinogradLayerTransformInputKernel<float, 4, 4, 3, 3>;
Pablo Tellof6c572c2018-02-14 12:47:30 +0000405template class NEWinogradLayerTransformInputKernel<float, 2, 2, 5, 5>;
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100406template class NEWinogradLayerTransformInputKernel<float, 1, 6, 1, 3>;
407template class NEWinogradLayerTransformInputKernel<float, 6, 1, 3, 1>;
Pablo Tello52140b42018-01-30 14:48:11 +0000408
Pablo Tello000d33a2018-09-03 16:59:20 +0100409template class NEWinogradLayerTransformInputKernel<float, 1, 4, 1, 5>;
410template class NEWinogradLayerTransformInputKernel<float, 4, 1, 5, 1>;
411template class NEWinogradLayerTransformInputKernel<float, 1, 2, 1, 7>;
412template class NEWinogradLayerTransformInputKernel<float, 2, 1, 7, 1>;
413
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100414#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
415template class NEWinogradLayerTransformInputKernel<__fp16, 4, 4, 3, 3>;
416#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
417
Pablo Tellod6ca4782018-01-23 09:36:04 +0000418// Output transform
Pablo Tello52140b42018-01-30 14:48:11 +0000419
Pablo Tellof6c572c2018-02-14 12:47:30 +0000420template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
421unsigned int NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_output_storage_size(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100422 int num_batches, /* Number of batches in the output tensor. */
423 int num_rows, /* Number of rows in each feature map of the input tensor. */
424 int num_cols, /* Number of columns in each feature map of the input tensor. */
425 int num_output_channels /* Number of feature maps in the output tensor. */
Pablo Tellof6c572c2018-02-14 12:47:30 +0000426) const
Pablo Tello52140b42018-01-30 14:48:11 +0000427{
428 // Construct shapes for the input and kernel tensors.
Pablo Tello7df27862018-05-30 11:44:26 +0100429 const Tensor4DShape input_shape(num_batches, num_rows, num_cols, 1);
430 const KernelShape kern_shape(num_output_channels, KernelRows, KernelCols, 1);
Pablo Tello52140b42018-01-30 14:48:11 +0000431 // Return the size, converted into units of TOut
432 return static_cast<unsigned int>(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100433 WinogradConv::get_output_storage_size(num_batches, num_rows, num_cols, num_output_channels) / sizeof(T));
Pablo Tello52140b42018-01-30 14:48:11 +0000434}
435
Pablo Tellof6c572c2018-02-14 12:47:30 +0000436template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
437NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::NEWinogradLayerTransformOutputKernel()
Pablo Tello8f43d742019-03-27 09:28:32 +0000438 : _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),
439 _num_cols(0), _num_channels(0)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000440{
441}
442
Pablo Tellof6c572c2018-02-14 12:47:30 +0000443template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello8f43d742019-03-27 09:28:32 +0000444unsigned int NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_working_space_size(unsigned int num_threads) const
445{
446 return _transform->get_working_space_size(num_threads) / sizeof(T);
447}
448
449template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tellof6c572c2018-02-14 12:47:30 +0000450int NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_matrix_stride(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100451 int num_batches, /* Number of batches in the output tensor. */
452 int num_rows, /* Number of rows in each feature map of the input tensor. */
453 int num_cols, /* Number of columns in each feature map of the input tensor. */
454 int num_output_channels /* Number of feature maps in the output tensor. */
455) const
Pablo Tellof6c572c2018-02-14 12:47:30 +0000456{
Pablo Tello5264b7d2019-10-21 14:25:41 +0100457 return WinogradConv::get_output_matrix_stride(num_batches, num_rows, num_cols, num_output_channels);
Pablo Tellof6c572c2018-02-14 12:47:30 +0000458}
Pablo Tello5264b7d2019-10-21 14:25:41 +0100459
Pablo Tellof6c572c2018-02-14 12:47:30 +0000460template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Pablo Tello5264b7d2019-10-21 14:25:41 +0100461std::pair<unsigned int, unsigned int> NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::get_output_shape(
462 int num_rows, /* Number of rows in each feature map of the input tensor. */
463 int num_cols, /* Number of columns in each feature map of the input tensor. */
464 bool padding_same) const
Pablo Tellof6c572c2018-02-14 12:47:30 +0000465{
Pablo Tello5264b7d2019-10-21 14:25:41 +0100466 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 +0000467}
468
469template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
470void NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::configure(
Pablo Tello5264b7d2019-10-21 14:25:41 +0100471 const ITensor *biases,
472 const ITensor *transformed_output,
473 const int matrix_stride,
474 ITensor *output_nhwc,
475 const int num_batches,
476 const int num_rows,
477 const int num_cols,
478 const int num_channels,
479 ITensor *workspace,
480 const arm_gemm::Activation &activation)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000481{
Pablo Tello8f43d742019-03-27 09:28:32 +0000482 _biases = biases;
483 _workspace = workspace;
484 _transformed_output = transformed_output;
485 _matrix_stride = matrix_stride;
486 _matrix_row_stride = roundup(num_channels, WinogradConv::N_BLOCK);
487 _output_nhwc = output_nhwc;
488 _num_batches = num_batches;
489 _num_rows = num_rows;
490 _num_cols = num_cols;
491 _num_channels = num_channels;
Pablo Tellod6ca4782018-01-23 09:36:04 +0000492 // 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 +0100493 _transform = arm_compute::support::cpp14::make_unique<OutputTransform>(num_batches, num_rows, num_cols, num_channels, activation);
Pablo Tello7282d562018-06-14 15:35:49 +0100494 Window win;
Pablo Tello8f43d742019-03-27 09:28:32 +0000495 auto win_last = _transform->get_window();
Pablo Tellod6ca4782018-01-23 09:36:04 +0000496 win.set(Window::DimX, Window::Dimension(0, win_last, 1));
Pablo Tello7282d562018-06-14 15:35:49 +0100497 _output_nhwc->info()->set_valid_region(ValidRegion(Coordinates(), _output_nhwc->info()->tensor_shape()));
498
Pablo Tellod6ca4782018-01-23 09:36:04 +0000499 INEKernel::configure(win);
500}
501
Pablo Tellof6c572c2018-02-14 12:47:30 +0000502template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
503void NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::run(const Window &window, const ThreadInfo &info)
Pablo Tellod6ca4782018-01-23 09:36:04 +0000504{
505 ARM_COMPUTE_UNUSED(info);
506 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
Pablo Tello8f43d742019-03-27 09:28:32 +0000507 ARM_COMPUTE_ERROR_ON_NULLPTR(_workspace);
508 ARM_COMPUTE_ERROR_ON_NULLPTR(_transformed_output);
Pablo Tello7df27862018-05-30 11:44:26 +0100509 ARM_COMPUTE_ERROR_ON_NULLPTR(_output_nhwc);
Pablo Tellod6ca4782018-01-23 09:36:04 +0000510
Pablo Tello8f43d742019-03-27 09:28:32 +0000511 const int out_batch_stride = _output_nhwc->info()->strides_in_bytes()[3] / sizeof(T);
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100512 const int out_row_stride = _output_nhwc->info()->strides_in_bytes()[2] / sizeof(T);
513 const int out_col_stride = _output_nhwc->info()->strides_in_bytes()[1] / sizeof(T);
514
Pablo Tello8f43d742019-03-27 09:28:32 +0000515 _transform->set_input_matrices(_transformed_output->buffer(), _matrix_stride, _matrix_row_stride);
516 _transform->set_bias((_biases ? reinterpret_cast<T *>(_biases->buffer() + _biases->info()->offset_first_element_in_bytes()) : nullptr));
517 _transform->set_output_tensor(_output_nhwc->buffer() + _output_nhwc->info()->offset_first_element_in_bytes(), out_batch_stride, out_row_stride, out_col_stride);
518 _transform->set_working_space(_workspace->buffer());
Pablo Tellod6ca4782018-01-23 09:36:04 +0000519 // The code below cannot be moved to configure because biases hasn't been allocated at that point
520 const size_t fst = window.x().start();
521 const size_t lst = window.x().end();
Pablo Tello8f43d742019-03-27 09:28:32 +0000522 _transform->run(fst, lst, info.thread_id);
Pablo Tellod6ca4782018-01-23 09:36:04 +0000523}
524
Pablo Tellof6c572c2018-02-14 12:47:30 +0000525template <typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100526Status NEWinogradLayerTransformOutputKernel<T, OutputTileRows, OutputTileCols, KernelRows, KernelCols>::validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output,
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100527 const WinogradInfo &winograd_info)
Vidhya Sudhan Loganathan3ca97862018-04-23 08:20:04 +0100528{
Vidhya Sudhan Loganathan84ce1f92018-04-25 13:00:09 +0100529 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 +0000530 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 +0100531
532 return Status{};
533}
534
Pablo Tellof6c572c2018-02-14 12:47:30 +0000535template class NEWinogradLayerTransformOutputKernel<float, 2, 2, 3, 3>;
Vidhya Sudhan Loganathancb0010b2018-05-11 16:23:53 +0100536template class NEWinogradLayerTransformOutputKernel<float, 4, 4, 3, 3>;
Pablo Tellof6c572c2018-02-14 12:47:30 +0000537template class NEWinogradLayerTransformOutputKernel<float, 2, 2, 5, 5>;
Pablo Tellobda6e4b2018-08-22 11:40:33 +0100538template class NEWinogradLayerTransformOutputKernel<float, 1, 6, 1, 3>;
539template class NEWinogradLayerTransformOutputKernel<float, 6, 1, 3, 1>;
Pablo Tello52140b42018-01-30 14:48:11 +0000540
Pablo Tello000d33a2018-09-03 16:59:20 +0100541template class NEWinogradLayerTransformOutputKernel<float, 1, 4, 1, 5>;
542template class NEWinogradLayerTransformOutputKernel<float, 4, 1, 5, 1>;
543template class NEWinogradLayerTransformOutputKernel<float, 1, 2, 1, 7>;
544template class NEWinogradLayerTransformOutputKernel<float, 2, 1, 7, 1>;
545
Georgios Pinitas5ce897f2020-04-29 11:44:10 +0100546#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
547template class NEWinogradLayerTransformOutputKernel<__fp16, 4, 4, 3, 3>;
548#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Pablo Tello89519332017-11-17 11:52:36 +0000549} // namespace arm_compute