blob: 2d4d231f5f4327443b772288a5406f2f6b2e44d1 [file] [log] [blame]
Gian Marco05288a22017-11-21 10:57:50 +00001/*
Gian Marco7b4d5472018-01-10 15:56:30 +00002 * Copyright (c) 2017-2018 ARM Limited.
Gian Marco05288a22017-11-21 10:57:50 +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/CL/functions/CLGEMMLowpMatrixMultiplyCore.h"
25
26#include "arm_compute/core/CL/ICLTensor.h"
27#include "arm_compute/core/Error.h"
28#include "arm_compute/core/Helpers.h"
29#include "arm_compute/core/TensorInfo.h"
30#include "arm_compute/core/Types.h"
31#include "arm_compute/core/Validate.h"
Georgios Pinitas358ca202017-12-07 16:47:52 +000032#include "arm_compute/core/utils/misc/ShapeCalculator.h"
Gian Marco05288a22017-11-21 10:57:50 +000033#include "arm_compute/runtime/CL/CLScheduler.h"
34
35using namespace arm_compute;
Georgios Pinitas358ca202017-12-07 16:47:52 +000036using namespace arm_compute::misc::shape_calculator;
Gian Marco05288a22017-11-21 10:57:50 +000037
Gian Marco19835e52018-01-30 13:35:54 +000038namespace
39{
40inline bool is_interleaved_transposed(int m, int n, int k, bool reshape_b_only_on_first_run, GPUTarget gpu_target)
41{
42 bool flag = true;
43
Georgios Pinitasa34286e2018-09-04 12:18:50 +010044 if(gpu_target_is_in(gpu_target,
Gian Marco Iodice4b908652018-10-18 10:21:02 +010045 GPUTarget::G71, GPUTarget::G72,
Gian Marco Iodicee059f4f2018-11-15 15:21:17 +000046 GPUTarget::G51, GPUTarget::G51BIG, GPUTarget::G51LIT))
Gian Marco19835e52018-01-30 13:35:54 +000047 {
48 // COMPMID-852
49 if(k > 256 && m > 4 && reshape_b_only_on_first_run)
50 {
51 flag = ((0.72f + n * 0.10766f) < (n * 0.1284f));
52 }
53 else
54 {
55 flag = false;
56 }
57 }
Gian Marco Iodice4b908652018-10-18 10:21:02 +010058 else
59 {
60 flag = m > 1;
61 }
Gian Marco19835e52018-01-30 13:35:54 +000062
63 return flag;
64}
65} // namespace
66
Gian Marco05288a22017-11-21 10:57:50 +000067CLGEMMLowpMatrixMultiplyCore::CLGEMMLowpMatrixMultiplyCore(std::shared_ptr<IMemoryManager> memory_manager)
Georgios Pinitas72219332018-06-05 14:56:06 +010068 : _memory_group(std::move(memory_manager)),
69 _mm_kernel(),
70 _mtx_a_reshape_kernel(),
71 _mtx_b_reshape_kernel(),
72 _mtx_a_reduction_kernel(),
73 _mtx_b_reduction_kernel(),
74 _offset_contribution_kernel(),
Gian Marco Iodice4b908652018-10-18 10:21:02 +010075 _offset_contribution_output_stage_kernel(),
Georgios Pinitas72219332018-06-05 14:56:06 +010076 _vector_sum_col(),
77 _vector_sum_row(),
78 _tmp_a(),
79 _tmp_b(),
Gian Marco Iodice4b908652018-10-18 10:21:02 +010080 _mm_result_s32(),
Georgios Pinitas72219332018-06-05 14:56:06 +010081 _original_b(nullptr),
82 _a_offset(0),
83 _b_offset(0),
84 _is_interleaved_transposed(true),
85 _reshape_b_only_on_first_run(false),
Gian Marco Iodice4b908652018-10-18 10:21:02 +010086 _is_prepared(false),
87 _fuse_output_stage(false)
Gian Marco05288a22017-11-21 10:57:50 +000088{
89}
90
Gian Marco Iodice4b908652018-10-18 10:21:02 +010091void CLGEMMLowpMatrixMultiplyCore::configure(const ICLTensor *a, const ICLTensor *b, const ICLTensor *c, ICLTensor *output, const GEMMInfo &gemm_info)
Gian Marco05288a22017-11-21 10:57:50 +000092{
Georgios Pinitas358ca202017-12-07 16:47:52 +000093 ARM_COMPUTE_ERROR_ON_NULLPTR(a, b, output);
Gian Marco Iodice4b908652018-10-18 10:21:02 +010094 ARM_COMPUTE_ERROR_THROW_ON(CLGEMMLowpMatrixMultiplyCore::validate(a->info(), b->info(), c != nullptr ? c->info() : nullptr, output->info(), gemm_info));
Gian Marco05288a22017-11-21 10:57:50 +000095
Georgios Pinitas72219332018-06-05 14:56:06 +010096 _is_prepared = false;
97 _original_b = b;
Chunosov5124be52017-11-22 20:42:13 +070098 _reshape_b_only_on_first_run = gemm_info.reshape_b_only_on_first_run();
99 _a_offset = a->info()->quantization_info().offset;
100 _b_offset = b->info()->quantization_info().offset;
Gian Marco05288a22017-11-21 10:57:50 +0000101
Gian Marco19835e52018-01-30 13:35:54 +0000102 // Get the GPU target
103 const GPUTarget gpu_target = CLScheduler::get().target();
Gian Marco7b4d5472018-01-10 15:56:30 +0000104
Gian Marco19835e52018-01-30 13:35:54 +0000105 // Set the target for the kernels
106 _mtx_a_reshape_kernel.set_target(gpu_target);
107 _mm_kernel.set_target(gpu_target);
Gian Marco05288a22017-11-21 10:57:50 +0000108
109 const ICLTensor *matrix_a = a;
110 const ICLTensor *matrix_b = b;
111
Gian Marco19835e52018-01-30 13:35:54 +0000112 // Arguments used by GEMMReshapeInfo
113 // If we pass the matrix A and matrix B reshaped to CLGEMMMatrixMultiplyKernel, we need to pass m, n, k, mult_transpose1xW_width and mult_interleave4x4_height to CLGEMMReshapeInfo
114 // in order to know how the matrices have been reshaped
Georgios Pinitasebf6b8a2018-09-24 16:31:08 +0100115 bool reinterpret_input_as_3d = gemm_info.reinterpret_input_as_3d();
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100116 const bool unroll_block = dot8_supported(CLKernelLibrary::get().get_device());
Isabella Gottardic4f582e2018-10-11 19:14:55 +0100117 const int m = reinterpret_input_as_3d ? (a->info()->dimension(1) * a->info()->dimension(2)) : a->info()->dimension(1);
Gian Marco19835e52018-01-30 13:35:54 +0000118 const int n = b->info()->dimension(0);
119 const int k = a->info()->dimension(0);
Georgios Pinitasebf6b8a2018-09-24 16:31:08 +0100120 const int depth_output_gemm3d = gemm_info.depth_output_gemm3d();
Gian Marco19835e52018-01-30 13:35:54 +0000121 constexpr int mult_transpose1xW_width = 1;
122 constexpr int mult_interleave4x4_height = 1;
123
124 // Check if we need to reshape the matrix A and matrix B
125 _is_interleaved_transposed = is_interleaved_transposed(m, n, k, _reshape_b_only_on_first_run, gpu_target);
126
Georgios Pinitasebf6b8a2018-09-24 16:31:08 +0100127 if(_is_interleaved_transposed)
128 {
Isabella Gottardif02e5272018-10-01 12:26:28 +0100129 // if _is_interleaved_transposed is set, force reinterpret_input_as_3d to be false as the output of CLGEMMInterleaveKernel will be 2D
Georgios Pinitasebf6b8a2018-09-24 16:31:08 +0100130 reinterpret_input_as_3d = false;
Georgios Pinitasebf6b8a2018-09-24 16:31:08 +0100131
Gian Marco05288a22017-11-21 10:57:50 +0000132 matrix_a = &_tmp_a;
133 matrix_b = &_tmp_b;
134
Gian Marco05288a22017-11-21 10:57:50 +0000135 _memory_group.manage(&_tmp_a);
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100136 if(!_reshape_b_only_on_first_run)
137 {
138 _memory_group.manage(&_tmp_b);
139 }
Gian Marco05288a22017-11-21 10:57:50 +0000140
141 // Configure interleave kernel
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100142 _mtx_a_reshape_kernel.configure(a, &_tmp_a, mult_interleave4x4_height, gemm_info.reinterpret_input_as_3d(), unroll_block);
Gian Marco05288a22017-11-21 10:57:50 +0000143
144 // Configure transpose kernel
Gian Marco19835e52018-01-30 13:35:54 +0000145 _mtx_b_reshape_kernel.configure(b, &_tmp_b, mult_transpose1xW_width);
Gian Marco05288a22017-11-21 10:57:50 +0000146 }
Gian Marco05288a22017-11-21 10:57:50 +0000147
148 // Initialize matrix B reduction kernel only if _a_offset is not equal to 0
149 if(_a_offset != 0)
150 {
Georgios Pinitas358ca202017-12-07 16:47:52 +0000151 TensorInfo info_vector_sum_col(compute_reductionA_shape(*b->info()), 1, DataType::S32);
Gian Marco05288a22017-11-21 10:57:50 +0000152 _vector_sum_col.allocator()->init(info_vector_sum_col);
Giorgio Arenabb54e4e2018-04-05 17:20:34 +0100153 if(!_reshape_b_only_on_first_run)
154 {
155 _memory_group.manage(&_vector_sum_col);
156 }
Gian Marco05288a22017-11-21 10:57:50 +0000157
158 // Configure Matrix B reduction kernel
159 _mtx_b_reduction_kernel.configure(b, &_vector_sum_col);
160 }
161
162 // Initialize Matrix A reduction kernel only if _b_offset is not equal to 0
163 if(_b_offset != 0)
164 {
Georgios Pinitas358ca202017-12-07 16:47:52 +0000165 TensorInfo info_vector_sum_row(compute_reductionB_shape(*a->info()), 1, DataType::S32);
Gian Marco05288a22017-11-21 10:57:50 +0000166 _vector_sum_row.allocator()->init(info_vector_sum_row);
167 _memory_group.manage(&_vector_sum_row);
168
169 // Configure matrix A reduction kernel
170 _mtx_a_reduction_kernel.configure(a, &_vector_sum_row);
171 }
172
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100173 // If GEMMLowpOutputStage != NONE, fuse the offset contribution with the output stage
174 if(gemm_info.gemmlowp_output_stage().type != GEMMLowpOutputStageType::NONE)
175 {
176 _fuse_output_stage = true;
177
178 _memory_group.manage(&_mm_result_s32);
179
180 // Configure matrix multiply kernel
181 _mm_kernel.configure(matrix_a, matrix_b, &_mm_result_s32, _is_interleaved_transposed, GEMMReshapeInfo(m, n, k,
182 mult_transpose1xW_width, mult_interleave4x4_height,
183 depth_output_gemm3d, reinterpret_input_as_3d));
184
185 // Configure offset contribution kernel
186 _offset_contribution_output_stage_kernel.configure(&_mm_result_s32, _a_offset == 0 ? nullptr : &_vector_sum_col, _b_offset == 0 ? nullptr : &_vector_sum_row, c, output, a->info()->dimension(0),
187 _a_offset, _b_offset, gemm_info.gemmlowp_output_stage());
188
189 _mm_result_s32.allocator()->allocate();
190 }
191 else
192 {
193 // Configure matrix multiply kernel
194 _mm_kernel.configure(matrix_a, matrix_b, output, _is_interleaved_transposed, GEMMReshapeInfo(m, n, k,
195 mult_transpose1xW_width, mult_interleave4x4_height,
196 depth_output_gemm3d, reinterpret_input_as_3d));
197
198 // Configure offset contribution kernel
199 _offset_contribution_kernel.configure(output, _a_offset == 0 ? nullptr : &_vector_sum_col, _b_offset == 0 ? nullptr : &_vector_sum_row, c, a->info()->dimension(0), _a_offset, _b_offset);
200 }
Gian Marco05288a22017-11-21 10:57:50 +0000201
202 // Allocate tensors
203 if(_is_interleaved_transposed)
204 {
205 _tmp_a.allocator()->allocate();
Georgios Pinitas72219332018-06-05 14:56:06 +0100206 if(!_reshape_b_only_on_first_run)
207 {
208 _tmp_b.allocator()->allocate();
209 }
Gian Marco05288a22017-11-21 10:57:50 +0000210 }
211
Georgios Pinitas72219332018-06-05 14:56:06 +0100212 if(_a_offset != 0 && !_reshape_b_only_on_first_run)
Gian Marco05288a22017-11-21 10:57:50 +0000213 {
214 _vector_sum_col.allocator()->allocate();
215 }
216
217 if(_b_offset != 0)
218 {
219 _vector_sum_row.allocator()->allocate();
220 }
221}
222
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100223Status CLGEMMLowpMatrixMultiplyCore::validate(const ITensorInfo *a, const ITensorInfo *b, const ITensorInfo *c, const ITensorInfo *output, const GEMMInfo &gemm_info)
Georgios Pinitas358ca202017-12-07 16:47:52 +0000224{
225 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(a, 1, DataType::QASYMM8);
Georgios Pinitas358ca202017-12-07 16:47:52 +0000226 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(a, b);
Georgios Pinitas358ca202017-12-07 16:47:52 +0000227 ARM_COMPUTE_RETURN_ERROR_ON_MSG(gemm_info.is_a_reshaped(), "Matrix A already reshaped is not supported");
228 ARM_COMPUTE_RETURN_ERROR_ON_MSG(gemm_info.is_b_reshaped(), "Matrix B already reshaped is not supported");
229
Gian Marco19835e52018-01-30 13:35:54 +0000230 int32_t a_offset = a->quantization_info().offset;
231 int32_t b_offset = b->quantization_info().offset;
Georgios Pinitas358ca202017-12-07 16:47:52 +0000232
Isabella Gottardic4f582e2018-10-11 19:14:55 +0100233 const ITensorInfo *matrix_a_info = a;
234 const ITensorInfo *matrix_b_info = b;
235
236 TensorInfo tmp_a_info{};
237 TensorInfo tmp_b_info{};
238
Georgios Pinitas932491f2018-09-21 16:33:15 +0100239 bool reinterpret_input_as_3d = gemm_info.reinterpret_input_as_3d();
Isabella Gottardic4f582e2018-10-11 19:14:55 +0100240 const int m = reinterpret_input_as_3d ? (a->dimension(1) * a->dimension(2)) : a->dimension(1);
Georgios Pinitasebf6b8a2018-09-24 16:31:08 +0100241 const int n = b->dimension(0);
242 const int k = a->dimension(0);
243 constexpr int mult_transpose1xW_width = 1;
244 constexpr int mult_interleave4x4_height = 1;
Georgios Pinitasebf6b8a2018-09-24 16:31:08 +0100245 const int depth_output_gemm3d = gemm_info.depth_output_gemm3d();
Gian Marco19835e52018-01-30 13:35:54 +0000246
247 bool reshape_matrices = is_interleaved_transposed(m, n, k, gemm_info.reshape_b_only_on_first_run(), CLScheduler::get().target());
248
Georgios Pinitasebf6b8a2018-09-24 16:31:08 +0100249 // if reshape_matrices is set, force reinterpret_input_as_3d to be false as the output of CLGEMMInterleaveKernel will be 2D
250 if(reshape_matrices)
251 {
252 reinterpret_input_as_3d = false;
253 }
254
Isabella Gottardic4f582e2018-10-11 19:14:55 +0100255 const GEMMReshapeInfo reshape_info = GEMMReshapeInfo(m, n, k, mult_transpose1xW_width, mult_interleave4x4_height, depth_output_gemm3d, reinterpret_input_as_3d);
Georgios Pinitasebf6b8a2018-09-24 16:31:08 +0100256
Gian Marco19835e52018-01-30 13:35:54 +0000257 if(reshape_matrices)
Georgios Pinitas358ca202017-12-07 16:47:52 +0000258 {
Isabella Gottardic4f582e2018-10-11 19:14:55 +0100259 matrix_a_info = &tmp_a_info;
260 matrix_b_info = &tmp_b_info;
Georgios Pinitas358ca202017-12-07 16:47:52 +0000261
Isabella Gottardic4f582e2018-10-11 19:14:55 +0100262 // Validate interleave kernel
263 auto_init_if_empty(tmp_a_info, a->clone()->set_tensor_shape(compute_interleaved_shape(*a, mult_interleave4x4_height, gemm_info.reinterpret_input_as_3d())));
264 ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMInterleave4x4Kernel::validate(a, &tmp_a_info, mult_interleave4x4_height, gemm_info.reinterpret_input_as_3d()));
265
266 // Validate transpose kernel
267 auto_init_if_empty(tmp_b_info, b->clone()->set_tensor_shape(compute_transpose1xW_with_element_size_shape(*b, mult_transpose1xW_width)));
Isabella Gottardi089695f2018-10-17 18:04:15 +0100268 ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMTranspose1xWKernel::validate(b, &tmp_b_info, mult_transpose1xW_width));
Georgios Pinitas358ca202017-12-07 16:47:52 +0000269 }
Isabella Gottardic4f582e2018-10-11 19:14:55 +0100270
Georgios Pinitas358ca202017-12-07 16:47:52 +0000271 TensorInfo info_vector_sum_col, info_vector_sum_row;
272
273 // Validate matrix B reduction kernel only if _a_offset is not equal to 0
274 if(a_offset != 0)
275 {
276 info_vector_sum_col = TensorInfo(compute_reductionA_shape(*b), 1, DataType::S32);
277
278 // Configure Matrix B reduction kernel
279 ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMLowpMatrixBReductionKernel::validate(b, &info_vector_sum_col));
280 }
281
282 // Validate Matrix A reduction kernel only if _b_offset is not equal to 0
283 if(b_offset != 0)
284 {
285 info_vector_sum_row = TensorInfo(compute_reductionB_shape(*a), 1, DataType::S32);
286
287 // Configure matrix A reduction kernel
288 ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMLowpMatrixAReductionKernel::validate(a, &info_vector_sum_row));
289 }
290
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100291 if(gemm_info.gemmlowp_output_stage().type != GEMMLowpOutputStageType::NONE)
292 {
293 TensorInfo mm_result_s32_info{};
294
295 // Output tensor auto inizialitation if not yet initialized
296 auto_init_if_empty(mm_result_s32_info, a->clone()->set_tensor_shape(compute_mm_shape(*matrix_a_info, *matrix_b_info, reshape_matrices, reshape_info)).set_data_type(DataType::S32));
297
298 // Validate matrix multiply
299 ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMLowpMatrixMultiplyKernel::validate(matrix_a_info, matrix_b_info, &mm_result_s32_info, reshape_matrices, reshape_info));
300
301 // Validate offset contribution kernel
302 ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMLowpOffsetContributionOutputStageKernel::validate(&mm_result_s32_info,
303 a_offset == 0 ? nullptr : &info_vector_sum_col,
304 b_offset == 0 ? nullptr : &info_vector_sum_row,
305 c,
306 output,
307 a_offset, b_offset,
308 gemm_info.gemmlowp_output_stage()));
309 }
310 else
311 {
312 // Validate matrix multiply
313 ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMLowpMatrixMultiplyKernel::validate(matrix_a_info, matrix_b_info, output, reshape_matrices, reshape_info));
314
315 // Validate offset contribution kernel
316 ARM_COMPUTE_RETURN_ON_ERROR(CLGEMMLowpOffsetContributionKernel::validate(output,
317 a_offset == 0 ? nullptr : &info_vector_sum_col,
318 b_offset == 0 ? nullptr : &info_vector_sum_row,
319 c,
320 a_offset, b_offset));
321 }
Georgios Pinitas358ca202017-12-07 16:47:52 +0000322
323 return Status{};
324}
325
Gian Marco05288a22017-11-21 10:57:50 +0000326void CLGEMMLowpMatrixMultiplyCore::run()
327{
Georgios Pinitas72219332018-06-05 14:56:06 +0100328 prepare();
329
Gian Marco05288a22017-11-21 10:57:50 +0000330 _memory_group.acquire();
331
332 if(_is_interleaved_transposed)
333 {
334 // Run reshape matrix A
335 CLScheduler::get().enqueue(_mtx_a_reshape_kernel, false);
336
Georgios Pinitas72219332018-06-05 14:56:06 +0100337 if(!_reshape_b_only_on_first_run)
Chunosov5124be52017-11-22 20:42:13 +0700338 {
339 // Run reshape matrix B
340 CLScheduler::get().enqueue(_mtx_b_reshape_kernel, false);
341 }
342 }
343
Georgios Pinitas72219332018-06-05 14:56:06 +0100344 // Run matrix B reduction kernel only if _a_offset is not equal to 0
345 if(_a_offset != 0 && !_reshape_b_only_on_first_run)
Chunosov5124be52017-11-22 20:42:13 +0700346 {
Georgios Pinitas72219332018-06-05 14:56:06 +0100347 CLScheduler::get().enqueue(_mtx_b_reduction_kernel, false);
Gian Marco05288a22017-11-21 10:57:50 +0000348 }
349
350 // Run matrix multiply
351 CLScheduler::get().enqueue(_mm_kernel, false);
352
353 // Run matrix A reduction kernel only if _b_offset is not equal to 0
354 if(_b_offset != 0)
355 {
356 CLScheduler::get().enqueue(_mtx_a_reduction_kernel, false);
357 }
358
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100359 if(_fuse_output_stage)
360 {
361 // Run offset contribution/output stage kernel
362 CLScheduler::get().enqueue(_offset_contribution_output_stage_kernel, true);
363 }
364 else
365 {
366 // Run offset contribution kernel
367 CLScheduler::get().enqueue(_offset_contribution_kernel, true);
368 }
Gian Marco05288a22017-11-21 10:57:50 +0000369
370 _memory_group.release();
Georgios Pinitas72219332018-06-05 14:56:06 +0100371}
Chunosov5124be52017-11-22 20:42:13 +0700372
Georgios Pinitas72219332018-06-05 14:56:06 +0100373void CLGEMMLowpMatrixMultiplyCore::prepare()
374{
375 if(!_is_prepared)
376 {
377 if(_is_interleaved_transposed && _reshape_b_only_on_first_run)
378 {
379 ARM_COMPUTE_ERROR_ON(!_original_b->is_used());
380
381 // Run reshape kernel and mark original weights tensor as unused
382 _tmp_b.allocator()->allocate();
383 CLScheduler::get().enqueue(_mtx_b_reshape_kernel, false);
384 _original_b->mark_as_unused();
385 }
386
387 // Run matrix B reduction kernel only if _a_offset is not equal to 0
388 if(_a_offset != 0 && _reshape_b_only_on_first_run)
389 {
390 _vector_sum_col.allocator()->allocate();
391 CLScheduler::get().enqueue(_mtx_b_reduction_kernel, false);
392 }
393
394 CLScheduler::get().queue().finish();
395 _is_prepared = true;
396 }
Gian Marco05288a22017-11-21 10:57:50 +0000397}