blob: f6dc3a8f43076b585093821ebf2bbba26b056d85 [file] [log] [blame]
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +00001/*
Sang-Hoon Park4715cf92020-01-08 16:02:47 +00002 * Copyright (c) 2017-2020 ARM Limited.
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +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 */
24#include "arm_compute/runtime/NEON/functions/NEGEMMConvolutionLayer.h"
25
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000026#include "arm_compute/core/Size2D.h"
27#include "arm_compute/core/Utils.h"
28#include "arm_compute/core/Validate.h"
Gian Marco Iodice597a8562018-08-01 15:06:06 +010029#include "arm_compute/core/utils/misc/ShapeCalculator.h"
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000030#include "arm_compute/core/utils/quantization/AsymmHelpers.h"
31#include "arm_compute/runtime/NEON/NEScheduler.h"
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000032
Georgios Pinitas08346e92018-10-16 19:10:46 +010033#include <set>
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000034#include <tuple>
35
Michalis Spyroue7be8a02019-12-12 16:16:09 +000036namespace arm_compute
37{
Gian Marco Iodice597a8562018-08-01 15:06:06 +010038using namespace arm_compute::misc::shape_calculator;
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000039
Gian Marco Iodice597a8562018-08-01 15:06:06 +010040NEConvolutionLayerReshapeWeights::NEConvolutionLayerReshapeWeights()
41 : _weights_reshape_kernel()
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000042{
43}
44
Gian Marco Iodice597a8562018-08-01 15:06:06 +010045void NEConvolutionLayerReshapeWeights::configure(const ITensor *weights, const ITensor *biases, ITensor *output)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000046{
47 // Perform validation step
48 ARM_COMPUTE_ERROR_ON_NULLPTR(weights, output);
49 ARM_COMPUTE_ERROR_THROW_ON(NEConvolutionLayerReshapeWeights::validate(weights->info(),
50 (biases != nullptr) ? biases->info() : nullptr,
Gian Marco Iodice597a8562018-08-01 15:06:06 +010051 output->info()));
Gian Marco Iodice597a8562018-08-01 15:06:06 +010052 const bool append_biases = (biases != nullptr) && !is_data_type_quantized_asymmetric(weights->info()->data_type());
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000053 const ITensor *biases_to_use = (append_biases) ? biases : nullptr;
54
Gian Marco Iodice597a8562018-08-01 15:06:06 +010055 _weights_reshape_kernel.configure(weights, biases_to_use, output);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000056
57 output->info()->set_quantization_info(weights->info()->quantization_info());
58}
59
Gian Marco Iodice597a8562018-08-01 15:06:06 +010060Status NEConvolutionLayerReshapeWeights::validate(const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000061{
Gian Marco Iodice597a8562018-08-01 15:06:06 +010062 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(weights);
Georgios Pinitas6e1791b2019-12-02 19:01:25 +000063 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(weights, 1,
64 DataType::QASYMM8, DataType::QASYMM8_SIGNED, DataType::QSYMM8_PER_CHANNEL,
Georgios Pinitasc7b183a2020-03-06 18:12:09 +000065 DataType::BFLOAT16, DataType::F16, DataType::F32);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000066 ARM_COMPUTE_RETURN_ERROR_ON(weights->num_dimensions() > 4);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000067
Gian Marco Iodice597a8562018-08-01 15:06:06 +010068 if(biases != nullptr)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000069 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +010070 const int idx_kernels = get_data_layout_dimension_index(weights->data_layout(), DataLayoutDimension::BATCHES);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000071 ARM_COMPUTE_RETURN_ERROR_ON(is_data_type_quantized_asymmetric(weights->data_type()));
72 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(weights, biases);
Gian Marco Iodice597a8562018-08-01 15:06:06 +010073 ARM_COMPUTE_RETURN_ERROR_ON(biases->dimension(0) != weights->dimension(idx_kernels));
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000074 ARM_COMPUTE_RETURN_ERROR_ON(biases->num_dimensions() > 1);
75 }
76
Gian Marco Iodice597a8562018-08-01 15:06:06 +010077 if((output != nullptr) && (output->total_size() != 0))
Michalis Spyroue2503892018-04-23 15:17:31 +010078 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +010079 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(weights, output);
Michalis Spyroue2503892018-04-23 15:17:31 +010080
Gian Marco Iodice597a8562018-08-01 15:06:06 +010081 NEWeightsReshapeKernel::validate(weights, biases, output);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000082 }
83
84 return Status{};
85}
86
87void NEConvolutionLayerReshapeWeights::run()
88{
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000089 NEScheduler::get().schedule(&_weights_reshape_kernel, 3);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000090}
91
Michalis Spyrou1a569a32019-09-10 17:20:34 +010092NEGEMMConvolutionLayer::NEGEMMConvolutionLayer(const std::shared_ptr<IMemoryManager> &memory_manager, IWeightsManager *weights_manager)
93 : _memory_group(memory_manager), _weights_manager(weights_manager), _reshape_weights(), _reshape_weights_managed(), _im2col_kernel(), _mm_gemm(memory_manager), _mm_gemmlowp(memory_manager),
Georgios Pinitas48b3ef82019-10-14 19:03:09 +010094 _col2im_kernel(), _reshape_layer(), _original_weights(nullptr), _im2col_output(), _weights_reshaped(), _gemm_output(), _tmp_output(), _data_layout(DataLayout::NCHW), _skip_im2col(false),
95 _skip_col2im(false), _is_quantized(false), _is_prepared(false)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +000096{
97}
98
George Wort2d7e6832019-02-22 16:37:41 +000099void NEGEMMConvolutionLayer::configure_mm(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, const ActivationLayerInfo &act_info, int gemm_3d_depth)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000100{
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100101 ARM_COMPUTE_ERROR_ON_NULLPTR(input, weights);
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100102 ARM_COMPUTE_ERROR_THROW_ON(validate_mm(input->info(), weights->info(), biases == nullptr ? nullptr : biases->info(), output == nullptr ? nullptr : output->info(),
103 act_info, gemm_3d_depth, _skip_im2col));
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100104
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100105 // Create GEMMInfo structure
Georgios Pinitasbb081ca2018-11-08 10:22:01 +0000106 const GEMMInfo &gemm_info = GEMMInfo(false, false, true /* Reshape weights only for the first run */,
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100107 gemm_3d_depth, _skip_im2col /* Reinterpret the input as 3D if im2col is skipped */,
108 false, GEMMLowpOutputStageInfo(), false, false, act_info);
109
110 // Supported activations in GEMM
111 const std::set<ActivationLayerInfo::ActivationFunction> supported_acts = { ActivationLayerInfo::ActivationFunction::RELU,
112 ActivationLayerInfo::ActivationFunction::BOUNDED_RELU,
113 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU
114 };
Georgios Pinitasbb081ca2018-11-08 10:22:01 +0000115
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000116 if(_is_quantized)
117 {
118 // Since we need negative offsets for computing convolution, we need to change QuantizationInfo()
119 // Extract and negate input and weights offset
Georgios Pinitas6e1791b2019-12-02 19:01:25 +0000120 const QuantizationInfo iqinfo = input->info()->quantization_info();
121 const QuantizationInfo wqinfo = weights->info()->quantization_info();
122 const QuantizationInfo oqinfo = (output->info()->total_size() == 0) ? iqinfo : output->info()->quantization_info();
123 const UniformQuantizationInfo uiqinfo = iqinfo.uniform();
124 const UniformQuantizationInfo uoqinfo = oqinfo.uniform();
125 const DataType data_type = input->info()->data_type();
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000126
Georgios Pinitasdbdea0d2019-10-16 19:21:40 +0100127 input->info()->set_quantization_info(QuantizationInfo(uiqinfo.scale, -uiqinfo.offset));
128 if(!is_data_type_quantized_per_channel(weights->info()->data_type()))
129 {
130 const UniformQuantizationInfo uwqinfo = wqinfo.uniform();
131 weights->info()->set_quantization_info(QuantizationInfo(uwqinfo.scale, -uwqinfo.offset));
132 }
George Wort2d7e6832019-02-22 16:37:41 +0000133
134 // Merge activation with output stage
Michalis Spyroue7be8a02019-12-12 16:16:09 +0000135 PixelValue type_min{};
136 PixelValue type_max{};
Georgios Pinitas6e1791b2019-12-02 19:01:25 +0000137 std::tie(type_min, type_max) = get_min_max(data_type);
Michalis Spyroue7be8a02019-12-12 16:16:09 +0000138 int32_t min_activation = type_min.get<int32_t>();
139 int32_t max_activation = type_max.get<int32_t>();
George Wort2d7e6832019-02-22 16:37:41 +0000140
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100141 if(supported_acts.count(act_info.activation()) != 0)
George Wort2d7e6832019-02-22 16:37:41 +0000142 {
Sang-Hoon Park4715cf92020-01-08 16:02:47 +0000143 std::tie(min_activation, max_activation) = get_quantized_activation_min_max(act_info, data_type, uoqinfo);
George Wort2d7e6832019-02-22 16:37:41 +0000144 }
145
146 GEMMLowpOutputStageInfo output_info;
Georgios Pinitas6e1791b2019-12-02 19:01:25 +0000147 output_info.type = GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT;
148 output_info.gemmlowp_offset = uoqinfo.offset;
149 output_info.gemmlowp_min_bound = min_activation;
150 output_info.gemmlowp_max_bound = max_activation;
151 output_info.is_quantized_per_channel = (weights->info()->data_type() == DataType::QSYMM8_PER_CHANNEL);
Michele Di Giorgiof29d1b72019-10-29 10:58:13 +0000152 quantization::calculate_quantized_multipliers(iqinfo, wqinfo, oqinfo, output_info);
George Wort2d7e6832019-02-22 16:37:41 +0000153
154 _mm_gemmlowp.configure(input, weights, biases, output, GEMMInfo(false, false, true, gemm_3d_depth, _skip_im2col, false, output_info));
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000155
156 // Revert back QuantizatioInfo as input and weights could be used in other convolution layers
Georgios Pinitasdbdea0d2019-10-16 19:21:40 +0100157 input->info()->set_quantization_info(iqinfo);
158 weights->info()->set_quantization_info(wqinfo);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000159 }
160 else
161 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100162 // Configure matrix multiply function
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100163 _mm_gemm.configure(input, weights, biases, output, 1.0f, 0.0f, gemm_info);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000164 }
165}
166
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100167Status NEGEMMConvolutionLayer::validate_mm(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output,
168 const ActivationLayerInfo &act_info, int gemm_3d_depth, bool skip_im2col)
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100169{
Georgios Pinitas6e1791b2019-12-02 19:01:25 +0000170 const DataType data_type = input->data_type();
171 const bool is_quantized = is_data_type_quantized_asymmetric(data_type);
172 const bool is_activation_enabled = act_info.enabled();
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100173
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100174 // Create GEMMInfo structure
175 const GEMMInfo gemm_info = GEMMInfo(false, false, true /* Reshape weights only for the first run */,
176 gemm_3d_depth, skip_im2col /* Reinterpret the input as 3D if im2col is skipped */,
177 false, GEMMLowpOutputStageInfo(), false, false, act_info);
178
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100179 if(is_quantized)
180 {
181 // Since we need negative offsets for computing convolution, we need to change QuantizationInfo()
182 // Extract and negate input and weights offset
Georgios Pinitasdbdea0d2019-10-16 19:21:40 +0100183 const QuantizationInfo &iqinfo = input->quantization_info();
184 const QuantizationInfo &wqinfo = weights->quantization_info();
185 const QuantizationInfo &oqinfo = (output->total_size() == 0) ? iqinfo : output->quantization_info();
186 const UniformQuantizationInfo uoqinfo = oqinfo.uniform();
George Wort2d7e6832019-02-22 16:37:41 +0000187
188 // Merge activation with output stage
Michalis Spyroue7be8a02019-12-12 16:16:09 +0000189 PixelValue type_min{};
190 PixelValue type_max{};
Georgios Pinitas6e1791b2019-12-02 19:01:25 +0000191 std::tie(type_min, type_max) = get_min_max(data_type);
Michalis Spyroue7be8a02019-12-12 16:16:09 +0000192 int32_t min_activation = type_min.get<int32_t>();
193 int32_t max_activation = type_max.get<int32_t>();
George Wort2d7e6832019-02-22 16:37:41 +0000194
195 const std::set<ActivationLayerInfo::ActivationFunction> supported_acts = { ActivationLayerInfo::ActivationFunction::RELU,
196 ActivationLayerInfo::ActivationFunction::BOUNDED_RELU,
197 ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU
198 };
199 if(is_activation_enabled && supported_acts.count(act_info.activation()) != 0)
200 {
Sang-Hoon Park4715cf92020-01-08 16:02:47 +0000201 std::tie(min_activation, max_activation) = get_quantized_activation_min_max(act_info, data_type, uoqinfo);
George Wort2d7e6832019-02-22 16:37:41 +0000202 }
203
204 GEMMLowpOutputStageInfo output_info;
Georgios Pinitas6e1791b2019-12-02 19:01:25 +0000205 output_info.type = GEMMLowpOutputStageType::QUANTIZE_DOWN_FIXEDPOINT;
206 output_info.gemmlowp_offset = uoqinfo.offset;
207 output_info.gemmlowp_min_bound = min_activation;
208 output_info.gemmlowp_max_bound = max_activation;
209 output_info.is_quantized_per_channel = (weights->data_type() == DataType::QSYMM8_PER_CHANNEL);
Michele Di Giorgiof29d1b72019-10-29 10:58:13 +0000210 ARM_COMPUTE_RETURN_ON_ERROR(quantization::calculate_quantized_multipliers(iqinfo, wqinfo, oqinfo, output_info));
George Wort2d7e6832019-02-22 16:37:41 +0000211
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100212 // Perform validation step on GEMMLowp
Georgios Pinitasdbdea0d2019-10-16 19:21:40 +0100213 std::unique_ptr<ITensorInfo> input_qa = input->clone();
214 std::unique_ptr<ITensorInfo> weights_qa = weights->clone();
215 input_qa->set_quantization_info(QuantizationInfo(iqinfo.uniform().scale, -iqinfo.uniform().offset));
216 weights_qa->set_quantization_info(QuantizationInfo(wqinfo.uniform().scale, -wqinfo.uniform().offset));
George Wort2d7e6832019-02-22 16:37:41 +0000217 return NEGEMMLowpMatrixMultiplyCore::validate(input_qa.get(), weights_qa.get(), biases, output, GEMMInfo(false, false, true, gemm_3d_depth, skip_im2col, false, output_info));
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100218 }
219 else
220 {
221 // Perform validation step on Matrix multiply function
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100222 return NEGEMM::validate(input, weights, nullptr, output, 1.0f, 0.0f, gemm_info);
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100223 }
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100224}
225
Giorgio Arena7a669a82019-11-13 17:07:13 +0000226Status NEGEMMConvolutionLayer::validate_gemm3d(const ITensorInfo *input_info, const ITensorInfo *weights_info, const ActivationLayerInfo &act_info, int gemm_3d_depth, bool skip_im2col)
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100227{
George Wort2d7e6832019-02-22 16:37:41 +0000228 const DataType data_type = input_info->data_type();
229 const unsigned int mult_y = skip_im2col ? 1U : gemm_3d_depth;
230 const unsigned int mult_z = skip_im2col ? gemm_3d_depth : 1U;
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100231
232 // Set dummy tensor shapes for the validation
George Wort2d7e6832019-02-22 16:37:41 +0000233 const TensorInfo dummy_input_info(TensorShape(4U, 4U * mult_y, 1U * mult_z), 1, data_type, input_info->quantization_info());
Giorgio Arena7a669a82019-11-13 17:07:13 +0000234 const TensorInfo dummy_weights_info(TensorShape(4U, 4U), 1, data_type, weights_info->quantization_info());
George Wort2d7e6832019-02-22 16:37:41 +0000235 const TensorInfo dummy_output_info(TensorShape(4U, 4U, gemm_3d_depth), 1, data_type, input_info->quantization_info());
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100236
George Wort2d7e6832019-02-22 16:37:41 +0000237 return validate_mm(&dummy_input_info, &dummy_weights_info, nullptr, &dummy_output_info, act_info, gemm_3d_depth, skip_im2col);
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100238}
239
Alex Gilday7da29b62018-03-23 14:16:00 +0000240void NEGEMMConvolutionLayer::configure(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info,
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100241 const Size2D &dilation, const ActivationLayerInfo &act_info, unsigned int num_groups)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000242{
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000243 ARM_COMPUTE_ERROR_ON_NULLPTR(input, weights, output);
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100244 ARM_COMPUTE_UNUSED(num_groups, weights_info);
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100245 ARM_COMPUTE_ERROR_THROW_ON(NEGEMMConvolutionLayer::validate(input->info(),
246 weights->info(),
247 biases != nullptr ? biases->info() : nullptr,
248 output->info(),
249 conv_info,
250 weights_info,
251 dilation,
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100252 act_info,
253 num_groups));
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000254
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100255 const DataType data_type = input->info()->data_type();
256 const DataLayout data_layout = input->info()->data_layout();
257 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
258 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100259 const int idx_kernels = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES);
Michalis Spyroue2503892018-04-23 15:17:31 +0100260
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100261 const unsigned int kernel_width = weights->info()->dimension(idx_width);
262 const unsigned int kernel_height = weights->info()->dimension(idx_height);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000263
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100264 _is_prepared = weights_info.retain_internal_weights();
265 _original_weights = weights;
266 _is_quantized = is_data_type_quantized_asymmetric(input->info()->data_type());
267 _data_layout = data_layout;
268 _skip_im2col = (data_layout == DataLayout::NHWC && kernel_width == 1 && kernel_height == 1 && conv_info.stride().first == 1 && conv_info.stride().second == 1);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000269
George Wort2d7e6832019-02-22 16:37:41 +0000270 const ITensor *gemm_input_to_use = input;
271 ITensor *gemm_output_to_use = output;
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000272
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100273 // Get convolved dimensions
274 unsigned int conv_w = 0;
275 unsigned int conv_h = 0;
276 std::tie(conv_w, conv_h) = scaled_dimensions(input->info()->dimension(idx_width),
277 input->info()->dimension(idx_height),
278 kernel_width,
279 kernel_height,
280 conv_info,
281 dilation);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000282
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100283 // Check if GEMM3D is supported
Georgios Pinitase413d252018-11-14 18:29:58 +0000284 if(data_layout == DataLayout::NHWC)
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100285 {
Giorgio Arena7a669a82019-11-13 17:07:13 +0000286 _skip_col2im = bool(validate_gemm3d(input->info(), weights->info(), act_info, conv_h, true));
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100287 // If not supported, we need to perform im2col and col2im (or reshape layer)
Georgios Pinitase413d252018-11-14 18:29:58 +0000288 if(!_skip_col2im)
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100289 {
290 _skip_im2col = false;
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100291 }
292 }
Georgios Pinitase413d252018-11-14 18:29:58 +0000293 else
294 {
295 _skip_col2im = false;
296 }
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100297
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100298 // Get parameters from conv_info
299 unsigned int stride_x = 0;
300 unsigned int stride_y = 0;
301 std::tie(stride_x, stride_y) = conv_info.stride();
302
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100303 unsigned int mat_weights_cols = weights->info()->dimension(idx_kernels);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000304
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100305 // _weights_reshaped will be auto configured in the kernel.
306 // Just append biases and do not transpose 1xW as it will be reshaped in NEGEMM
Michalis Spyrou1a569a32019-09-10 17:20:34 +0100307 const ITensor *weights_to_use = weights;
308
309 if(_weights_manager && _weights_manager->are_weights_managed(weights))
310 {
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100311 _reshape_weights_managed.configure(weights, nullptr);
Michalis Spyrou1a569a32019-09-10 17:20:34 +0100312 weights_to_use = _weights_manager->acquire(weights, &_reshape_weights_managed);
313 }
314 else
315 {
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100316 _reshape_weights.configure(weights, nullptr, &_weights_reshaped);
Michalis Spyrou1a569a32019-09-10 17:20:34 +0100317 weights_to_use = &_weights_reshaped;
318 }
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100319
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100320 // Create tensor to store im2col reshaped inputs
Michalis Spyroue2503892018-04-23 15:17:31 +0100321 if(!_skip_im2col)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000322 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100323 _memory_group.manage(&_im2col_output);
Michalis Spyroue2503892018-04-23 15:17:31 +0100324
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +0100325 // Configure
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100326 _im2col_kernel.configure(input, &_im2col_output, Size2D(kernel_width, kernel_height), conv_info, false, dilation);
Michalis Spyroue2503892018-04-23 15:17:31 +0100327
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100328 // Update GEMM input
329 gemm_input_to_use = &_im2col_output;
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000330 }
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000331
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100332 // Create temporary GEMM output tensor in case we cannot skip col2im
Georgios Pinitasc7b183a2020-03-06 18:12:09 +0000333 const DataType output_data_type = data_type == DataType::BFLOAT16 ? DataType::F32 : data_type;
George Wort2d7e6832019-02-22 16:37:41 +0000334 if(!_skip_col2im)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000335 {
George Wort2d7e6832019-02-22 16:37:41 +0000336 TensorShape shape_gemm;
Georgios Pinitasbb081ca2018-11-08 10:22:01 +0000337
George Wort2d7e6832019-02-22 16:37:41 +0000338 // Calculate GEMM output shape
339 shape_gemm = _im2col_output.info()->tensor_shape();
340 shape_gemm.set(0, mat_weights_cols);
341 shape_gemm.set(1, conv_w * conv_h);
Georgios Pinitasbb081ca2018-11-08 10:22:01 +0000342
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100343 // FIXME: input->clone() doesn't work with subtensors for grouped convolutions.
Georgios Pinitasc7b183a2020-03-06 18:12:09 +0000344 TensorInfo info_gemm(shape_gemm, 1, output_data_type);
Georgios Pinitas041f36d2018-09-18 18:38:37 +0100345 info_gemm.set_quantization_info(output->info()->quantization_info()).set_data_layout(input->info()->data_layout());
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100346 _gemm_output.allocator()->init(info_gemm);
347 _memory_group.manage(&_gemm_output);
348
349 // Update GEMM output
350 gemm_output_to_use = &_gemm_output;
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000351 }
352
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100353 // Configure GEMM
Gian Marco Iodice3139f032018-11-05 14:26:32 +0000354 // In case we need to skip col2im, GEMM3D (gemm_3d_depth != 0) must be called in order to avoid reshaping the output matrix
355 const unsigned int gemm_3d_depth = _skip_col2im ? conv_h : 0;
Michalis Spyrou1a569a32019-09-10 17:20:34 +0100356 configure_mm(gemm_input_to_use, weights_to_use, biases, gemm_output_to_use, act_info, gemm_3d_depth);
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100357
Michalis Spyroue2503892018-04-23 15:17:31 +0100358 if(!_skip_im2col)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000359 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100360 _im2col_output.allocator()->allocate();
361 }
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000362
Georgios Pinitase413d252018-11-14 18:29:58 +0000363 if(!_skip_col2im)
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100364 {
Georgios Pinitase413d252018-11-14 18:29:58 +0000365 if(_data_layout == DataLayout::NCHW)
366 {
367 // Configure col2im
George Wort2d7e6832019-02-22 16:37:41 +0000368 _col2im_kernel.configure(gemm_output_to_use, output, Size2D(conv_w, conv_h));
Georgios Pinitase413d252018-11-14 18:29:58 +0000369 }
370 else
371 {
372 // Configure reshape layer
George Wort2d7e6832019-02-22 16:37:41 +0000373 _reshape_layer.configure(gemm_output_to_use, output);
Georgios Pinitase413d252018-11-14 18:29:58 +0000374 }
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100375 }
376
Georgios Pinitase413d252018-11-14 18:29:58 +0000377 if(_is_quantized && !_skip_col2im)
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100378 {
379 _tmp_output.allocator()->allocate();
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100380 }
381
Georgios Pinitasbb081ca2018-11-08 10:22:01 +0000382 if(!_skip_col2im || _is_quantized)
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100383 {
Michalis Spyroue2503892018-04-23 15:17:31 +0100384 _gemm_output.allocator()->allocate();
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000385 }
386
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100387 ARM_COMPUTE_ERROR_ON_MSG((output->info()->dimension(idx_width) != conv_w) || (output->info()->dimension(idx_height) != conv_h),
388 "Output shape does not match the expected one");
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000389}
390
391Status NEGEMMConvolutionLayer::validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info,
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100392 const WeightsInfo &weights_info, const Size2D &dilation, const ActivationLayerInfo &act_info, unsigned int num_groups)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000393{
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100394 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, weights, output);
395 ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights_info.are_reshaped(), "Weights already reshaped are not supported!");
Georgios Pinitasc7b183a2020-03-06 18:12:09 +0000396 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED, DataType::BFLOAT16, DataType::F16, DataType::F32);
397 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(weights, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED, DataType::QSYMM8_PER_CHANNEL, DataType::BFLOAT16, DataType::F16, DataType::F32);
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100398 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(input, weights);
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +0100399 ARM_COMPUTE_RETURN_ERROR_ON_MSG(num_groups > 1, "Grouping (num_groups != 1) is not supported on NEON");
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000400
Michalis Spyroue2503892018-04-23 15:17:31 +0100401 const DataLayout data_layout = input->data_layout();
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100402 const DataType data_type = input->data_type();
Michalis Spyroue2503892018-04-23 15:17:31 +0100403 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
404 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100405 const int idx_channel = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
406 const int idx_kernels = get_data_layout_dimension_index(data_layout, DataLayoutDimension::BATCHES);
Michalis Spyroue2503892018-04-23 15:17:31 +0100407
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100408 const unsigned int kernel_width = weights->dimension(idx_width);
409 const unsigned int kernel_height = weights->dimension(idx_height);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000410
Michalis Spyroua4f378d2019-04-26 14:54:54 +0100411 TensorInfo im2col_reshaped_info{};
412 TensorInfo info_gemm{};
413 TensorInfo tmp_info{};
414 TensorInfo weights_reshaped_info{};
George Wort2d7e6832019-02-22 16:37:41 +0000415 const ITensorInfo *gemm_input_to_use = input;
416 const ITensorInfo *gemm_output_to_use = output;
417 const ITensorInfo *weights_to_use = weights;
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +0000418
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100419 const bool append_bias = false;
420 const bool is_quantized = is_data_type_quantized_asymmetric(data_type);
421 bool skip_im2col = (data_layout == DataLayout::NHWC && kernel_width == 1 && kernel_height == 1 && conv_info.stride().first == 1 && conv_info.stride().second == 1);
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100422
423 // Get convolved dimensions
424 unsigned int conv_w = 0;
425 unsigned int conv_h = 0;
426
427 std::tie(conv_w, conv_h) = scaled_dimensions(input->dimension(idx_width),
428 input->dimension(idx_height),
429 kernel_width,
430 kernel_height,
431 conv_info,
432 dilation);
433
434 // Check if GEMM3D is supported
Georgios Pinitase413d252018-11-14 18:29:58 +0000435 bool skip_col2im = false;
436 if(data_layout == DataLayout::NHWC)
437 {
Giorgio Arena7a669a82019-11-13 17:07:13 +0000438 skip_col2im = bool(validate_gemm3d(input, weights, act_info, conv_h, true));
Georgios Pinitase413d252018-11-14 18:29:58 +0000439 // If not supported, we need to perform im2col and col2im (or reshape layer)
440 if(!skip_col2im)
441 {
442 skip_im2col = false;
443 }
444 }
445
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100446 if(skip_col2im)
447 {
448 // If not supported, we need to perform im2col and col2im (or reshape layer)
Giorgio Arena7a669a82019-11-13 17:07:13 +0000449 if(!bool(validate_gemm3d(input, weights, act_info, conv_h, skip_im2col)))
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100450 {
451 skip_im2col = false;
452 skip_col2im = false;
453 }
454 }
455
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100456 ARM_COMPUTE_RETURN_ERROR_ON(weights->dimension(idx_channel) != input->dimension(idx_channel));
457 ARM_COMPUTE_RETURN_ERROR_ON(weights->num_dimensions() > 4);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000458
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100459 // Validate biases
460 if(biases != nullptr)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000461 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100462 if(is_quantized)
463 {
464 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(biases, 1, DataType::S32);
465 }
466 else
467 {
468 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, biases);
469 }
470 ARM_COMPUTE_RETURN_ERROR_ON(biases->dimension(0) != weights->dimension(idx_kernels));
471 ARM_COMPUTE_RETURN_ERROR_ON(biases->num_dimensions() > 1);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000472 }
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000473
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100474 unsigned int mat_weights_cols = weights->dimension(idx_kernels);
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100475 unsigned int mat_weights_rows = weights->dimension(idx_width) * weights->dimension(idx_height) * weights->dimension(idx_channel);
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100476
477 // Output tensor auto inizialization if not yet initialized
Georgios Pinitas48b3ef82019-10-14 19:03:09 +0100478 ARM_COMPUTE_RETURN_ON_ERROR(NEConvolutionLayerReshapeWeights::validate(weights, nullptr, nullptr));
479 weights_reshaped_info = TensorInfo(compute_weights_reshaped_shape(*weights, append_bias), 1, data_type);
Georgios Pinitas4d600c72019-07-30 15:09:10 +0100480 weights_reshaped_info.set_quantization_info(weights->quantization_info());
Michalis Spyrou1a569a32019-09-10 17:20:34 +0100481 weights_to_use = &weights_reshaped_info;
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100482
Michalis Spyroue2503892018-04-23 15:17:31 +0100483 if(!skip_im2col)
484 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100485 // Create tensor info for im2col reshaped inputs
486 // For NEON the batch size is on the fourth dimension
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100487 // TODO (giaiod01): Auto-initialize the output shape of im2col COMPMID-1482
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100488 TensorShape shape_im2col = input->tensor_shape();
489 shape_im2col.set(0, mat_weights_rows);
490 shape_im2col.set(1, conv_w * conv_h);
491 shape_im2col.set(2, 1);
492
493 im2col_reshaped_info = TensorInfo(shape_im2col, 1, data_type);
494 im2col_reshaped_info.set_quantization_info(input->quantization_info());
495
Giorgio Arena0f170392018-07-18 16:13:12 +0100496 ARM_COMPUTE_RETURN_ON_ERROR(NEIm2ColKernel::validate(input, &im2col_reshaped_info, Size2D(kernel_width, kernel_height), conv_info, append_bias, dilation));
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100497 gemm_input_to_use = &im2col_reshaped_info;
Michalis Spyroue2503892018-04-23 15:17:31 +0100498 }
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000499
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100500 // Create temporary GEMM output tensor in case we cannot skip col2im
Georgios Pinitasc7b183a2020-03-06 18:12:09 +0000501 const DataType output_data_type = data_type == DataType::BFLOAT16 ? DataType::F32 : data_type;
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100502 if(!skip_col2im)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000503 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100504 TensorShape shape_gemm = gemm_input_to_use->tensor_shape();
505 shape_gemm.set(0, mat_weights_cols);
506 shape_gemm.set(1, conv_w * conv_h);
Georgios Pinitasc7b183a2020-03-06 18:12:09 +0000507 info_gemm = TensorInfo(shape_gemm, 1, output_data_type);
Michalis Spyroue2503892018-04-23 15:17:31 +0100508 }
Georgios Pinitasbb081ca2018-11-08 10:22:01 +0000509 else
510 {
Georgios Pinitasc7b183a2020-03-06 18:12:09 +0000511 info_gemm = TensorInfo(output->tensor_shape(), 1, output_data_type);
Georgios Pinitasbb081ca2018-11-08 10:22:01 +0000512 }
513 info_gemm.set_quantization_info(output->quantization_info()).set_data_layout(input->data_layout());
514 gemm_output_to_use = &info_gemm;
George Wort2d7e6832019-02-22 16:37:41 +0000515 ARM_COMPUTE_RETURN_ON_ERROR(validate_mm(gemm_input_to_use, weights_to_use, biases, gemm_output_to_use, act_info, skip_col2im ? conv_h : 0, skip_im2col));
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100516
Gian Marco Iodicedb9d46d2018-08-08 12:29:38 +0100517 // Validate Col2Im/ReshapeLayer
518 if(!skip_col2im && (data_layout == DataLayout::NCHW))
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100519 {
George Wort2d7e6832019-02-22 16:37:41 +0000520 ARM_COMPUTE_RETURN_ON_ERROR(NECol2ImKernel::validate(gemm_output_to_use, output, Size2D(conv_w, conv_h)));
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100521 }
522
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000523 return Status{};
524}
525
526void NEGEMMConvolutionLayer::run()
527{
Georgios Pinitas72219332018-06-05 14:56:06 +0100528 prepare();
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000529
Georgios Pinitasda953f22019-04-02 17:27:03 +0100530 MemoryGroupResourceScope scope_mg(_memory_group);
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000531
Michalis Spyroue2503892018-04-23 15:17:31 +0100532 if(!_skip_im2col)
533 {
534 // Run input reshaping
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100535 unsigned int y_dim = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
536 NEScheduler::get().schedule(&_im2col_kernel, y_dim);
Michalis Spyroue2503892018-04-23 15:17:31 +0100537 }
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000538
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100539 // Runs NEGEMM or NEGEMMLowpMatrixMultiplyCore functions
540 if(_is_quantized)
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000541 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100542 // Run gemmlowp
543 _mm_gemmlowp.run();
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000544 }
545 else
546 {
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100547 // Run gemm
548 _mm_gemm.run();
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000549 }
550
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000551 // Reshape output matrix
Georgios Pinitase413d252018-11-14 18:29:58 +0000552 if(!_skip_col2im)
Michalis Spyroue2503892018-04-23 15:17:31 +0100553 {
Georgios Pinitase413d252018-11-14 18:29:58 +0000554 if(_data_layout == DataLayout::NCHW)
555 {
556 NEScheduler::get().schedule(&_col2im_kernel, Window::DimY);
557 }
558 else
559 {
560 _reshape_layer.run();
561 }
Michalis Spyroue2503892018-04-23 15:17:31 +0100562 }
Isabella Gottardi6acc6ad2018-02-02 17:19:18 +0000563}
Georgios Pinitas72219332018-06-05 14:56:06 +0100564
565void NEGEMMConvolutionLayer::prepare()
566{
567 if(!_is_prepared)
568 {
Michalis Spyrou1a569a32019-09-10 17:20:34 +0100569 if(_weights_manager && _weights_manager->are_weights_managed(_original_weights))
570 {
571 _weights_manager->run(_original_weights, &_reshape_weights_managed);
572 }
573 else
574 {
575 // Run weights reshaping and mark original weights tensor as unused
576 _weights_reshaped.allocator()->allocate();
577 _reshape_weights.run();
578 _original_weights->mark_as_unused();
579 }
Georgios Pinitas72219332018-06-05 14:56:06 +0100580
Gian Marco Iodice597a8562018-08-01 15:06:06 +0100581 // Prepare GEMM
582 _is_quantized ? _mm_gemmlowp.prepare() : _mm_gemm.prepare();
Georgios Pinitas72219332018-06-05 14:56:06 +0100583 if(!_weights_reshaped.is_used())
584 {
585 _weights_reshaped.allocator()->free();
586 }
587
588 _is_prepared = true;
589 }
590}
Michalis Spyroue7be8a02019-12-12 16:16:09 +0000591} // namespace arm_compute