1*c217d954SCole Faust /*
2*c217d954SCole Faust * Copyright (c) 2022-2023 Arm Limited.
3*c217d954SCole Faust *
4*c217d954SCole Faust * SPDX-License-Identifier: MIT
5*c217d954SCole Faust *
6*c217d954SCole Faust * Permission is hereby granted, free of charge, to any person obtaining a copy
7*c217d954SCole Faust * of this software and associated documentation files (the "Software"), to
8*c217d954SCole Faust * deal in the Software without restriction, including without limitation the
9*c217d954SCole Faust * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10*c217d954SCole Faust * sell copies of the Software, and to permit persons to whom the Software is
11*c217d954SCole Faust * furnished to do so, subject to the following conditions:
12*c217d954SCole Faust *
13*c217d954SCole Faust * The above copyright notice and this permission notice shall be included in all
14*c217d954SCole Faust * copies or substantial portions of the Software.
15*c217d954SCole Faust *
16*c217d954SCole Faust * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*c217d954SCole Faust * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*c217d954SCole Faust * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19*c217d954SCole Faust * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*c217d954SCole Faust * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21*c217d954SCole Faust * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22*c217d954SCole Faust * SOFTWARE.
23*c217d954SCole Faust */
24*c217d954SCole Faust #include "src/gpu/cl/kernels/ClIndirectConv2dKernel.h"
25*c217d954SCole Faust
26*c217d954SCole Faust #include "arm_compute/core/CL/CLKernelLibrary.h"
27*c217d954SCole Faust #include "arm_compute/core/CL/ICLTensor.h"
28*c217d954SCole Faust #include "arm_compute/core/KernelDescriptors.h"
29*c217d954SCole Faust #include "arm_compute/core/Utils.h"
30*c217d954SCole Faust #include "arm_compute/core/utils/misc/ShapeCalculator.h"
31*c217d954SCole Faust #include "src/core/CL/CLUtils.h"
32*c217d954SCole Faust #include "src/core/CL/CLValidate.h"
33*c217d954SCole Faust #include "src/core/helpers/AutoConfiguration.h"
34*c217d954SCole Faust #include "src/core/helpers/WindowHelpers.h"
35*c217d954SCole Faust #include "src/gpu/cl/kernels/gemm/ClGemmHelpers.h"
36*c217d954SCole Faust #include "support/Cast.h"
37*c217d954SCole Faust #include "support/StringSupport.h"
38*c217d954SCole Faust
39*c217d954SCole Faust namespace arm_compute
40*c217d954SCole Faust {
41*c217d954SCole Faust namespace opencl
42*c217d954SCole Faust {
43*c217d954SCole Faust namespace kernels
44*c217d954SCole Faust {
45*c217d954SCole Faust namespace
46*c217d954SCole Faust {
validate_arguments(const ITensorInfo * src,const ITensorInfo * weights,const ITensorInfo * biases,const ITensorInfo * indirect_buffer,const ITensorInfo * dst,const PadStrideInfo & conv_info,const ActivationLayerInfo & act_info,const DirectConvComputeKernelInfo & desc)47*c217d954SCole Faust Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *indirect_buffer, const ITensorInfo *dst,
48*c217d954SCole Faust const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info, const DirectConvComputeKernelInfo &desc)
49*c217d954SCole Faust {
50*c217d954SCole Faust ARM_COMPUTE_UNUSED(act_info);
51*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(src);
52*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::F16, DataType::F32);
53*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(indirect_buffer, 1, DataType::S32);
54*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_DATA_LAYOUT_NOT_IN(src, DataLayout::NHWC);
55*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, weights);
56*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(indirect_buffer->tensor_shape(),
57*c217d954SCole Faust misc::shape_calculator::compute_indirect_buffer_shape(src->tensor_shape(),
58*c217d954SCole Faust src->data_layout(),
59*c217d954SCole Faust weights->tensor_shape(),
60*c217d954SCole Faust conv_info,
61*c217d954SCole Faust desc));
62*c217d954SCole Faust
63*c217d954SCole Faust constexpr int channel_idx = 0;
64*c217d954SCole Faust constexpr int batch_idx = 3;
65*c217d954SCole Faust
66*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights->dimension(channel_idx) != src->dimension(channel_idx), "Weights feature map dimension should match the respective src's one");
67*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights->num_dimensions() > 4, "Weights can be at most 4 dimensional");
68*c217d954SCole Faust
69*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(desc.m0 <= 0 || desc.m0 > 8, "M0 can only be greater than 0 and less than or equal to 8");
70*c217d954SCole Faust
71*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(desc.n0 != 1 && desc.n0 != 2 && desc.n0 != 3 && desc.n0 != 4 && desc.n0 != 8 && desc.n0 != 16,
72*c217d954SCole Faust "N0 can only be: 1, 2, 3, 4, 8, and 16");
73*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(desc.k0 != 1 && desc.k0 != 2 && desc.k0 != 3 && desc.k0 != 4 && desc.k0 != 8 && desc.k0 != 16,
74*c217d954SCole Faust "K0 can only be: 1, 2, 3, 4, 8, and 16");
75*c217d954SCole Faust
76*c217d954SCole Faust if(desc.export_weights_to_cl_image)
77*c217d954SCole Faust {
78*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(desc.k0 != 4 && desc.k0 != 8 && desc.k0 != 16,
79*c217d954SCole Faust "K0 can only be: 4, 8, and 16");
80*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(!export_to_cl_image(weights),
81*c217d954SCole Faust "Export to CLImage is not supported for this weight configuration");
82*c217d954SCole Faust }
83*c217d954SCole Faust
84*c217d954SCole Faust if(biases != nullptr)
85*c217d954SCole Faust {
86*c217d954SCole Faust if(is_data_type_quantized_asymmetric(src->data_type()))
87*c217d954SCole Faust {
88*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(biases, 1, DataType::S32);
89*c217d954SCole Faust }
90*c217d954SCole Faust else
91*c217d954SCole Faust {
92*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(weights, biases);
93*c217d954SCole Faust }
94*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(biases->dimension(channel_idx) != weights->dimension(batch_idx),
95*c217d954SCole Faust "Biases size and number of dst feature maps should match");
96*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MSG(biases->num_dimensions() > 1,
97*c217d954SCole Faust "Biases should be one dimensional");
98*c217d954SCole Faust }
99*c217d954SCole Faust
100*c217d954SCole Faust // Checks performed when dst is configured
101*c217d954SCole Faust if(dst->total_size() != 0)
102*c217d954SCole Faust {
103*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(dst->tensor_shape(),
104*c217d954SCole Faust misc::shape_calculator::compute_deep_convolution_shape(*src, *weights, conv_info));
105*c217d954SCole Faust ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst);
106*c217d954SCole Faust }
107*c217d954SCole Faust
108*c217d954SCole Faust return Status{};
109*c217d954SCole Faust }
110*c217d954SCole Faust } // namespace
111*c217d954SCole Faust
ClIndirectConv2dKernel()112*c217d954SCole Faust ClIndirectConv2dKernel::ClIndirectConv2dKernel()
113*c217d954SCole Faust {
114*c217d954SCole Faust _type = CLKernelType::DIRECT;
115*c217d954SCole Faust }
116*c217d954SCole Faust
configure(const CLCompileContext & compile_context,ITensorInfo * src,ITensorInfo * weights,ITensorInfo * biases,ITensorInfo * indirect_buffer,ITensorInfo * dst,const PadStrideInfo & conv_info,const ActivationLayerInfo & act_info,const DirectConvComputeKernelInfo & desc)117*c217d954SCole Faust void ClIndirectConv2dKernel::configure(const CLCompileContext &compile_context, ITensorInfo *src, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *indirect_buffer, ITensorInfo *dst,
118*c217d954SCole Faust const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info, const DirectConvComputeKernelInfo &desc)
119*c217d954SCole Faust {
120*c217d954SCole Faust ARM_COMPUTE_ERROR_ON_NULLPTR(src, weights, indirect_buffer, dst);
121*c217d954SCole Faust
122*c217d954SCole Faust // Perform validation
123*c217d954SCole Faust ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, weights, biases, indirect_buffer, dst, conv_info, act_info, desc));
124*c217d954SCole Faust
125*c217d954SCole Faust constexpr unsigned int channel_idx = 0;
126*c217d954SCole Faust constexpr unsigned int width_idx = 1;
127*c217d954SCole Faust constexpr unsigned int height_idx = 2;
128*c217d954SCole Faust const unsigned int kernel_width = weights->dimension(width_idx);
129*c217d954SCole Faust const unsigned int kernel_height = weights->dimension(height_idx);
130*c217d954SCole Faust const DataType data_type = src->data_type();
131*c217d954SCole Faust
132*c217d954SCole Faust const GPUTarget gpu_target = get_target();
133*c217d954SCole Faust
134*c217d954SCole Faust // Get dst shape
135*c217d954SCole Faust TensorShape output_shape = misc::shape_calculator::compute_deep_convolution_shape(*src, *weights, conv_info);
136*c217d954SCole Faust
137*c217d954SCole Faust // Output auto inizialitation if not yet initialized
138*c217d954SCole Faust auto_init_if_empty(*dst, output_shape,
139*c217d954SCole Faust 1,
140*c217d954SCole Faust src->data_type(),
141*c217d954SCole Faust src->quantization_info());
142*c217d954SCole Faust
143*c217d954SCole Faust // Configure kernel window
144*c217d954SCole Faust Window win;
145*c217d954SCole Faust output_shape.collapse(2U, 1U);
146*c217d954SCole Faust const unsigned int n0 = adjust_vec_size(desc.n0, output_shape[0]);
147*c217d954SCole Faust const unsigned int m0 = adjust_vec_size(desc.m0, output_shape[1]);
148*c217d954SCole Faust const unsigned int k0 = adjust_vec_size(desc.k0, src->dimension(channel_idx));
149*c217d954SCole Faust
150*c217d954SCole Faust const unsigned int partial_store_n0 = dst->dimension(channel_idx) % n0;
151*c217d954SCole Faust
152*c217d954SCole Faust // Create window and update padding
153*c217d954SCole Faust win = calculate_max_window(output_shape, Steps(n0, m0));
154*c217d954SCole Faust
155*c217d954SCole Faust ICLKernel::configure_internal(win);
156*c217d954SCole Faust
157*c217d954SCole Faust std::stringstream kernel_name;
158*c217d954SCole Faust CLBuildOptions build_options;
159*c217d954SCole Faust
160*c217d954SCole Faust kernel_name << "indirect_convolution_nhwc";
161*c217d954SCole Faust
162*c217d954SCole Faust _export_to_cl_image = desc.export_weights_to_cl_image;
163*c217d954SCole Faust
164*c217d954SCole Faust // Update the padding for the weights tensor if we can export to cl_image
165*c217d954SCole Faust if(_export_to_cl_image)
166*c217d954SCole Faust {
167*c217d954SCole Faust gemm::update_padding_for_cl_image(weights);
168*c217d954SCole Faust }
169*c217d954SCole Faust
170*c217d954SCole Faust // Add padding to indirect buffer to avoid out-of-bound reads
171*c217d954SCole Faust // When M0 is 5, 6, and 7, we use vload8 to fetch the data from the buffer
172*c217d954SCole Faust const unsigned int load_indirect_buf_size = m0 > 4 ? 8 : m0;
173*c217d954SCole Faust const unsigned int indirect_buf_width = indirect_buffer->tensor_shape()[0];
174*c217d954SCole Faust const unsigned int round_up_width = ((indirect_buf_width + load_indirect_buf_size - 1) / load_indirect_buf_size) * load_indirect_buf_size;
175*c217d954SCole Faust const unsigned int padding = round_up_width - indirect_buf_width;
176*c217d954SCole Faust indirect_buffer->extend_padding(PaddingSize(0, indirect_buffer->padding().right + padding, 0, 0));
177*c217d954SCole Faust
178*c217d954SCole Faust if(biases != nullptr)
179*c217d954SCole Faust {
180*c217d954SCole Faust build_options.add_option(std::string("-DHAS_BIAS"));
181*c217d954SCole Faust build_options.add_option(std::string("-DBIA_DATA_TYPE=" + get_cl_type_from_data_type(biases->data_type())));
182*c217d954SCole Faust }
183*c217d954SCole Faust
184*c217d954SCole Faust // Conditions of -cl-fast-relaxed-math causing accuracy issues can be traced from COMPMID-5324
185*c217d954SCole Faust const auto act_function = act_info.activation();
186*c217d954SCole Faust
187*c217d954SCole Faust if((gpu_target != GPUTarget::G71 && (gpu_target & GPUTarget::GPU_ARCH_MASK) == GPUTarget::BIFROST)
188*c217d954SCole Faust && (act_function == ActivationLayerInfo::ActivationFunction::BOUNDED_RELU || act_function == ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU)
189*c217d954SCole Faust && (data_type == DataType::F32 || data_type == DataType::F16))
190*c217d954SCole Faust {
191*c217d954SCole Faust // -cl-fast-relaxed-math also sets -cl-finite-math-only and -cl-unsafe-math-optimizations
192*c217d954SCole Faust // to disable -cl-finite-math-only, we only include -cl-unsafe-math-optimizations
193*c217d954SCole Faust build_options.add_option("-cl-unsafe-math-optimizations");
194*c217d954SCole Faust }
195*c217d954SCole Faust else
196*c217d954SCole Faust {
197*c217d954SCole Faust build_options.add_option("-cl-fast-relaxed-math");
198*c217d954SCole Faust }
199*c217d954SCole Faust
200*c217d954SCole Faust build_options.add_option("-DSRC_TENSOR_TYPE=BUFFER");
201*c217d954SCole Faust build_options.add_option("-DSRC_DATA_TYPE=" + get_cl_type_from_data_type(data_type));
202*c217d954SCole Faust build_options.add_option("-DSRC_CHANNELS=" + support::cpp11::to_string(src->dimension(channel_idx)));
203*c217d954SCole Faust build_options.add_option("-DOFF_TENSOR_TYPE=BUFFER");
204*c217d954SCole Faust build_options.add_option("-DDST_WIDTH=" + support::cpp11::to_string(dst->dimension(width_idx)));
205*c217d954SCole Faust build_options.add_option("-DDST_HEIGHT=" + support::cpp11::to_string(dst->dimension(height_idx)));
206*c217d954SCole Faust build_options.add_option("-DDST_TENSOR_TYPE=BUFFER");
207*c217d954SCole Faust build_options.add_option("-DDST_DATA_TYPE=" + get_cl_type_from_data_type(data_type));
208*c217d954SCole Faust build_options.add_option_if_else(_export_to_cl_image, "-DWEI_TENSOR_TYPE=IMAGE", "-DWEI_TENSOR_TYPE=BUFFER");
209*c217d954SCole Faust build_options.add_option("-DWEI_WIDTH=" + support::cpp11::to_string(kernel_width));
210*c217d954SCole Faust build_options.add_option("-DWEI_HEIGHT=" + support::cpp11::to_string(kernel_height));
211*c217d954SCole Faust build_options.add_option("-DWEI_DATA_TYPE=" + get_cl_type_from_data_type(data_type));
212*c217d954SCole Faust build_options.add_option("-DN0=" + support::cpp11::to_string(n0));
213*c217d954SCole Faust build_options.add_option("-DM0=" + support::cpp11::to_string(m0));
214*c217d954SCole Faust build_options.add_option("-DK0=" + support::cpp11::to_string(k0));
215*c217d954SCole Faust build_options.add_option("-DPARTIAL_N0=" + support::cpp11::to_string(partial_store_n0));
216*c217d954SCole Faust build_options.add_option("-DIND_BUFF_VEC_SIZE=" + support::cpp11::to_string(load_indirect_buf_size));
217*c217d954SCole Faust build_options.add_option_if((src->dimension(channel_idx) % k0) != 0, "-DLEFTOVER_LOOP");
218*c217d954SCole Faust build_options.add_option("-DACTIVATION_TYPE=" + lower_string(string_from_activation_func(act_function)));
219*c217d954SCole Faust build_options.add_option_if(act_info.enabled(), "-DA_VAL=" + float_to_string_with_full_precision(act_info.a()));
220*c217d954SCole Faust build_options.add_option_if(act_info.enabled(), "-DB_VAL=" + float_to_string_with_full_precision(act_info.b()));
221*c217d954SCole Faust
222*c217d954SCole Faust // A macro guard to compile ONLY the kernel of interest
223*c217d954SCole Faust build_options.add_option("-D" + upper_string(kernel_name.str()));
224*c217d954SCole Faust
225*c217d954SCole Faust if(compile_context.get_ddk_version() >= 30)
226*c217d954SCole Faust {
227*c217d954SCole Faust build_options.add_option("-fregister-allocation=64");
228*c217d954SCole Faust }
229*c217d954SCole Faust
230*c217d954SCole Faust _kernel = create_kernel(compile_context, kernel_name.str(), build_options.options());
231*c217d954SCole Faust
232*c217d954SCole Faust // Set config_id for enabling LWS tuning
233*c217d954SCole Faust _config_id = kernel_name.str();
234*c217d954SCole Faust _config_id += "_";
235*c217d954SCole Faust _config_id += lower_string(string_from_data_type(data_type));
236*c217d954SCole Faust _config_id += "_";
237*c217d954SCole Faust _config_id += support::cpp11::to_string(kernel_width);
238*c217d954SCole Faust _config_id += "_";
239*c217d954SCole Faust _config_id += support::cpp11::to_string(kernel_height);
240*c217d954SCole Faust _config_id += "_";
241*c217d954SCole Faust _config_id += support::cpp11::to_string(src->dimension(width_idx));
242*c217d954SCole Faust _config_id += "_";
243*c217d954SCole Faust _config_id += support::cpp11::to_string(src->dimension(height_idx));
244*c217d954SCole Faust _config_id += "_";
245*c217d954SCole Faust _config_id += support::cpp11::to_string(src->dimension(channel_idx));
246*c217d954SCole Faust _config_id += "_";
247*c217d954SCole Faust _config_id += support::cpp11::to_string(dst->dimension(width_idx));
248*c217d954SCole Faust _config_id += "_";
249*c217d954SCole Faust _config_id += support::cpp11::to_string(dst->dimension(height_idx));
250*c217d954SCole Faust _config_id += "_";
251*c217d954SCole Faust _config_id += support::cpp11::to_string(dst->dimension(channel_idx));
252*c217d954SCole Faust }
253*c217d954SCole Faust
validate(const ITensorInfo * src,const ITensorInfo * weights,const ITensorInfo * biases,const ITensorInfo * indirect_buffer,const ITensorInfo * dst,const PadStrideInfo & conv_info,const ActivationLayerInfo & act_info,const DirectConvComputeKernelInfo & desc)254*c217d954SCole Faust Status ClIndirectConv2dKernel::validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *indirect_buffer, const ITensorInfo *dst,
255*c217d954SCole Faust const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info, const DirectConvComputeKernelInfo &desc)
256*c217d954SCole Faust {
257*c217d954SCole Faust ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, weights, biases, indirect_buffer, dst, conv_info, act_info, desc));
258*c217d954SCole Faust return Status{};
259*c217d954SCole Faust }
260*c217d954SCole Faust
run_op(ITensorPack & tensors,const Window & window,cl::CommandQueue & queue)261*c217d954SCole Faust void ClIndirectConv2dKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
262*c217d954SCole Faust {
263*c217d954SCole Faust ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
264*c217d954SCole Faust ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window);
265*c217d954SCole Faust
266*c217d954SCole Faust // Get initial windows
267*c217d954SCole Faust Window slice = window.first_slice_window_3D();
268*c217d954SCole Faust
269*c217d954SCole Faust const auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_0));
270*c217d954SCole Faust const auto weights = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_1));
271*c217d954SCole Faust const auto biases = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_2));
272*c217d954SCole Faust const auto indirect_buffer = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_3));
273*c217d954SCole Faust auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
274*c217d954SCole Faust
275*c217d954SCole Faust cl::Image2D weights_cl_image;
276*c217d954SCole Faust
277*c217d954SCole Faust if(_export_to_cl_image)
278*c217d954SCole Faust {
279*c217d954SCole Faust const size_t image_w = weights->info()->dimension(0) / 4;
280*c217d954SCole Faust const size_t image_h = weights->info()->dimension(1) * weights->info()->dimension(2) * weights->info()->dimension(3);
281*c217d954SCole Faust const TensorShape shape2d(image_w, image_h);
282*c217d954SCole Faust const size_t image_row_pitch = weights->info()->strides_in_bytes()[1];
283*c217d954SCole Faust
284*c217d954SCole Faust // Export cl_buffer to cl_image
285*c217d954SCole Faust weights_cl_image = create_image2d_from_buffer(CLKernelLibrary::get().context(), weights->cl_buffer(), shape2d, weights->info()->data_type(), image_row_pitch, CLImage2DType::ReadOnly);
286*c217d954SCole Faust }
287*c217d954SCole Faust
288*c217d954SCole Faust unsigned int idx = 0;
289*c217d954SCole Faust add_4d_tensor_nhwc_argument(idx, src);
290*c217d954SCole Faust add_4d_tensor_nhwc_argument(idx, indirect_buffer);
291*c217d954SCole Faust add_4d_tensor_nhwc_argument(idx, dst);
292*c217d954SCole Faust if(_export_to_cl_image)
293*c217d954SCole Faust {
294*c217d954SCole Faust _kernel.setArg(idx++, weights_cl_image);
295*c217d954SCole Faust }
296*c217d954SCole Faust add_4d_tensor_nhwc_argument(idx, weights);
297*c217d954SCole Faust if(biases != nullptr)
298*c217d954SCole Faust {
299*c217d954SCole Faust add_1D_tensor_argument(idx, biases, slice);
300*c217d954SCole Faust }
301*c217d954SCole Faust enqueue(queue, *this, slice, lws_hint());
302*c217d954SCole Faust }
303*c217d954SCole Faust } // namespace kernels
304*c217d954SCole Faust } // namespace opencl
305*c217d954SCole Faust } // namespace arm_compute
306