blob: 0ed3351825eb305f2d04aa7c14aa6c718f12758f [file] [log] [blame]
Anthony Barbier871448e2017-03-24 14:54:29 +00001/*
2 * Copyright (c) 2017 ARM Limited.
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 */
24#include "arm_compute/runtime/CL/functions/CLConvolutionLayer.h"
25
26#include "arm_compute/core/PixelValue.h"
Kaizen8938bd32017-09-28 14:38:23 +010027#include "arm_compute/core/Size2D.h"
Anthony Barbier871448e2017-03-24 14:54:29 +000028#include "arm_compute/core/Utils.h"
29#include "arm_compute/core/Validate.h"
Anthony Barbier8140e1e2017-12-14 23:48:46 +000030#include "arm_compute/core/utils/quantization/AsymmHelpers.h"
Anthony Barbier871448e2017-03-24 14:54:29 +000031#include "arm_compute/runtime/CL/CLScheduler.h"
32
33#include <cmath>
Kaizen8938bd32017-09-28 14:38:23 +010034#include <memory>
Anthony Barbier871448e2017-03-24 14:54:29 +000035#include <tuple>
36
37using namespace arm_compute;
38
Kaizen8938bd32017-09-28 14:38:23 +010039CLConvolutionLayerReshapeWeights::CLConvolutionLayerReshapeWeights(std::shared_ptr<IMemoryManager> memory_manager)
40 : _memory_group(std::move(memory_manager)), _weights_reshape_kernel(), _weights_transposed_kernel(), _weights_reshaped(), _transpose1xW(false)
Anthony Barbier871448e2017-03-24 14:54:29 +000041{
42}
43
Anthony Barbierdbdab852017-06-23 15:42:00 +010044void CLConvolutionLayerReshapeWeights::configure(const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, bool transpose1xW)
45{
Anthony Barbier8140e1e2017-12-14 23:48:46 +000046 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(weights, 1, DataType::QS8, DataType::QASYMM8, DataType::QS16, DataType::F16, DataType::F32);
Kaizen8938bd32017-09-28 14:38:23 +010047 ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(weights, output);
48 ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(weights, output);
Anthony Barbierdbdab852017-06-23 15:42:00 +010049 ARM_COMPUTE_ERROR_ON(weights->info()->num_dimensions() > 4);
50
51 if(biases != nullptr)
52 {
Anthony Barbier8140e1e2017-12-14 23:48:46 +000053 ARM_COMPUTE_ERROR_ON(is_data_type_quantized_asymmetric(weights->info()->data_type()));
Anthony Barbierdbdab852017-06-23 15:42:00 +010054 ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(weights, biases);
55 ARM_COMPUTE_ERROR_ON(biases->info()->dimension(0) != weights->info()->dimension(3));
56 ARM_COMPUTE_ERROR_ON(biases->info()->num_dimensions() > 1);
57 }
58
Anthony Barbier8140e1e2017-12-14 23:48:46 +000059 const bool append_biases = (biases != nullptr) && !is_data_type_quantized_asymmetric(weights->info()->data_type());
60 const unsigned bias_element = (append_biases) ? 1 : 0;
61 const ICLTensor *biases_to_use = (append_biases) ? biases : nullptr;
Anthony Barbierdbdab852017-06-23 15:42:00 +010062
63 _transpose1xW = transpose1xW;
64
65 if(transpose1xW)
66 {
67 // Create tensor to store the reshaped weights
68 const unsigned int mat_weights_cols = weights->info()->dimension(3);
Anthony Barbier8140e1e2017-12-14 23:48:46 +000069 const unsigned int mat_weights_rows = weights->info()->dimension(0) * weights->info()->dimension(1) * weights->info()->dimension(2) + bias_element;
Anthony Barbierdbdab852017-06-23 15:42:00 +010070 TensorShape shape_wr(mat_weights_cols, mat_weights_rows);
Kaizen8938bd32017-09-28 14:38:23 +010071 const DataType dt = weights->info()->data_type();
72 const int fixed_point_position = weights->info()->fixed_point_position();
73 TensorInfo info_wr(shape_wr, 1, dt, fixed_point_position);
Anthony Barbierdbdab852017-06-23 15:42:00 +010074
75 _weights_reshaped.allocator()->init(info_wr);
Kaizen8938bd32017-09-28 14:38:23 +010076 _memory_group.manage(&_weights_reshaped);
Anthony Barbier8140e1e2017-12-14 23:48:46 +000077 _weights_reshape_kernel.configure(weights, biases_to_use, &_weights_reshaped);
Anthony Barbierdbdab852017-06-23 15:42:00 +010078 _weights_transposed_kernel.configure(&_weights_reshaped, output);
79 _weights_reshaped.allocator()->allocate();
80 }
81 else
82 {
Anthony Barbier8140e1e2017-12-14 23:48:46 +000083 _weights_reshape_kernel.configure(weights, biases_to_use, output);
Anthony Barbierdbdab852017-06-23 15:42:00 +010084 }
85}
86
87void CLConvolutionLayerReshapeWeights::run()
88{
Kaizen8938bd32017-09-28 14:38:23 +010089 _memory_group.acquire();
90
Anthony Barbierdbdab852017-06-23 15:42:00 +010091 cl::CommandQueue q = CLScheduler::get().queue();
92 CLScheduler::get().enqueue(_weights_reshape_kernel);
93 if(_transpose1xW)
94 {
95 CLScheduler::get().enqueue(_weights_transposed_kernel);
96 }
Kaizen8938bd32017-09-28 14:38:23 +010097
98 _memory_group.release();
Anthony Barbierdbdab852017-06-23 15:42:00 +010099}
100
Kaizen8938bd32017-09-28 14:38:23 +0100101CLConvolutionLayer::CLConvolutionLayer(std::shared_ptr<IMemoryManager> memory_manager)
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000102 : _memory_group(memory_manager), _reshape_weights(), _input_im2col_kernel(), _input_interleave_kernel(), _mm_kernel(), _mm_gemmlowp(memory_manager), _gemmlowp_output_stage(), _output_col2im_kernel(),
103 _input_im2col_reshaped(), _input_interleaved_reshaped(), _weights_reshaped(), _weights_transposed(), _gemm_output(), _tmp_output(), _append_bias(false), _is_fully_connected_convolution(false),
104 _are_weights_reshaped(false), _is_quantized(false)
Anthony Barbierdbdab852017-06-23 15:42:00 +0100105{
106}
107
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000108void CLConvolutionLayer::configure_mm(const ICLTensor *input, const ICLTensor *weights, ICLTensor *output, bool is_interleaved_transposed)
109{
110 if(_is_quantized)
111 {
112 // Since we need negative offsets for computing convolution, we need to change QuantizationInfo()
113 // Extract and negate input and weights offset
114 const QuantizationInfo input_quantization_info = input->info()->quantization_info();
115 const QuantizationInfo weights_quantization_info = weights->info()->quantization_info();
116
117 input->info()->set_quantization_info(QuantizationInfo(input_quantization_info.scale, -input_quantization_info.offset));
118 weights->info()->set_quantization_info(QuantizationInfo(weights_quantization_info.scale, -weights_quantization_info.offset));
119
120 _mm_gemmlowp.configure(input, weights, output, GEMMInfo(false, false, true /* Reshape weights only for the first run*/));
121
122 // Revert back QuantizatioInfo as input and weights could be used in other convolution layers
123 input->info()->set_quantization_info(input_quantization_info);
124 weights->info()->set_quantization_info(weights_quantization_info);
125 }
126 else
127 {
128 _mm_kernel.configure(input, weights, output, 1.f, is_interleaved_transposed);
129 }
130}
131
Anthony Barbierdbdab852017-06-23 15:42:00 +0100132void CLConvolutionLayer::configure(const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info)
Anthony Barbier871448e2017-03-24 14:54:29 +0000133{
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000134 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QS8, DataType::QASYMM8, DataType::QS16, DataType::F16, DataType::F32);
Kaizen8938bd32017-09-28 14:38:23 +0100135 ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, weights);
136 ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(input, weights);
Anthony Barbierdbdab852017-06-23 15:42:00 +0100137 ARM_COMPUTE_ERROR_ON(!weights_info.are_reshaped() && weights->info()->dimension(2) != input->info()->dimension(2));
Anthony Barbier871448e2017-03-24 14:54:29 +0000138 ARM_COMPUTE_ERROR_ON(weights->info()->num_dimensions() > 4);
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000139 ARM_COMPUTE_ERROR_ON(weights_info.are_reshaped() && is_data_type_quantized_asymmetric(input->info()->data_type()));
140
141 _is_quantized = is_data_type_quantized_asymmetric(input->info()->data_type());
Anthony Barbier871448e2017-03-24 14:54:29 +0000142
143 if(biases != nullptr)
144 {
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000145 if(_is_quantized)
146 {
147 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(biases, 1, DataType::S32);
148 }
149 else
150 {
151 ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, biases);
152 }
Kaizen8938bd32017-09-28 14:38:23 +0100153 ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(input, biases);
Anthony Barbierdbdab852017-06-23 15:42:00 +0100154 ARM_COMPUTE_ERROR_ON(!weights_info.are_reshaped() && biases->info()->dimension(0) != weights->info()->dimension(3));
Anthony Barbier871448e2017-03-24 14:54:29 +0000155 ARM_COMPUTE_ERROR_ON(biases->info()->num_dimensions() > 1);
156 }
157
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000158 const DataType dt = input->info()->data_type();
Kaizen8938bd32017-09-28 14:38:23 +0100159
160 // Set the GPU target for matrix multiply
161 _mm_kernel.set_target(CLScheduler::get().target());
162
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000163 _append_bias = (biases != nullptr) && (!_is_quantized);
Anthony Barbierdbdab852017-06-23 15:42:00 +0100164 _are_weights_reshaped = weights_info.are_reshaped();
Anthony Barbier871448e2017-03-24 14:54:29 +0000165
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000166 const unsigned bias_element = (_append_bias) ? 1 : 0;
167 const ICLTensor *biases_to_use = (_append_bias) ? biases : nullptr;
168
Kaizen8938bd32017-09-28 14:38:23 +0100169 // Get parameters from conv_info
Anthony Barbierdbdab852017-06-23 15:42:00 +0100170 unsigned int stride_x = 0;
171 unsigned int stride_y = 0;
Anthony Barbier871448e2017-03-24 14:54:29 +0000172 std::tie(stride_x, stride_y) = conv_info.stride();
Anthony Barbier871448e2017-03-24 14:54:29 +0000173
Anthony Barbier871448e2017-03-24 14:54:29 +0000174 // Get convolved dimensions
175 unsigned int conv_w = 0;
176 unsigned int conv_h = 0;
Anthony Barbierdbdab852017-06-23 15:42:00 +0100177
Kaizen8938bd32017-09-28 14:38:23 +0100178 const unsigned int kernel_width = (_are_weights_reshaped) ? weights_info.kernel_size().first : weights->info()->dimension(0);
179 const unsigned int kernel_height = (_are_weights_reshaped) ? weights_info.kernel_size().second : weights->info()->dimension(1);
180 std::tie(conv_w, conv_h) = scaled_dimensions(input->info()->dimension(0), input->info()->dimension(1), kernel_width, kernel_height,
181 conv_info);
Anthony Barbier871448e2017-03-24 14:54:29 +0000182
Anthony Barbierdbdab852017-06-23 15:42:00 +0100183 // Check if its a "fully connected" convolution
184 _is_fully_connected_convolution = ((conv_w == 1) && (conv_h == 1));
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000185 const bool run_interleaved = (!_is_fully_connected_convolution && !_is_quantized);
Anthony Barbierdbdab852017-06-23 15:42:00 +0100186
Kaizen8938bd32017-09-28 14:38:23 +0100187 unsigned int mat_weights_cols = weights->info()->dimension(3);
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000188 unsigned int mat_weights_rows = weights->info()->dimension(0) * weights->info()->dimension(1) * weights->info()->dimension(2) + bias_element;
Kaizen8938bd32017-09-28 14:38:23 +0100189
190 // Reshape weights if needed
Anthony Barbierdbdab852017-06-23 15:42:00 +0100191 if(_are_weights_reshaped)
192 {
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000193 if(_is_fully_connected_convolution || _is_quantized)
194 {
195 mat_weights_cols = weights->info()->dimension(0);
196 mat_weights_rows = weights->info()->dimension(1);
197 }
198 else
199 {
200 mat_weights_cols = weights_info.num_kernels();
201 const unsigned int quarter_reshaped_cols = weights->info()->dimension(0) / 4;
202 mat_weights_rows = quarter_reshaped_cols + bias_element;
203 }
Anthony Barbierdbdab852017-06-23 15:42:00 +0100204 }
205 else
206 {
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000207 if(_is_fully_connected_convolution || _is_quantized)
Anthony Barbierdbdab852017-06-23 15:42:00 +0100208 {
209 // Create tensor to store the reshaped weights
210 TensorShape shape_wr(mat_weights_cols, mat_weights_rows);
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000211 _weights_reshaped.allocator()->init(weights->info()->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(shape_wr));
212 _reshape_weights.configure(weights, biases_to_use, &_weights_reshaped, false /* 1xW transpose */);
Anthony Barbierdbdab852017-06-23 15:42:00 +0100213 }
214 else
215 {
216 // Create tensor to store transposed weights
Kaizen8938bd32017-09-28 14:38:23 +0100217 const float transpose_width = 16.0f / input->info()->element_size();
218 TensorShape shape_wt(mat_weights_rows * static_cast<unsigned int>(transpose_width), static_cast<unsigned int>(std::ceil(mat_weights_cols / transpose_width)));
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000219 _weights_reshaped.allocator()->init(weights->info()->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(shape_wt));
220 _reshape_weights.configure(weights, biases_to_use, &_weights_reshaped, true /* 1xW transpose */);
Anthony Barbierdbdab852017-06-23 15:42:00 +0100221 }
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000222 _weights_reshaped.info()->set_quantization_info(weights->info()->quantization_info());
Kaizen8938bd32017-09-28 14:38:23 +0100223 weights = &_weights_reshaped;
Anthony Barbierdbdab852017-06-23 15:42:00 +0100224 }
Kaizen8938bd32017-09-28 14:38:23 +0100225
Anthony Barbier871448e2017-03-24 14:54:29 +0000226 // Create tensor to store im2col reshaped inputs
Kaizen8938bd32017-09-28 14:38:23 +0100227 const unsigned int mat_input_cols = mat_weights_rows;
228 const unsigned int mat_input_rows = conv_w * conv_h;
229 TensorShape shape_im2col = input->info()->tensor_shape();
Anthony Barbier871448e2017-03-24 14:54:29 +0000230 shape_im2col.set(0, mat_input_cols);
231 shape_im2col.set(1, mat_input_rows);
232 shape_im2col.set(2, 1);
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000233 TensorInfo im2col_reshaped_info(shape_im2col, 1, dt, input->info()->fixed_point_position());
234 im2col_reshaped_info.set_quantization_info(input->info()->quantization_info());
235 _input_im2col_reshaped.allocator()->init(im2col_reshaped_info);
Kaizen8938bd32017-09-28 14:38:23 +0100236 _memory_group.manage(&_input_im2col_reshaped);
Anthony Barbier871448e2017-03-24 14:54:29 +0000237
Anthony Barbierdbdab852017-06-23 15:42:00 +0100238 // Create tensor (interleave) to prepare input tensor for GEMM
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000239 if(run_interleaved)
Anthony Barbierdbdab852017-06-23 15:42:00 +0100240 {
241 TensorShape shape_interleaved = shape_im2col;
242 shape_interleaved.set(0, shape_interleaved.x() * 4);
Kaizen8938bd32017-09-28 14:38:23 +0100243 shape_interleaved.set(1, std::ceil(shape_interleaved.y() / 4.f));
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000244 TensorInfo interleaved_info(shape_interleaved, 1, dt, input->info()->fixed_point_position());
245 interleaved_info.set_quantization_info(input->info()->quantization_info());
246 _input_interleaved_reshaped.allocator()->init(interleaved_info);
Kaizen8938bd32017-09-28 14:38:23 +0100247 _memory_group.manage(&_input_interleaved_reshaped);
Anthony Barbierdbdab852017-06-23 15:42:00 +0100248 }
Anthony Barbier871448e2017-03-24 14:54:29 +0000249
250 // Create GEMM output tensor
251 TensorShape shape_gemm = _input_im2col_reshaped.info()->tensor_shape();
252 shape_gemm.set(0, mat_weights_cols);
253 shape_gemm.set(1, mat_input_rows);
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000254 const DataType gemm_data_type = _is_quantized ? DataType::S32 : dt;
255 // GEMM output should be S32 for acquiring raw integer accumulator without quantized postprocessing for quantized asymmetric input.
256 TensorInfo info_gemm(shape_gemm, 1, gemm_data_type, input->info()->fixed_point_position());
257 info_gemm.set_quantization_info(output->info()->quantization_info());
258 _gemm_output.allocator()->init(info_gemm);
Kaizen8938bd32017-09-28 14:38:23 +0100259 _memory_group.manage(&_gemm_output);
Anthony Barbier871448e2017-03-24 14:54:29 +0000260
261 // Configure kernels
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000262 _input_im2col_kernel.set_target(CLScheduler::get().target());
263 _input_im2col_kernel.configure(input, &_input_im2col_reshaped, Size2D(kernel_width, kernel_height), conv_info, _append_bias);
Anthony Barbierdbdab852017-06-23 15:42:00 +0100264
Kaizen8938bd32017-09-28 14:38:23 +0100265 // Configure matrix multiply
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000266 if(run_interleaved)
Anthony Barbier871448e2017-03-24 14:54:29 +0000267 {
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000268 _input_interleave_kernel.configure(&_input_im2col_reshaped, &_input_interleaved_reshaped);
269 configure_mm(&_input_interleaved_reshaped, weights, &_gemm_output);
270 _input_interleaved_reshaped.allocator()->allocate();
Anthony Barbier871448e2017-03-24 14:54:29 +0000271 }
272 else
273 {
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000274 configure_mm(&_input_im2col_reshaped, weights, &_gemm_output, false);
Anthony Barbierdbdab852017-06-23 15:42:00 +0100275 }
Kaizen8938bd32017-09-28 14:38:23 +0100276 _input_im2col_reshaped.allocator()->allocate();
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000277
278 // Configure output stage for quantized case
279 if(_is_quantized)
280 {
281 float multiplier = input->info()->quantization_info().scale * weights->info()->quantization_info().scale / output->info()->quantization_info().scale;
282 int output_multiplier, output_shift;
283 quantization::calculate_quantized_multiplier_less_than_one(multiplier, &output_multiplier, &output_shift);
284 _gemmlowp_output_stage.configure(&_gemm_output, biases, &_tmp_output, output_multiplier, output_shift, output->info()->quantization_info().offset);
285 _gemm_output.allocator()->allocate();
286 }
287
288 // Configure Col2Im
289 _output_col2im_kernel.set_target(CLScheduler::get().target());
290 _output_col2im_kernel.configure(_is_quantized ? &_tmp_output : &_gemm_output, output, std::make_pair(conv_w, conv_h));
291 if(_is_quantized)
292 {
293 _tmp_output.allocator()->allocate();
294 }
295 else
296 {
297 _gemm_output.allocator()->allocate();
298 }
Kaizen8938bd32017-09-28 14:38:23 +0100299
300 ARM_COMPUTE_ERROR_ON_MSG((output->info()->dimension(0) != conv_w) || (output->info()->dimension(1) != conv_h), "Output shape does not match the expected one");
301
302 // Allocate intermediate tensor
303 if(!_are_weights_reshaped)
304 {
305 _weights_reshaped.allocator()->allocate();
306 }
Anthony Barbier871448e2017-03-24 14:54:29 +0000307}
308
309void CLConvolutionLayer::run()
310{
311 // Run weights reshaping (Runs once for every configure)
Anthony Barbierdbdab852017-06-23 15:42:00 +0100312 if(!_are_weights_reshaped)
Anthony Barbier871448e2017-03-24 14:54:29 +0000313 {
Anthony Barbierdbdab852017-06-23 15:42:00 +0100314 _are_weights_reshaped = true;
315 _reshape_weights.run();
Anthony Barbier871448e2017-03-24 14:54:29 +0000316 }
317
Kaizen8938bd32017-09-28 14:38:23 +0100318 _memory_group.acquire();
319
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000320 // Run im2col
Anthony Barbier871448e2017-03-24 14:54:29 +0000321 CLScheduler::get().enqueue(_input_im2col_kernel);
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000322
323 if(!_is_fully_connected_convolution && !_is_quantized)
Anthony Barbierdbdab852017-06-23 15:42:00 +0100324 {
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000325 // Run interleave4x4
Anthony Barbierdbdab852017-06-23 15:42:00 +0100326 CLScheduler::get().enqueue(_input_interleave_kernel);
327 }
Anthony Barbier871448e2017-03-24 14:54:29 +0000328
329 // Runs matrix multiply on reshaped matrices
Anthony Barbier8140e1e2017-12-14 23:48:46 +0000330 if(_is_quantized)
331 {
332 _mm_gemmlowp.run();
333 }
334 else
335 {
336 CLScheduler::get().enqueue(_mm_kernel);
337 }
338
339 // Run output stage for quantized case
340 if(_is_quantized)
341 {
342 _gemmlowp_output_stage.run();
343 }
Anthony Barbier871448e2017-03-24 14:54:29 +0000344
345 // Reshape output matrix
Anthony Barbierdbdab852017-06-23 15:42:00 +0100346 CLScheduler::get().enqueue(_output_col2im_kernel, false);
Kaizen8938bd32017-09-28 14:38:23 +0100347
348 _memory_group.release();
Anthony Barbier871448e2017-03-24 14:54:29 +0000349}