blob: 67a1530431addc005f299d44e7052c401ae9e5a9 [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +01001/*
Stephen Lie855c232018-01-04 14:13:22 +08002 * Copyright (c) 2017-2018 ARM Limited.
Anthony Barbier7068f992017-10-26 15:23:08 +01003 *
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/core/GLES_COMPUTE/kernels/GCDirectConvolutionLayerKernel.h"
25
26#include "arm_compute/core/AccessWindowStatic.h"
27#include "arm_compute/core/Error.h"
28#include "arm_compute/core/GLES_COMPUTE/GCHelpers.h"
29#include "arm_compute/core/GLES_COMPUTE/GCKernelLibrary.h"
30#include "arm_compute/core/GLES_COMPUTE/IGCTensor.h"
31#include "arm_compute/core/Helpers.h"
32#include "arm_compute/core/IAccessWindow.h"
33#include "arm_compute/core/ITensor.h"
34#include "arm_compute/core/Types.h"
35#include "arm_compute/core/Validate.h"
36#include "support/ToolchainSupport.h"
37
38using namespace arm_compute;
39
40template <unsigned int kernel_size>
41GCDirectConvolutionLayerKernel<kernel_size>::GCDirectConvolutionLayerKernel()
42 : _input(nullptr), _bias(nullptr), _weights(nullptr), _output(nullptr), _border_size(0), _conv_stride_x(0), _conv_stride_y(0), _conv_pad_x(0), _conv_pad_y(0), _lws(gles::NDRange(1U, 1U, 1U))
43{
44}
45
46template <unsigned int kernel_size>
47BorderSize GCDirectConvolutionLayerKernel<kernel_size>::border_size() const
48{
49 return _border_size;
50}
51
52template <unsigned int kernel_size>
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000053void GCDirectConvolutionLayerKernel<kernel_size>::configure(const IGCTensor *input, const IGCTensor *weights, const IGCTensor *bias, IGCTensor *output,
54 const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info)
Anthony Barbier7068f992017-10-26 15:23:08 +010055{
56 ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16, DataType::F32);
Anthony Barbier7068f992017-10-26 15:23:08 +010057 ARM_COMPUTE_ERROR_ON(weights->info()->dimension(2) != input->info()->dimension(2));
58 ARM_COMPUTE_ERROR_ON(weights->info()->dimension(0) != weights->info()->dimension(1));
59 ARM_COMPUTE_ERROR_ON(weights->info()->num_dimensions() > 4);
60 ARM_COMPUTE_ERROR_ON_MSG((kernel_size == 3 && std::get<0>(conv_info.stride()) > 2), "Strides larger than 2 not supported in 3x3 direct convolution!");
61 ARM_COMPUTE_ERROR_ON(kernel_size != weights->info()->dimension(0));
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000062 ARM_COMPUTE_ERROR_ON(act_info.enabled() && act_info.activation() != ActivationLayerInfo::ActivationFunction::RELU && act_info.activation() != ActivationLayerInfo::ActivationFunction::LOGISTIC);
Anthony Barbier7068f992017-10-26 15:23:08 +010063
64 if(bias != nullptr)
65 {
66 ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(weights, bias);
67 // FIXME: Bug in framework, workaround it in tests currently.
68 //ARM_COMPUTE_ERROR_ON(bias->info()->dimension(0) != weights->info()->dimension(3));
69 ARM_COMPUTE_ERROR_ON(bias->info()->num_dimensions() > 1);
70 }
71
Frank Leib9d38ee2017-12-05 10:43:33 +080072 // Get convolved dimensions
73 unsigned int owidth = 0;
74 unsigned int oheight = 0;
75 std::tie(owidth, oheight) = scaled_dimensions(input->info()->dimension(0), input->info()->dimension(1), kernel_size, kernel_size, conv_info);
76
77 TensorShape output_shape = input->info()->tensor_shape();
78 output_shape.set(0, owidth);
79 output_shape.set(1, oheight);
80 output_shape.set(2, weights->info()->dimension(3));
81
82 // Output auto inizialitation if not yet initialized
83 auto_init_if_empty(*output->info(), output_shape, 1, input->info()->data_type(), input->info()->fixed_point_position());
84
85 ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, weights, output);
86 ARM_COMPUTE_ERROR_ON_MISMATCHING_DIMENSIONS(output->info()->tensor_shape(), output_shape);
87 ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
88 ARM_COMPUTE_ERROR_ON_MISMATCHING_FIXED_POINT(input, output);
Anthony Barbier21f67d62018-02-16 15:17:48 +000089 ARM_COMPUTE_ERROR_ON(!conv_info.padding_is_symmetric());
Frank Leib9d38ee2017-12-05 10:43:33 +080090
Anthony Barbier7068f992017-10-26 15:23:08 +010091 _conv_stride_x = std::get<0>(conv_info.stride());
92 _conv_stride_y = std::get<1>(conv_info.stride());
93 _conv_pad_x = std::get<0>(conv_info.pad());
94 _conv_pad_y = std::get<1>(conv_info.pad());
95
96 _input = input;
97 _weights = weights;
98 _output = output;
99 _bias = bias;
100 _border_size = BorderSize(_conv_pad_y, _conv_pad_x);
101
102 std::set<std::string> options;
103
104 options.emplace("#define LOCAL_SIZE_X " + support::cpp11::to_string(_lws[0]));
105 options.emplace("#define LOCAL_SIZE_Y " + support::cpp11::to_string(_lws[1]));
106 options.emplace("#define LOCAL_SIZE_Z " + support::cpp11::to_string(_lws[2]));
107 options.emplace("#define STRIDE_X " + support::cpp11::to_string(_conv_stride_x));
Xinghang Zhou4af62a02017-11-02 16:37:24 +0800108 options.emplace("#define STRIDE_Y " + support::cpp11::to_string(_conv_stride_y));
Anthony Barbier7068f992017-10-26 15:23:08 +0100109
110 std::string dt_name = (input->info()->data_type() == DataType::F32) ? "DATA_TYPE_FP32" : "DATA_TYPE_FP16";
111 options.emplace(("#define " + dt_name));
112
Isabella Gottardi3f217ec2018-02-12 14:59:19 +0000113 // Activation information in case of a fused activation
114 if(act_info.enabled())
115 {
116 options.emplace("#define FUSED_ACTIVATION");
117 options.emplace(("#define " + string_from_activation_func(act_info.activation())));
118 options.emplace(("#define ACT_OP " + lower_string(string_from_activation_func(act_info.activation())) + "_op"));
119 options.emplace(("#define A_VAL " + float_to_string_with_full_precision(act_info.a())));
120 options.emplace(("#define B_VAL " + float_to_string_with_full_precision(act_info.b())));
121 }
122
Anthony Barbier7068f992017-10-26 15:23:08 +0100123 unsigned int num_elems_read_per_iteration_x = kernel_size * _conv_stride_x;
124 unsigned int num_elems_read_per_iteration_y = 1;
125 unsigned int num_elems_written_per_iteration_x = 1;
126 unsigned int num_elems_written_per_iteration_y = 1;
127 unsigned int num_elems_written_per_iteration_z = 1;
128
129 if(kernel_size == 3)
130 {
131 if((_conv_stride_x == 1) && (_conv_stride_y == 1))
132 {
133 switch(input->info()->data_type())
134 {
Anthony Barbier7068f992017-10-26 15:23:08 +0100135 case DataType::F16:
Joel Liang63875432018-01-02 14:05:06 +0800136 // TODO(APPBROWSER-299): Choose the most optimal path and remove others.
137#define PROCESS_4X_3Y_1Z
138
139#if defined(PROCESS_8X_3Y_1Z)
140 options.emplace("#define PROCESS_8X_3Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100141 num_elems_read_per_iteration_x = 16;
142 num_elems_read_per_iteration_y = 5;
143 num_elems_written_per_iteration_x = 8;
144 num_elems_written_per_iteration_y = 3;
Joel Liang63875432018-01-02 14:05:06 +0800145#elif defined(PROCESS_4X_3Y_1Z)
146 options.emplace("#define PROCESS_4X_3Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100147 num_elems_read_per_iteration_x = 8;
148 num_elems_read_per_iteration_y = 5;
149 num_elems_written_per_iteration_x = 4;
150 num_elems_written_per_iteration_y = 3;
Joel Liang63875432018-01-02 14:05:06 +0800151#elif defined(PROCESS_4X_4Y_1Z)
152 options.emplace("#define PROCESS_4X_4Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100153 num_elems_read_per_iteration_x = 8;
154 num_elems_read_per_iteration_y = 6;
155 num_elems_written_per_iteration_x = 4;
156 num_elems_written_per_iteration_y = 4;
Joel Liang63875432018-01-02 14:05:06 +0800157#elif defined(PROCESS_4X_3Y_2Z)
158 options.emplace("#define PROCESS_4X_3Y_2Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100159 num_elems_read_per_iteration_x = 8;
160 num_elems_read_per_iteration_y = 5;
161 num_elems_written_per_iteration_x = 4;
162 num_elems_written_per_iteration_y = 3;
163 num_elems_written_per_iteration_z = 2;
Joel Liang63875432018-01-02 14:05:06 +0800164#endif /* PROCESS_nX_nY_nZ */
165#undef PROCESS_8X_3Y_1Z
166#undef PROCESS_4X_3Y_1Z
167#undef PROCESS_4X_4Y_1Z
168#undef PROCESS_4X_3Y_2Z
Anthony Barbier7068f992017-10-26 15:23:08 +0100169 break;
170
171 case DataType::F32:
Joel Liang63875432018-01-02 14:05:06 +0800172 options.emplace("#define PROCESS_4X_3Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100173 num_elems_read_per_iteration_x = 8;
174 num_elems_read_per_iteration_y = 5;
175 num_elems_written_per_iteration_x = 4;
176 num_elems_written_per_iteration_y = 3;
177 break;
178
179 default:
180 ARM_COMPUTE_ERROR("Current data type is not supported");
181 break;
182 }
183 }
184 // FIXME: Just keep one in release
185 else
186 {
187 switch(input->info()->data_type())
188 {
189 case DataType::F16:
Joel Liang63875432018-01-02 14:05:06 +0800190 options.emplace("#define PROCESS_4X_1Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100191 num_elems_read_per_iteration_x = 8;
192 num_elems_written_per_iteration_x = 4;
193 break;
194
195 case DataType::F32:
196 // TODO(APPBROWSER-299): Choose the most optimal path and remove others.
Joel Liang63875432018-01-02 14:05:06 +0800197#define PROCESS_4X_1Y_1Z
Anthony Barbier7068f992017-10-26 15:23:08 +0100198
Joel Liang63875432018-01-02 14:05:06 +0800199#if defined(PROCESS_1X_1Y_1Z)
200 options.emplace("#define PROCESS_1X_1Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100201 num_elems_read_per_iteration_x = 3;
202 num_elems_written_per_iteration_x = 1;
Joel Liang63875432018-01-02 14:05:06 +0800203#elif defined(PROCESS_4X_1Y_1Z)
204 options.emplace("#define PROCESS_4X_1Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100205 num_elems_read_per_iteration_x = 8;
206 num_elems_written_per_iteration_x = 4;
Joel Liang63875432018-01-02 14:05:06 +0800207#elif defined(PROCESS_8X_1Y_1Z)
208 options.emplace("#define PROCESS_8X_1Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100209 num_elems_read_per_iteration_x = 12;
210 num_elems_written_per_iteration_x = 8;
Joel Liang63875432018-01-02 14:05:06 +0800211#else /* PROCESS_nX_nY_nZ */
Anthony Barbier7068f992017-10-26 15:23:08 +0100212#error Have to declare how many elements to process in one thread.
Joel Liang63875432018-01-02 14:05:06 +0800213#endif /* PROCESS_nX_nY_nZ */
214#undef PROCESS_1X_1Y_1Z
215#undef PROCESS_4X_1Y_1Z
216#undef PROCESS_8X_1Y_1Z
Anthony Barbier7068f992017-10-26 15:23:08 +0100217 break;
218
219 default:
220 ARM_COMPUTE_ERROR("Current data type is not supported");
221 break;
222 }
223 }
224 }
225 else if(kernel_size == 1)
226 {
Xinghang Zhou4af62a02017-11-02 16:37:24 +0800227 if(weights->info()->dimension(2) % 2 == 0)
228 {
229 options.emplace("#define WEIGHTS_OPTIMIZATION");
230 }
Anthony Barbier7068f992017-10-26 15:23:08 +0100231 switch(input->info()->data_type())
232 {
233 case DataType::F16:
Xinghang Zhou4af62a02017-11-02 16:37:24 +0800234#define PROCESS_8X_2Y_1Z
235
236#if defined(PROCESS_4X_1Y_1Z)
237 options.emplace("#define PROCESS_4X_1Y_1Z");
238 num_elems_read_per_iteration_x = 4;
239 num_elems_written_per_iteration_x = 4;
240#elif defined(PROCESS_4X_2Y_1Z)
241 options.emplace("#define PROCESS_4X_2Y_1Z");
242 num_elems_read_per_iteration_x = 4;
243 num_elems_read_per_iteration_y = 2;
244 num_elems_written_per_iteration_x = 4;
245 num_elems_written_per_iteration_y = 2;
246#elif defined(PROCESS_4X_3Y_1Z)
247 options.emplace("#define PROCESS_4X_3Y_1Z");
248 num_elems_read_per_iteration_x = 4;
249 num_elems_read_per_iteration_y = 3;
250 num_elems_written_per_iteration_x = 4;
251 num_elems_written_per_iteration_y = 3;
252#elif defined(PROCESS_4X_4Y_1Z)
253 options.emplace("#define PROCESS_4X_4Y_1Z");
254 num_elems_read_per_iteration_x = 4;
255 num_elems_read_per_iteration_y = 4;
256 num_elems_written_per_iteration_x = 4;
257 num_elems_written_per_iteration_y = 4;
258#elif defined(PROCESS_4X_2Y_2Z)
259 ARM_COMPUTE_ERROR_ON_MSG((weights->info()->dimension(4) % 2) == 1, "Current 'weights->info()->dimension(4) % 2) == 1' is not supported");
260 options.emplace("#define PROCESS_4X_2Y_2Z");
261 num_elems_read_per_iteration_x = 4;
262 num_elems_read_per_iteration_y = 2;
263 num_elems_written_per_iteration_x = 4;
264 num_elems_written_per_iteration_y = 2;
265 num_elems_written_per_iteration_z = 2;
266#elif defined(PROCESS_8X_1Y_1Z)
267 options.emplace("#define PROCESS_8X_1Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100268 num_elems_read_per_iteration_x = 8;
269 num_elems_written_per_iteration_x = 8;
Xinghang Zhou4af62a02017-11-02 16:37:24 +0800270#elif defined(PROCESS_8X_2Y_1Z)
271 options.emplace("#define PROCESS_8X_2Y_1Z");
272 num_elems_read_per_iteration_x = 8;
273 num_elems_read_per_iteration_y = 2;
274 num_elems_written_per_iteration_x = 8;
275 num_elems_written_per_iteration_y = 2;
276#else /* PROCESS_4X_1Y_1Z */
277#error Have to declare how many elements to process in one thread.
278#endif /* PROCESS_4X_1Y_1Z */
279#undef PROCESS_4X_1Y_1Z
280#undef PROCESS_4X_2Y_1Z
281#undef PROCESS_4X_3Y_1Z
282#undef PROCESS_4X_4Y_1Z
283#undef PROCESS_4X_2Y_2Z
284#undef PROCESS_8X_1Y_1Z
285#undef PROCESS_8X_2Y_1Z
Anthony Barbier7068f992017-10-26 15:23:08 +0100286 break;
287
288 case DataType::F32:
289 num_elems_read_per_iteration_x = 1;
290 num_elems_written_per_iteration_x = 1;
291 break;
292
293 default:
294 break;
295 }
296 }
297 else if(kernel_size == 5)
298 {
299 switch(input->info()->data_type())
300 {
301 case DataType::F16:
ASIAPAC\steli0123ac91b2017-11-07 16:14:44 +0800302 options.emplace("#define PROCESS_4X_1Y_1Z");
Anthony Barbier7068f992017-10-26 15:23:08 +0100303 num_elems_read_per_iteration_x = 8;
304 num_elems_written_per_iteration_x = 4;
305
306 default:
307 break;
308 }
309 }
310 else
311 {
312 }
313
314 if(_bias != nullptr)
315 {
316 options.emplace("#define BIAS");
317 }
318
319 std::stringstream kernel_name;
320 kernel_name << "direct_convolution" << kernel_size << "x" << kernel_size;
321
322 _kernel = static_cast<GCKernel>(GCKernelLibrary::get().create_kernel(kernel_name.str(), options));
323
Anthony Barbier7068f992017-10-26 15:23:08 +0100324 unsigned int idx = (_bias == nullptr) ? 3 * num_arguments_per_3D_tensor() : (num_arguments_per_1D_tensor() + 3 * num_arguments_per_3D_tensor());
325
326 // Calculate output right and bottom border
327 const int output_width = output->info()->dimension(0);
328 const int output_height = output->info()->dimension(1);
329 const int output_padding_right = ceil_to_multiple(output_width, num_elems_written_per_iteration_x * _lws[0]) - output_width;
330 const int output_padding_bottom = ceil_to_multiple(output_height, num_elems_written_per_iteration_y * _lws[1]) - output_height;
331
332 // Calculate input right and bottom border
Xinghang Zhou33ff9ef2018-01-17 11:23:39 +0800333 const int input_width = input->info()->dimension(0);
334 const int input_height = input->info()->dimension(1);
335 const int input_total_width = std::max(int(input->info()->padding().left), int(_conv_pad_x)) + input_width + std::max(int(input->info()->padding().right), int(_conv_pad_x));
336 const int input_total_height = std::max(int(input->info()->padding().top), int(_conv_pad_y)) + input_height + std::max(int(input->info()->padding().bottom), int(_conv_pad_y));
337 const int padding_right1 = ceil_to_multiple(input_total_width, num_elems_read_per_iteration_x * _lws[0]) - input_width - _conv_pad_x;
338 const int padding_bottom1 = ceil_to_multiple(input_total_height, num_elems_read_per_iteration_y * _lws[1]) - input_height - _conv_pad_y;
339
340 const int upper_bound_w = ceil_to_multiple(((output_width + output_padding_right) * _conv_stride_x + (kernel_size - 1)), num_elems_read_per_iteration_x * _lws[0]) - _conv_pad_x - input_width;
341 const int upper_bound_h = ceil_to_multiple(((output_height + output_padding_bottom) * _conv_stride_y + (kernel_size - 1)), num_elems_read_per_iteration_y * _lws[1]) - _conv_pad_y - input_height;
342 const int padding_right2 = std::max(upper_bound_w, _conv_pad_x);
343 const int padding_bottom2 = std::max(upper_bound_h, _conv_pad_y);
344
345 const int padding_right = std::max(padding_right1, padding_right2);
346 const int padding_bottom = std::max(padding_bottom1, padding_bottom2);
Anthony Barbier7068f992017-10-26 15:23:08 +0100347
348 BorderSize border = BorderSize(0, output_padding_right, output_padding_bottom, 0);
349
350 Window win = calculate_max_enlarged_window(*output->info(), Steps(num_elems_written_per_iteration_x, num_elems_written_per_iteration_y, num_elems_written_per_iteration_z), border);
351
352 AccessWindowStatic input_access(input->info(), -_conv_pad_x, -_conv_pad_y, input_width + padding_right, input_height + padding_bottom);
353 AccessWindowStatic weights_access = AccessWindowStatic(nullptr, 0, 0, 0, 0);
354 AccessWindowStatic bias_access = AccessWindowStatic(nullptr, 0, 0, 0, 1);
355
356 switch(weights->info()->data_type())
357 {
358 case DataType::F16:
zhenglin666635c2017-12-04 14:38:09 +0800359 if((weights->info()->dimension(2) % 2 != 0) || (kernel_size != 1))
360 {
361 weights_access = AccessWindowStatic(weights->info(), 0, 0, kernel_size + 1, kernel_size);
362 }
Anthony Barbier7068f992017-10-26 15:23:08 +0100363 if(_bias != nullptr)
364 {
365 bias_access = AccessWindowStatic(_bias->info(), 0, 0, _bias->info()->dimension(0) + 1, 1);
366 }
367 break;
368
369 case DataType::F32:
370 weights_access = AccessWindowStatic(weights->info(), 0, 0, kernel_size, kernel_size);
371 if(_bias != nullptr)
372 {
373 bias_access = AccessWindowStatic(_bias->info(), 0, 0, _bias->info()->dimension(0), 1);
374 }
375 break;
376
377 default:
378 ARM_COMPUTE_ERROR("Current data type is not supported");
379 break;
380 }
381
382 AccessWindowStatic output_access(output->info(), 0, 0, output_width + output_padding_right, output_height + output_padding_bottom);
383
384 if(_bias != nullptr)
385 {
386 update_window_and_padding(win, input_access, weights_access, bias_access, output_access);
387 }
388 else
389 {
390 update_window_and_padding(win, input_access, weights_access, output_access);
391 }
392
393 output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape()));
394
Joel Liangf1f3ebd2017-11-10 09:59:19 +0800395 _kernel.set_argument(idx++, _weights->info()->strides_in_bytes()[3]); // weights_stride_w
396 _kernel.set_argument(idx++, _weights->info()->dimension(2)); // weights_depth
Anthony Barbier7068f992017-10-26 15:23:08 +0100397
398 IGCKernel::configure(win);
399}
400
401template <unsigned int kernel_size>
402void GCDirectConvolutionLayerKernel<kernel_size>::run(const Window &window)
403{
404 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
405 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window);
406
407 _kernel.use();
408
Frank Lei4406fd62018-02-01 14:47:14 +0800409 _output->set_needs_shifting(true);
410
Anthony Barbier7068f992017-10-26 15:23:08 +0100411 // Get initial windows
412 Window slice = window.first_slice_window_3D();
413 Window win_in = window;
414
415 win_in.adjust(Window::DimX, -_conv_pad_x, true);
416 win_in.adjust(Window::DimY, -_conv_pad_y, true);
417 win_in.set_dimension_step(Window::DimX, window.x().step() * _conv_stride_x);
418 win_in.set_dimension_step(Window::DimY, window.y().step() * _conv_stride_y);
419
420 Window slice_in = win_in.first_slice_window_3D();
421
422 unsigned int idx1 = 2 * num_arguments_per_3D_tensor();
Joel Liangabd03cf2018-01-08 15:20:48 +0800423 add_3D_tensor_argument(idx1, _weights, 3, slice);
Anthony Barbier7068f992017-10-26 15:23:08 +0100424
425 if(_bias != nullptr)
426 {
427 Window slice_bias;
428 slice_bias.use_tensor_dimensions(_bias->info()->tensor_shape());
Joel Liangabd03cf2018-01-08 15:20:48 +0800429 add_1D_tensor_argument(idx1, _bias, 4, slice_bias);
Anthony Barbier7068f992017-10-26 15:23:08 +0100430 }
431
Xinghang Zhou33ff9ef2018-01-17 11:23:39 +0800432 slice.shift(Window::DimX, -(_output->info()->padding()).left);
433
Anthony Barbier7068f992017-10-26 15:23:08 +0100434 do
435 {
436 unsigned int idx = 0;
437
Joel Liangabd03cf2018-01-08 15:20:48 +0800438 add_3D_tensor_argument(idx, _input, 1, slice_in);
439 add_3D_tensor_argument(idx, _output, 2, slice);
Anthony Barbier7068f992017-10-26 15:23:08 +0100440
441 _kernel.update_shader_params();
442 enqueue(*this, slice, _lws);
443 }
444 while(window.slide_window_slice_3D(slice) && win_in.slide_window_slice_3D(slice_in));
445}
446
447template class arm_compute::GCDirectConvolutionLayerKernel<1>;
448template class arm_compute::GCDirectConvolutionLayerKernel<3>;
449template class arm_compute::GCDirectConvolutionLayerKernel<5>;