Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 1 | /* |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 3 | * |
| 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 | */ |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 24 | #include "arm_compute/runtime/NEON/functions/NEWinogradConvolutionLayer.h" |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 25 | |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 26 | #include "arm_compute/core/Error.h" |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/Utils.h" |
| 28 | #include "arm_compute/core/Validate.h" |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/Validate.h" |
| 30 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
Michalis Spyrou | 2b3129e | 2018-04-25 18:10:13 +0100 | [diff] [blame] | 31 | #include "arm_compute/runtime/NEON/AssemblyHelper.h" |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 32 | #include "arm_compute/runtime/NEON/NEScheduler.h" |
| 33 | #include "support/ToolchainSupport.h" |
| 34 | |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 35 | #include "arm_compute/core/NEON/kernels/NEWinogradConvolutionLayerKernel.h" |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 36 | |
Georgios Pinitas | 4074c99 | 2018-01-30 18:13:46 +0000 | [diff] [blame] | 37 | #include "arm_compute/core/NEON/kernels/convolution/winograd/winograd_gemm.hpp" |
Pablo Tello | d6ca478 | 2018-01-23 09:36:04 +0000 | [diff] [blame] | 38 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 39 | namespace arm_compute |
| 40 | { |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 41 | namespace |
| 42 | { |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 43 | inline Tensor4DShape internal_get_input_shape(const arm_compute::ITensor *input) |
| 44 | { |
| 45 | const DataLayout data_layout = input->info()->data_layout(); |
| 46 | const int in_width = input->info()->dimension(get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH)); |
| 47 | const int in_height = input->info()->dimension(get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT)); |
| 48 | const int in_channels = input->info()->dimension(get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL)); |
| 49 | const int in_batches = input->info()->dimension(3); |
| 50 | |
| 51 | return Tensor4DShape({ in_batches, in_height, in_width, in_channels }); |
| 52 | } |
| 53 | |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 54 | Status validate_arguments(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info) |
| 55 | { |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 56 | const DataLayout data_layout = input->data_layout(); |
| 57 | const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); |
| 58 | const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); |
| 59 | |
| 60 | ARM_COMPUTE_UNUSED(output); |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 61 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F32); |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 62 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, weights); |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 63 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights->dimension(width_idx) != 3 && weights->dimension(height_idx) != 5, "Only 3 and 5 kernels are supported"); |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 64 | ARM_COMPUTE_RETURN_ERROR_ON(weights->num_dimensions() > 4); |
| 65 | |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 66 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(conv_info.stride().first != 1 || conv_info.stride().second != 1, "Winograd layer only supports unit strides."); |
| 67 | |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 68 | if(biases != nullptr) |
| 69 | { |
| 70 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, biases); |
| 71 | ARM_COMPUTE_RETURN_ERROR_ON(biases->num_dimensions() > 1); |
| 72 | } |
| 73 | |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 74 | return Status{}; |
| 75 | } |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 76 | |
| 77 | Size2D winograd_output_tile(const Size2D &input_dims, const Size2D &kernel_dims) |
| 78 | { |
| 79 | Size2D output_tile = Size2D{}; |
| 80 | |
| 81 | if(kernel_dims == Size2D(3U, 3U)) |
| 82 | { |
| 83 | output_tile = (input_dims.width <= 4 && input_dims.height <= 4) ? Size2D(2U, 2U) : Size2D(4U, 4U); |
| 84 | } |
| 85 | else if(kernel_dims == Size2D(5U, 5U)) |
| 86 | { |
| 87 | output_tile = Size2D(2U, 2U); |
| 88 | } |
| 89 | |
| 90 | return output_tile; |
| 91 | } |
| 92 | |
| 93 | bool check_support_fast_math(const Size2D &output_tile, const Size2D &kernel_size) |
| 94 | { |
| 95 | // Check if we want to configure a Winograd configuration which requires fast math |
| 96 | using WinogradConfiguration = std::pair<std::pair<int, int>, std::pair<int, int>>; |
| 97 | |
| 98 | std::vector<WinogradConfiguration> fast_math_winograd = |
| 99 | { |
| 100 | WinogradConfiguration(std::pair<int, int>(2, 2), std::pair<int, int>(5, 5)), |
| 101 | WinogradConfiguration(std::pair<int, int>(4, 4), std::pair<int, int>(5, 5)) |
| 102 | }; |
| 103 | |
| 104 | auto p = std::make_pair(std::pair<int, int>(output_tile.width, output_tile.height), |
| 105 | std::pair<int, int>(kernel_size.width, kernel_size.height)); |
| 106 | |
| 107 | return std::find(fast_math_winograd.begin(), fast_math_winograd.end(), p) != fast_math_winograd.end(); |
| 108 | } |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 109 | |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 110 | } //namespace |
| 111 | |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 112 | NEWinogradConvolutionLayer::NEWinogradConvolutionLayer(std::shared_ptr<IMemoryManager> memory_manager) |
Michalis Spyrou | 2b3129e | 2018-04-25 18:10:13 +0100 | [diff] [blame] | 113 | : _memory_group(std::move(memory_manager)), _arm_gemm(nullptr), _gemm_kernel(nullptr), _transform_input_kernel(nullptr), _transform_output_kernel(nullptr), _transform_weights_kernel(nullptr), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 114 | _activationlayer_function(), _permute_input(), _permute_weights(), _permute_output(), _input_workspace(), _output_workspace(), _kernel_storage(), _input_nhwc(), _output_nhwc(), _weights_hwio(), |
Georgios Pinitas | 7221933 | 2018-06-05 14:56:06 +0100 | [diff] [blame] | 115 | _workspace(), _input(), _weights(), _output(), _is_prepared(false), _is_activationlayer_enabled(false) |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 116 | { |
| 117 | } /* arm_compute */ |
| 118 | |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 119 | void NEWinogradConvolutionLayer::configure(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info, |
| 120 | bool enable_fast_math) |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 121 | { |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 122 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, weights, output); |
Andrew Mundy | 4d9379a | 2018-03-15 16:47:03 +0000 | [diff] [blame] | 123 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), weights->info(), (biases != nullptr) ? biases->info() : nullptr, output->info(), conv_info)); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 124 | |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 125 | // Get indices for the width and height |
| 126 | const DataLayout data_layout = input->info()->data_layout(); |
| 127 | const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH); |
| 128 | const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT); |
| 129 | const unsigned int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL); |
| 130 | |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 131 | const Size2D input_dims = Size2D(input->info()->dimension(width_idx), input->info()->dimension(height_idx)); |
| 132 | const Size2D kernel_size = Size2D(weights->info()->dimension(width_idx), weights->info()->dimension(height_idx)); |
| 133 | const Size2D output_tile = winograd_output_tile(input_dims, kernel_size); |
| 134 | |
| 135 | // Check if the Winograd configuration requires fast math |
| 136 | if(!enable_fast_math) |
| 137 | { |
| 138 | ARM_COMPUTE_ERROR_ON_MSG(check_support_fast_math(output_tile, kernel_size), "This Winograd configuration requires enable_fast_math=true"); |
| 139 | } |
| 140 | |
Georgios Pinitas | 7221933 | 2018-06-05 14:56:06 +0100 | [diff] [blame] | 141 | _weights = weights; |
| 142 | _input = input; |
| 143 | _output = output; |
| 144 | _is_prepared = false; |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 145 | |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 146 | std::unique_ptr<INEWinogradLayerTransformInputKernel<float>> transform_input_kernel; |
| 147 | std::unique_ptr<INEWinogradLayerTransformWeightsKernel<float>> transform_weights_kernel; |
| 148 | std::unique_ptr<INEWinogradLayerTransformOutputKernel<float>> transform_output_kernel; |
| 149 | |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 150 | int n_gemms = 0; |
| 151 | int N_BLOCK = 0; // Size of block used by GEMM. |
Michalis Spyrou | 2b3129e | 2018-04-25 18:10:13 +0100 | [diff] [blame] | 152 | |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 153 | switch(kernel_size.width) |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 154 | { |
| 155 | case 3: |
| 156 | { |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 157 | if(input->info()->dimension(width_idx) > 4 && input->info()->dimension(height_idx) > 4) |
| 158 | { |
| 159 | transform_input_kernel = support::cpp14::make_unique<NEWinogradLayerTransformInputKernel<float, 4, 4, 3, 3>>(); |
| 160 | transform_weights_kernel = support::cpp14::make_unique<NEWinogradLayerTransformWeightsKernel<float, 4, 4, 3, 3>>(); |
| 161 | transform_output_kernel = support::cpp14::make_unique<NEWinogradLayerTransformOutputKernel<float, 4, 4, 3, 3>>(); |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 162 | n_gemms = NEWinogradLayerBatchedGEMMKernel<float, float, 4, 4, 3, 3>::WinogradBase::N_GEMMS; |
| 163 | N_BLOCK = NEWinogradLayerBatchedGEMMKernel<float, float, 4, 4, 3, 3>::WinogradConv::N_BLOCK; |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | transform_input_kernel = support::cpp14::make_unique<NEWinogradLayerTransformInputKernel<float, 2, 2, 3, 3>>(); |
| 168 | transform_weights_kernel = support::cpp14::make_unique<NEWinogradLayerTransformWeightsKernel<float, 2, 2, 3, 3>>(); |
| 169 | transform_output_kernel = support::cpp14::make_unique<NEWinogradLayerTransformOutputKernel<float, 2, 2, 3, 3>>(); |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 170 | n_gemms = NEWinogradLayerBatchedGEMMKernel<float, float, 2, 2, 3, 3>::WinogradBase::N_GEMMS; |
| 171 | N_BLOCK = NEWinogradLayerBatchedGEMMKernel<float, float, 2, 2, 3, 3>::WinogradConv::N_BLOCK; |
| 172 | } |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 173 | break; |
| 174 | } |
| 175 | case 5: |
| 176 | { |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 177 | transform_input_kernel = support::cpp14::make_unique<NEWinogradLayerTransformInputKernel<float, 2, 2, 5, 5>>(); |
| 178 | transform_weights_kernel = support::cpp14::make_unique<NEWinogradLayerTransformWeightsKernel<float, 2, 2, 5, 5>>(); |
| 179 | transform_output_kernel = support::cpp14::make_unique<NEWinogradLayerTransformOutputKernel<float, 2, 2, 5, 5>>(); |
Michalis Spyrou | 2b3129e | 2018-04-25 18:10:13 +0100 | [diff] [blame] | 180 | n_gemms = NEWinogradLayerBatchedGEMMKernel<float, float, 2, 2, 5, 5>::WinogradBase::N_GEMMS; |
| 181 | N_BLOCK = NEWinogradLayerBatchedGEMMKernel<float, float, 2, 2, 5, 5>::WinogradConv::N_BLOCK; |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 182 | break; |
| 183 | } |
| 184 | default: |
| 185 | { |
| 186 | ARM_COMPUTE_ERROR("Not supported."); |
| 187 | break; |
| 188 | } |
| 189 | } |
| 190 | |
Pablo Tello | 679463a | 2018-02-06 11:47:59 +0000 | [diff] [blame] | 191 | const PaddingType use_padding_type = (conv_info.pad_left() != 0u) ? PADDING_SAME : PADDING_VALID; |
| 192 | const bool use_same_padding = use_padding_type == PADDING_SAME; |
| 193 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 194 | // Get convolved dimensions |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 195 | const int in_channels = input->info()->dimension(channel_idx); |
| 196 | const int out_channels = output->info()->dimension(channel_idx); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 197 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 198 | const Tensor4DShape in_shape(internal_get_input_shape(input)); |
Pablo Tello | d6ca478 | 2018-01-23 09:36:04 +0000 | [diff] [blame] | 199 | const size_t data_type_size = input->info()->element_size(); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 200 | // Get the memory required to instantiate a new Winograd operator. |
Georgios Pinitas | 7221933 | 2018-06-05 14:56:06 +0100 | [diff] [blame] | 201 | constexpr size_t storage_alignment = 64; |
| 202 | |
| 203 | // Kernel Storage |
| 204 | const size_t kernel_storage_size = transform_weights_kernel->get_weight_storage_size(out_channels, in_channels) * data_type_size; |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 205 | _kernel_storage.allocator()->init(TensorInfo(TensorShape{ (kernel_storage_size + storage_alignment - 1) }, 1, DataType::U8)); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 206 | _kernel_storage.allocator()->allocate(); |
Georgios Pinitas | 7221933 | 2018-06-05 14:56:06 +0100 | [diff] [blame] | 207 | |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 208 | // Input storage |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 209 | const size_t input_storage_size = transform_input_kernel->get_input_storage_size(in_shape.n_batches, in_shape.n_channels, in_shape.n_rows, in_shape.n_cols, use_same_padding) * data_type_size; |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 210 | _input_workspace.allocator()->init(TensorInfo(TensorShape{ (input_storage_size + storage_alignment - 1) }, 1, DataType::U8)); |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 211 | _input_workspace.allocator()->allocate(); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 212 | |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 213 | // Output storage |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 214 | const size_t output_storage_size = transform_output_kernel->get_output_storage_size(in_shape.n_batches, in_shape.n_rows, in_shape.n_cols, out_channels, use_same_padding) * data_type_size; |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 215 | _output_workspace.allocator()->init(TensorInfo(TensorShape{ (output_storage_size + storage_alignment - 1) }, 1, DataType::U8)); |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 216 | _output_workspace.allocator()->allocate(); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 217 | |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 218 | // configure and allocate dst tensor to be used to convert from winograd domain to spatial domain when calling to reshape_output() |
| 219 | TensorInfo info(TensorShape(_output->info()->dimension(2), _output->info()->dimension(0), |
| 220 | _output->info()->dimension(1), _output->info()->dimension(3)), |
| 221 | 1, _output->info()->data_type()); |
| 222 | _output_nhwc.allocator()->init(info); |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 223 | _output_nhwc.allocator()->allocate(); |
Pablo Tello | 02541fb | 2017-12-15 09:48:59 +0000 | [diff] [blame] | 224 | |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 225 | const KernelShape kernel_shape({ out_channels, static_cast<int>(kernel_size.height), static_cast<int>(kernel_size.width), in_channels }); |
Pablo Tello | 52140b4 | 2018-01-30 14:48:11 +0000 | [diff] [blame] | 226 | |
| 227 | // Configure the InputTransform |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 228 | const int input_matrix_stride = transform_input_kernel->get_matrix_stride(kernel_shape, in_shape, use_padding_type); |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 229 | |
| 230 | if(data_layout == DataLayout::NCHW) |
| 231 | { |
| 232 | // configure the kernel to transform the input tensor from NCHW -> NHWC |
| 233 | _permute_input.configure(input, &_input_nhwc, PermutationVector(2U, 0U, 1U)); |
| 234 | _input_nhwc.allocator()->allocate(); |
| 235 | transform_input_kernel->configure(&_input_nhwc, in_shape.n_batches, in_shape.n_rows, in_shape.n_cols, in_shape.n_channels, use_padding_type, |
| 236 | reinterpret_cast<float *>(_input_workspace.buffer()), input_matrix_stride); |
| 237 | } |
| 238 | else |
| 239 | { |
| 240 | transform_input_kernel->configure(_input, in_shape.n_batches, in_shape.n_rows, in_shape.n_cols, in_shape.n_channels, use_padding_type, |
| 241 | reinterpret_cast<float *>(_input_workspace.buffer()), input_matrix_stride); |
| 242 | } |
Pablo Tello | 52140b4 | 2018-01-30 14:48:11 +0000 | [diff] [blame] | 243 | |
| 244 | // Configure WeightsTransform |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 245 | const int kernel_matrix_stride = transform_weights_kernel->get_matrix_stride(kernel_shape); |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 246 | if(data_layout == DataLayout::NCHW) |
| 247 | { |
| 248 | // Re-order a weight tensor from [Output feature map x Input feature map x Height x Width] to [Height x Width x Input feature map x Output feature map] |
| 249 | _permute_weights.configure(weights, &_weights_hwio, PermutationVector(3U, 2U, 0U, 1U)); |
| 250 | |
| 251 | transform_weights_kernel->configure(&_weights_hwio, reinterpret_cast<float *>(_kernel_storage.buffer()), kernel_matrix_stride, out_channels, in_channels); |
| 252 | } |
| 253 | else |
| 254 | { |
| 255 | // Re-order a weight tensor from [Output feature map x Input feature map x Height x Width] to [Height x Width x Input feature map x Output feature map] |
| 256 | _permute_weights.configure(weights, &_weights_hwio, PermutationVector(3U, 0U, 1U, 2U)); |
| 257 | |
| 258 | transform_weights_kernel->configure(&_weights_hwio, reinterpret_cast<float *>(_kernel_storage.buffer()), kernel_matrix_stride, out_channels, in_channels); |
| 259 | } |
| 260 | _weights_hwio.allocator()->allocate(); |
Pablo Tello | 52140b4 | 2018-01-30 14:48:11 +0000 | [diff] [blame] | 261 | |
| 262 | // Configure OutputTransform |
| 263 | //The biases tensor has not been allocated at this point in time, the output transform will add the biases to the final result in the run() method |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 264 | const int output_matrix_stride = transform_output_kernel->get_matrix_stride(kernel_shape, in_shape, use_padding_type); |
| 265 | const auto output_shape(transform_output_kernel->get_output_shape(kernel_shape, in_shape, use_padding_type)); |
Pablo Tello | d6ca478 | 2018-01-23 09:36:04 +0000 | [diff] [blame] | 266 | |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 267 | if(data_layout == DataLayout::NCHW) |
| 268 | { |
| 269 | transform_output_kernel->configure(biases, reinterpret_cast<float *>(_output_workspace.buffer()), |
| 270 | output_matrix_stride, &_output_nhwc, |
| 271 | in_shape.n_batches, output_shape.n_rows, output_shape.n_cols, out_channels); |
| 272 | } |
| 273 | else |
| 274 | { |
| 275 | transform_output_kernel->configure(biases, reinterpret_cast<float *>(_output_workspace.buffer()), |
| 276 | output_matrix_stride, _output, |
| 277 | in_shape.n_batches, output_shape.n_rows, output_shape.n_cols, out_channels); |
| 278 | } |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 279 | |
Michalis Spyrou | 2b3129e | 2018-04-25 18:10:13 +0100 | [diff] [blame] | 280 | // Configure GEMM |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 281 | const int tile_rows = iceildiv(output_shape.n_rows, output_tile.height); |
| 282 | const int tile_cols = iceildiv(output_shape.n_cols, output_tile.width); |
Michalis Spyrou | 2b3129e | 2018-04-25 18:10:13 +0100 | [diff] [blame] | 283 | const int m = in_shape.n_batches * tile_rows * tile_cols; |
| 284 | const int k = in_shape.n_channels; |
| 285 | const int n = out_channels; |
| 286 | const int input_matrix_row_stride = in_shape.n_channels; |
| 287 | const int kernel_matrix_row_stride = roundup(out_channels, N_BLOCK); |
| 288 | const int output_matrix_row_stride = kernel_matrix_row_stride; |
| 289 | unsigned int num_threads = NEScheduler::get().num_threads(); |
Pablo Tello | 52140b4 | 2018-01-30 14:48:11 +0000 | [diff] [blame] | 290 | |
Michalis Spyrou | 2b3129e | 2018-04-25 18:10:13 +0100 | [diff] [blame] | 291 | _arm_gemm = arm_gemm::gemm<float, float>(NEScheduler::get().cpu_info(), m, n, k, 1, n_gemms, false, false, 1.f, 0.f, num_threads, false); |
| 292 | _arm_gemm->set_arrays(reinterpret_cast<float *>(_input_workspace.buffer()), input_matrix_row_stride, 0, input_matrix_stride, reinterpret_cast<float *>(_kernel_storage.buffer()), |
| 293 | kernel_matrix_row_stride, kernel_matrix_stride, reinterpret_cast<float *>(_output_workspace.buffer()), output_matrix_row_stride, 0, output_matrix_stride); |
| 294 | |
| 295 | auto acl_gemm_wrapper = support::cpp14::make_unique<NEGEMMAssemblyWrapper<arm_gemm::GemmCommon<float, float>>>(); |
| 296 | acl_gemm_wrapper->configure(_arm_gemm.get()); |
| 297 | const size_t workspace_size = _arm_gemm->get_working_size(); |
| 298 | |
| 299 | // Allocate workspace |
| 300 | if(workspace_size > 0) |
| 301 | { |
| 302 | const unsigned int alignment = 4096; |
Georgios Pinitas | b95e210 | 2018-05-30 10:17:38 +0100 | [diff] [blame] | 303 | // TODO (COMPMID-1248) : Add support for memory manager in NEWinogradConvolutionLayer |
| 304 | // Warning : Do not set a memory group in allocate_workspace, should be done under COMPMID-1248 |
| 305 | allocate_workspace(workspace_size, _workspace, nullptr, alignment, 1); |
Michalis Spyrou | 2b3129e | 2018-04-25 18:10:13 +0100 | [diff] [blame] | 306 | _arm_gemm->set_working_space(reinterpret_cast<float *>(_workspace.buffer())); |
| 307 | } |
| 308 | |
| 309 | const unsigned int window_size = _arm_gemm->get_window_size(); |
| 310 | if(window_size < num_threads) |
| 311 | { |
| 312 | num_threads = window_size; |
| 313 | _arm_gemm->set_nthreads(num_threads); |
| 314 | } |
| 315 | |
| 316 | _gemm_kernel = std::move(acl_gemm_wrapper); |
Pablo Tello | 52140b4 | 2018-01-30 14:48:11 +0000 | [diff] [blame] | 317 | |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 318 | // Reorder the convoluted output to ACL's ordering NCHW |
| 319 | _permute_output.configure(&_output_nhwc, _output, PermutationVector(1U, 2U, 0U)); |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 320 | |
| 321 | _transform_input_kernel = std::move(transform_input_kernel); |
| 322 | _transform_weights_kernel = std::move(transform_weights_kernel); |
| 323 | _transform_output_kernel = std::move(transform_output_kernel); |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 324 | |
| 325 | //Configure Activation Layer |
| 326 | _is_activationlayer_enabled = act_info.enabled(); |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame^] | 327 | if(_is_activationlayer_enabled) |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 328 | { |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 329 | _activationlayer_function.configure(_output, nullptr, act_info); |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 330 | } |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 331 | } |
| 332 | |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 333 | void NEWinogradConvolutionLayer::run() |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 334 | { |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 335 | const DataLayout data_layout = _input->info()->data_layout(); |
| 336 | |
Georgios Pinitas | 7221933 | 2018-06-05 14:56:06 +0100 | [diff] [blame] | 337 | prepare(); |
| 338 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 339 | _memory_group.acquire(); |
Pablo Tello | 679463a | 2018-02-06 11:47:59 +0000 | [diff] [blame] | 340 | |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 341 | if(data_layout == DataLayout::NCHW) |
| 342 | { |
| 343 | //Bring channels to the front as Winograd code expects the tensor to be in the format NHWC |
| 344 | _permute_input.run(); |
| 345 | } |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 346 | // Transform input tensor to the winograd domain |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 347 | NEScheduler::get().schedule(_transform_input_kernel.get(), Window::DimX); |
Pablo Tello | d6ca478 | 2018-01-23 09:36:04 +0000 | [diff] [blame] | 348 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 349 | //Run 16 GEMMs in multiple threads, each kernel runs one or more GEMMs |
Michalis Spyrou | 2b3129e | 2018-04-25 18:10:13 +0100 | [diff] [blame] | 350 | NEScheduler::get().schedule(_gemm_kernel.get(), Window::DimX); |
Pablo Tello | d6ca478 | 2018-01-23 09:36:04 +0000 | [diff] [blame] | 351 | |
Pablo Tello | 9ceebbe | 2018-01-10 16:44:13 +0000 | [diff] [blame] | 352 | // Transform output tensor to the spatial domain |
Pablo Tello | f6c572c | 2018-02-14 12:47:30 +0000 | [diff] [blame] | 353 | NEScheduler::get().schedule(_transform_output_kernel.get(), Window::DimX); |
Pablo Tello | d6ca478 | 2018-01-23 09:36:04 +0000 | [diff] [blame] | 354 | |
Pablo Tello | 7df2786 | 2018-05-30 11:44:26 +0100 | [diff] [blame] | 355 | if(data_layout == DataLayout::NCHW) |
| 356 | { |
| 357 | // Reorder the convoluted output to ACL's ordering NCHW |
| 358 | _permute_output.run(); |
| 359 | } |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 360 | |
| 361 | if(_is_activationlayer_enabled) |
| 362 | { |
| 363 | _activationlayer_function.run(); |
| 364 | } |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame^] | 365 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 366 | _memory_group.release(); |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 367 | } |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 368 | |
Georgios Pinitas | 9fb1159 | 2018-04-26 20:34:58 +0100 | [diff] [blame] | 369 | Status NEWinogradConvolutionLayer::validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 370 | const ActivationLayerInfo &act_info, bool enable_fast_math) |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 371 | { |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 372 | ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, weights, output); |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 373 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, weights, biases, output, conv_info)); |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 374 | |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 375 | // Get indices for the width and height |
| 376 | const size_t idx_width = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::WIDTH); |
| 377 | const size_t idx_height = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::HEIGHT); |
| 378 | |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 379 | // Input shape, kernel size and output tile |
| 380 | const Size2D input_dims = Size2D(input->dimension(idx_width), input->dimension(idx_height)); |
| 381 | const Size2D kernel_size = Size2D(weights->dimension(idx_width), weights->dimension(idx_height)); |
| 382 | const Size2D output_tile = winograd_output_tile(input_dims, kernel_size); |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 383 | |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 384 | // Check if the Winograd configuration requires fast math |
| 385 | if(!enable_fast_math) |
| 386 | { |
| 387 | ARM_COMPUTE_RETURN_ERROR_ON_MSG(check_support_fast_math(output_tile, kernel_size), "This Winograd configuration requires enable_fast_math=true"); |
| 388 | } |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 389 | |
| 390 | const WinogradInfo winograd_info = WinogradInfo(output_tile, |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 391 | kernel_size, |
| 392 | input_dims, |
Vidhya Sudhan Loganathan | 84ce1f9 | 2018-04-25 13:00:09 +0100 | [diff] [blame] | 393 | conv_info, |
| 394 | input->data_layout()); |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 395 | |
| 396 | // Validate input transform |
Vidhya Sudhan Loganathan | 84ce1f9 | 2018-04-25 13:00:09 +0100 | [diff] [blame] | 397 | const TensorShape input0_shape = misc::shape_calculator::compute_winograd_input_transform_shape(*input, winograd_info); |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 398 | const TensorInfo input0 = input->clone()->set_tensor_shape(input0_shape); |
Pablo Tello | 7282d56 | 2018-06-14 15:35:49 +0100 | [diff] [blame^] | 399 | |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 400 | switch(weights->dimension(idx_width)) |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 401 | { |
| 402 | case 3: |
| 403 | { |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 404 | if(input_dims.width > 4 && input_dims.height > 4) |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 405 | { |
| 406 | ARM_COMPUTE_RETURN_ON_ERROR((NEWinogradLayerTransformInputKernel<float, 4, 4, 3, 3>::validate(input, &input0, winograd_info))); |
| 407 | } |
| 408 | else |
| 409 | { |
| 410 | ARM_COMPUTE_RETURN_ON_ERROR((NEWinogradLayerTransformInputKernel<float, 2, 2, 3, 3>::validate(input, &input0, winograd_info))); |
| 411 | } |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 412 | break; |
| 413 | } |
| 414 | case 5: |
| 415 | { |
Vidhya Sudhan Loganathan | 84ce1f9 | 2018-04-25 13:00:09 +0100 | [diff] [blame] | 416 | ARM_COMPUTE_RETURN_ON_ERROR((NEWinogradLayerTransformInputKernel<float, 2, 2, 5, 5>::validate(input, &input0, winograd_info))); |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 417 | break; |
| 418 | } |
| 419 | default: |
| 420 | { |
| 421 | ARM_COMPUTE_RETURN_ERROR_MSG("Only 3x3 and 5x5 kernels supported."); |
| 422 | break; |
| 423 | } |
| 424 | } |
| 425 | // Validate filter transform |
Vidhya Sudhan Loganathan | 84ce1f9 | 2018-04-25 13:00:09 +0100 | [diff] [blame] | 426 | const TensorShape input1_shape = misc::shape_calculator::compute_winograd_filter_transform_shape(*weights, winograd_info); |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 427 | const TensorInfo input1 = weights->clone()->set_tensor_shape(input1_shape); |
| 428 | |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 429 | switch(weights->dimension(idx_width)) |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 430 | { |
| 431 | case 3: |
| 432 | { |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 433 | if(input_dims.width > 4 && input_dims.height > 4) |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 434 | { |
| 435 | ARM_COMPUTE_RETURN_ON_ERROR((NEWinogradLayerTransformWeightsKernel<float, 4, 4, 3, 3>::validate(weights, &input1, winograd_info))); |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | ARM_COMPUTE_RETURN_ON_ERROR((NEWinogradLayerTransformWeightsKernel<float, 2, 2, 3, 3>::validate(weights, &input1, winograd_info))); |
| 440 | } |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 441 | break; |
| 442 | } |
| 443 | case 5: |
| 444 | { |
Vidhya Sudhan Loganathan | 84ce1f9 | 2018-04-25 13:00:09 +0100 | [diff] [blame] | 445 | ARM_COMPUTE_RETURN_ON_ERROR((NEWinogradLayerTransformWeightsKernel<float, 2, 2, 5, 5>::validate(weights, &input1, winograd_info))); |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 446 | break; |
| 447 | } |
| 448 | default: |
| 449 | { |
| 450 | ARM_COMPUTE_RETURN_ERROR_MSG("Only 3x3 and 5x5 kernels supported."); |
| 451 | break; |
| 452 | } |
| 453 | } |
| 454 | // Validate batched matrix multiply |
| 455 | TensorShape batched_mm_output_shape = input0.tensor_shape(); |
| 456 | batched_mm_output_shape[0] = input1.tensor_shape()[0]; |
| 457 | const TensorInfo batched_mm_output = input0.clone()->set_tensor_shape(batched_mm_output_shape); |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 458 | switch(weights->dimension(idx_width)) |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 459 | { |
| 460 | case 3: |
| 461 | { |
Giorgio Arena | a3221e6 | 2018-05-03 15:57:48 +0100 | [diff] [blame] | 462 | if(input_dims.width > 4 && input_dims.height > 4) |
Vidhya Sudhan Loganathan | cb0010b | 2018-05-11 16:23:53 +0100 | [diff] [blame] | 463 | { |
| 464 | // Validate output transform |
| 465 | ARM_COMPUTE_RETURN_ON_ERROR((NEWinogradLayerTransformOutputKernel<float, 4, 4, 3, 3>::validate(&batched_mm_output, biases, output, winograd_info))); |
| 466 | } |
| 467 | else |
| 468 | { |
| 469 | // Validate output transform |
| 470 | ARM_COMPUTE_RETURN_ON_ERROR((NEWinogradLayerTransformOutputKernel<float, 2, 2, 3, 3>::validate(&batched_mm_output, biases, output, winograd_info))); |
| 471 | } |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 472 | break; |
| 473 | } |
| 474 | case 5: |
| 475 | { |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 476 | // Validate output transform |
Vidhya Sudhan Loganathan | 84ce1f9 | 2018-04-25 13:00:09 +0100 | [diff] [blame] | 477 | ARM_COMPUTE_RETURN_ON_ERROR((NEWinogradLayerTransformOutputKernel<float, 2, 2, 5, 5>::validate(&batched_mm_output, biases, output, winograd_info))); |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 478 | break; |
| 479 | } |
| 480 | default: |
| 481 | { |
| 482 | ARM_COMPUTE_RETURN_ERROR_MSG("Only 3x3 and 5x5 kernels supported."); |
| 483 | break; |
| 484 | } |
| 485 | } |
Vidhya Sudhan Loganathan | 3ca9786 | 2018-04-23 08:20:04 +0100 | [diff] [blame] | 486 | // Validate Activation Layer |
| 487 | if(act_info.enabled()) |
| 488 | { |
| 489 | NEActivationLayer::validate(output, nullptr, act_info); |
| 490 | } |
Isabella Gottardi | 6acc6ad | 2018-02-02 17:19:18 +0000 | [diff] [blame] | 491 | return Status{}; |
| 492 | } |
| 493 | |
Georgios Pinitas | 7221933 | 2018-06-05 14:56:06 +0100 | [diff] [blame] | 494 | void NEWinogradConvolutionLayer::prepare() |
| 495 | { |
| 496 | if(!_is_prepared) |
| 497 | { |
| 498 | // Permute weights |
| 499 | _permute_weights.run(); |
| 500 | _weights->mark_as_unused(); |
| 501 | |
| 502 | // Transform weights |
| 503 | NEScheduler::get().schedule(_transform_weights_kernel.get(), Window::DimX); |
| 504 | _weights_hwio.allocator()->free(); |
| 505 | |
| 506 | _is_prepared = true; |
| 507 | } |
| 508 | } |
| 509 | |
Pablo Tello | 8951933 | 2017-11-17 11:52:36 +0000 | [diff] [blame] | 510 | } // namespace arm_compute |