blob: d628bf93cec8e1956d25a95dfe5a514e183851be [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
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"
Gian Marco Iodice13edbff2017-06-26 17:20:16 +010027#include "arm_compute/core/Size2D.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Utils.h"
29#include "arm_compute/core/Validate.h"
Chunosov5124be52017-11-22 20:42:13 +070030#include "arm_compute/core/utils/quantization/AsymmHelpers.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031#include "arm_compute/runtime/CL/CLScheduler.h"
32
33#include <cmath>
Georgios Pinitasbaf174e2017-09-08 19:47:30 +010034#include <memory>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010035#include <tuple>
36
37using namespace arm_compute;
38
Georgios Pinitasbaf174e2017-09-08 19:47:30 +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 Barbier6ff3b192017-09-04 18:44:23 +010041{
42}
43
44void CLConvolutionLayerReshapeWeights::configure(const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, bool transpose1xW)
45{
Chunosov5124be52017-11-22 20:42:13 +070046 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(weights, 1, DataType::QS8, DataType::QASYMM8, DataType::QS16, DataType::F16, DataType::F32);
Gian Marco Iodice13edbff2017-06-26 17:20:16 +010047 ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(weights, output);
48 ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(weights, output);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010049 ARM_COMPUTE_ERROR_ON(weights->info()->num_dimensions() > 4);
50
51 if(biases != nullptr)
52 {
Chunosov5124be52017-11-22 20:42:13 +070053 ARM_COMPUTE_ERROR_ON(is_data_type_quantized_asymmetric(weights->info()->data_type()));
Anthony Barbier6ff3b192017-09-04 18:44:23 +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
Chunosov5124be52017-11-22 20:42:13 +070059 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 Barbier6ff3b192017-09-04 18:44:23 +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);
Chunosov5124be52017-11-22 20:42:13 +070069 const unsigned int mat_weights_rows = weights->info()->dimension(0) * weights->info()->dimension(1) * weights->info()->dimension(2) + bias_element;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010070 TensorShape shape_wr(mat_weights_cols, mat_weights_rows);
Gian Marco Iodice368da832017-07-03 12:33:49 +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 Barbier6ff3b192017-09-04 18:44:23 +010074
75 _weights_reshaped.allocator()->init(info_wr);
Georgios Pinitasbaf174e2017-09-08 19:47:30 +010076 _memory_group.manage(&_weights_reshaped);
Chunosov5124be52017-11-22 20:42:13 +070077 _weights_reshape_kernel.configure(weights, biases_to_use, &_weights_reshaped);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010078 _weights_transposed_kernel.configure(&_weights_reshaped, output);
79 _weights_reshaped.allocator()->allocate();
80 }
81 else
82 {
Chunosov5124be52017-11-22 20:42:13 +070083 _weights_reshape_kernel.configure(weights, biases_to_use, output);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010084 }
85}
86
87void CLConvolutionLayerReshapeWeights::run()
88{
Georgios Pinitasbaf174e2017-09-08 19:47:30 +010089 _memory_group.acquire();
90
Anthony Barbier6ff3b192017-09-04 18:44:23 +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 }
Georgios Pinitasbaf174e2017-09-08 19:47:30 +010097
98 _memory_group.release();
Anthony Barbier6ff3b192017-09-04 18:44:23 +010099}
100
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100101CLConvolutionLayer::CLConvolutionLayer(std::shared_ptr<IMemoryManager> memory_manager)
Chunosov5124be52017-11-22 20:42:13 +0700102 : _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 Barbier6ff3b192017-09-04 18:44:23 +0100105{
106}
107
Chunosov5124be52017-11-22 20:42:13 +0700108void 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 Barbier6ff3b192017-09-04 18:44:23 +0100132void CLConvolutionLayer::configure(const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info)
133{
Chunosov5124be52017-11-22 20:42:13 +0700134 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QS8, DataType::QASYMM8, DataType::QS16, DataType::F16, DataType::F32);
Gian Marco Iodice559d7712017-08-08 08:38:09 +0100135 ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, weights);
136 ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(input, weights);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100137 ARM_COMPUTE_ERROR_ON(!weights_info.are_reshaped() && weights->info()->dimension(2) != input->info()->dimension(2));
138 ARM_COMPUTE_ERROR_ON(weights->info()->num_dimensions() > 4);
Chunosov5124be52017-11-22 20:42:13 +0700139 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 Barbier6ff3b192017-09-04 18:44:23 +0100142
143 if(biases != nullptr)
144 {
Chunosov5124be52017-11-22 20:42:13 +0700145 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 }
Gian Marco Iodice368da832017-07-03 12:33:49 +0100153 ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(input, biases);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100154 ARM_COMPUTE_ERROR_ON(!weights_info.are_reshaped() && biases->info()->dimension(0) != weights->info()->dimension(3));
155 ARM_COMPUTE_ERROR_ON(biases->info()->num_dimensions() > 1);
156 }
157
Chunosov5124be52017-11-22 20:42:13 +0700158 const DataType dt = input->info()->data_type();
Gian Marco Iodice368da832017-07-03 12:33:49 +0100159
Gian Marco Iodice1246b632017-08-16 18:38:32 +0100160 // Set the GPU target for matrix multiply
161 _mm_kernel.set_target(CLScheduler::get().target());
162
Chunosov5124be52017-11-22 20:42:13 +0700163 _append_bias = (biases != nullptr) && (!_is_quantized);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100164 _are_weights_reshaped = weights_info.are_reshaped();
165
Chunosov5124be52017-11-22 20:42:13 +0700166 const unsigned bias_element = (_append_bias) ? 1 : 0;
167 const ICLTensor *biases_to_use = (_append_bias) ? biases : nullptr;
168
Gian Marco Iodice368da832017-07-03 12:33:49 +0100169 // Get parameters from conv_info
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100170 unsigned int stride_x = 0;
171 unsigned int stride_y = 0;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100172 std::tie(stride_x, stride_y) = conv_info.stride();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100173
174 // Get convolved dimensions
175 unsigned int conv_w = 0;
176 unsigned int conv_h = 0;
177
Gian Marco Iodice368da832017-07-03 12:33:49 +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);
Gian Marco Iodice4e288692017-06-27 11:41:59 +0100180 std::tie(conv_w, conv_h) = scaled_dimensions(input->info()->dimension(0), input->info()->dimension(1), kernel_width, kernel_height,
181 conv_info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100182
183 // Check if its a "fully connected" convolution
184 _is_fully_connected_convolution = ((conv_w == 1) && (conv_h == 1));
Chunosov5124be52017-11-22 20:42:13 +0700185 const bool run_interleaved = (!_is_fully_connected_convolution && !_is_quantized);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100186
Gian Marco Iodice368da832017-07-03 12:33:49 +0100187 unsigned int mat_weights_cols = weights->info()->dimension(3);
Chunosov5124be52017-11-22 20:42:13 +0700188 unsigned int mat_weights_rows = weights->info()->dimension(0) * weights->info()->dimension(1) * weights->info()->dimension(2) + bias_element;
Gian Marco Iodice368da832017-07-03 12:33:49 +0100189
190 // Reshape weights if needed
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100191 if(_are_weights_reshaped)
192 {
Gian Marco Iodice559d7712017-08-08 08:38:09 +0100193 mat_weights_cols = weights_info.num_kernels();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100194 const unsigned int quarter_reshaped_cols = weights->info()->dimension(0) / 4;
Chunosov5124be52017-11-22 20:42:13 +0700195 mat_weights_rows = quarter_reshaped_cols + bias_element;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100196 }
197 else
198 {
Chunosov5124be52017-11-22 20:42:13 +0700199 if(_is_fully_connected_convolution || _is_quantized)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100200 {
201 // Create tensor to store the reshaped weights
202 TensorShape shape_wr(mat_weights_cols, mat_weights_rows);
Chunosov5124be52017-11-22 20:42:13 +0700203 _weights_reshaped.allocator()->init(weights->info()->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(shape_wr));
204 _reshape_weights.configure(weights, biases_to_use, &_weights_reshaped, false /* 1xW transpose */);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100205 }
206 else
207 {
208 // Create tensor to store transposed weights
Gian Marco Iodice368da832017-07-03 12:33:49 +0100209 const float transpose_width = 16.0f / input->info()->element_size();
210 TensorShape shape_wt(mat_weights_rows * static_cast<unsigned int>(transpose_width), static_cast<unsigned int>(std::ceil(mat_weights_cols / transpose_width)));
Chunosov5124be52017-11-22 20:42:13 +0700211 _weights_reshaped.allocator()->init(weights->info()->clone()->set_is_resizable(true).reset_padding().set_tensor_shape(shape_wt));
212 _reshape_weights.configure(weights, biases_to_use, &_weights_reshaped, true /* 1xW transpose */);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100213 }
Chunosov5124be52017-11-22 20:42:13 +0700214 _weights_reshaped.info()->set_quantization_info(weights->info()->quantization_info());
Gian Marco Iodice368da832017-07-03 12:33:49 +0100215 weights = &_weights_reshaped;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100216 }
Gian Marco Iodice368da832017-07-03 12:33:49 +0100217
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100218 // Create tensor to store im2col reshaped inputs
Gian Marco Iodice368da832017-07-03 12:33:49 +0100219 const unsigned int mat_input_cols = mat_weights_rows;
220 const unsigned int mat_input_rows = conv_w * conv_h;
221 TensorShape shape_im2col = input->info()->tensor_shape();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100222 shape_im2col.set(0, mat_input_cols);
223 shape_im2col.set(1, mat_input_rows);
224 shape_im2col.set(2, 1);
Gian Marcobfa3b522017-12-12 10:08:38 +0000225 // FIXME: input->clone() doesn't work with subtensors for grouped convolutions.
226 TensorInfo im2col_reshaped_info(shape_im2col, 1, dt, input->info()->fixed_point_position());
227 im2col_reshaped_info.set_quantization_info(input->info()->quantization_info());
228 _input_im2col_reshaped.allocator()->init(im2col_reshaped_info);
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100229 _memory_group.manage(&_input_im2col_reshaped);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100230
231 // Create tensor (interleave) to prepare input tensor for GEMM
Chunosov5124be52017-11-22 20:42:13 +0700232 if(run_interleaved)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100233 {
234 TensorShape shape_interleaved = shape_im2col;
235 shape_interleaved.set(0, shape_interleaved.x() * 4);
Gian Marco Iodice368da832017-07-03 12:33:49 +0100236 shape_interleaved.set(1, std::ceil(shape_interleaved.y() / 4.f));
Gian Marcobfa3b522017-12-12 10:08:38 +0000237 // FIXME: input->clone() doesn't work with subtensors for grouped convolutions.
238 TensorInfo interleaved_info(shape_interleaved, 1, dt, input->info()->fixed_point_position());
239 interleaved_info.set_quantization_info(input->info()->quantization_info());
240 _input_interleaved_reshaped.allocator()->init(interleaved_info);
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100241 _memory_group.manage(&_input_interleaved_reshaped);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100242 }
243
244 // Create GEMM output tensor
245 TensorShape shape_gemm = _input_im2col_reshaped.info()->tensor_shape();
246 shape_gemm.set(0, mat_weights_cols);
247 shape_gemm.set(1, mat_input_rows);
Chunosov5124be52017-11-22 20:42:13 +0700248 const DataType gemm_data_type = _is_quantized ? DataType::S32 : dt;
249 // GEMM output should be S32 for acquiring raw integer accumulator without quantized postprocessing for quantized asymmetric input.
Gian Marcobfa3b522017-12-12 10:08:38 +0000250 // FIXME: input->clone() doesn't work with subtensors for grouped convolutions.
251 TensorInfo info_gemm(shape_gemm, 1, gemm_data_type, input->info()->fixed_point_position());
252 info_gemm.set_quantization_info(output->info()->quantization_info());
Chunosov5124be52017-11-22 20:42:13 +0700253 _gemm_output.allocator()->init(info_gemm);
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100254 _memory_group.manage(&_gemm_output);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100255
256 // Configure kernels
Anthony Barbierfcd52fb2017-11-28 10:31:43 +0000257 _input_im2col_kernel.set_target(CLScheduler::get().target());
Chunosov5124be52017-11-22 20:42:13 +0700258 _input_im2col_kernel.configure(input, &_input_im2col_reshaped, Size2D(kernel_width, kernel_height), conv_info, _append_bias);
Gian Marco Iodiceedfa9f42017-08-15 11:45:22 +0100259
260 // Configure matrix multiply
Chunosov5124be52017-11-22 20:42:13 +0700261 if(run_interleaved)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100262 {
Chunosov5124be52017-11-22 20:42:13 +0700263 _input_interleave_kernel.configure(&_input_im2col_reshaped, &_input_interleaved_reshaped);
264 configure_mm(&_input_interleaved_reshaped, weights, &_gemm_output);
265 _input_interleaved_reshaped.allocator()->allocate();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100266 }
267 else
268 {
Chunosov5124be52017-11-22 20:42:13 +0700269 configure_mm(&_input_im2col_reshaped, weights, &_gemm_output, false);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100270 }
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100271 _input_im2col_reshaped.allocator()->allocate();
Chunosov5124be52017-11-22 20:42:13 +0700272
273 // Configure output stage for quantized case
274 if(_is_quantized)
275 {
276 float multiplier = input->info()->quantization_info().scale * weights->info()->quantization_info().scale / output->info()->quantization_info().scale;
277 int output_multiplier, output_shift;
278 quantization::calculate_quantized_multiplier_less_than_one(multiplier, &output_multiplier, &output_shift);
279 _gemmlowp_output_stage.configure(&_gemm_output, biases, &_tmp_output, output_multiplier, output_shift, output->info()->quantization_info().offset);
280 _gemm_output.allocator()->allocate();
281 }
282
283 // Configure Col2Im
Anthony Barbierfcd52fb2017-11-28 10:31:43 +0000284 _output_col2im_kernel.set_target(CLScheduler::get().target());
Chunosov5124be52017-11-22 20:42:13 +0700285 _output_col2im_kernel.configure(_is_quantized ? &_tmp_output : &_gemm_output, output, std::make_pair(conv_w, conv_h));
286 if(_is_quantized)
287 {
288 _tmp_output.allocator()->allocate();
289 }
290 else
291 {
292 _gemm_output.allocator()->allocate();
293 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100294
Gian Marco Iodice559d7712017-08-08 08:38:09 +0100295 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");
296
Gian Marco Iodice368da832017-07-03 12:33:49 +0100297 // Allocate intermediate tensor
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100298 if(!_are_weights_reshaped)
299 {
Gian Marco Iodice368da832017-07-03 12:33:49 +0100300 _weights_reshaped.allocator()->allocate();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100301 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100302}
303
304void CLConvolutionLayer::run()
305{
306 // Run weights reshaping (Runs once for every configure)
307 if(!_are_weights_reshaped)
308 {
309 _are_weights_reshaped = true;
310 _reshape_weights.run();
311 }
312
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100313 _memory_group.acquire();
314
Chunosov5124be52017-11-22 20:42:13 +0700315 // Run im2col
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100316 CLScheduler::get().enqueue(_input_im2col_kernel);
Chunosov5124be52017-11-22 20:42:13 +0700317
318 if(!_is_fully_connected_convolution && !_is_quantized)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100319 {
Chunosov5124be52017-11-22 20:42:13 +0700320 // Run interleave4x4
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100321 CLScheduler::get().enqueue(_input_interleave_kernel);
322 }
323
324 // Runs matrix multiply on reshaped matrices
Chunosov5124be52017-11-22 20:42:13 +0700325 if(_is_quantized)
326 {
327 _mm_gemmlowp.run();
328 }
329 else
330 {
331 CLScheduler::get().enqueue(_mm_kernel);
332 }
333
334 // Run output stage for quantized case
335 if(_is_quantized)
336 {
337 _gemmlowp_output_stage.run();
338 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100339
340 // Reshape output matrix
341 CLScheduler::get().enqueue(_output_col2im_kernel, false);
Georgios Pinitasbaf174e2017-09-08 19:47:30 +0100342
343 _memory_group.release();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100344}