blob: c6c88569cec741d8119c7440428fcf55df5c1783 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgiob54ba282020-01-14 15:31:55 +00002 * Copyright (c) 2016-2020 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +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/CL/CLKernelLibrary.h"
25
steniu0134702472017-07-11 09:22:58 +010026#include "arm_compute/core/CL/CLHelpers.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027#include "arm_compute/core/Error.h"
28#include "arm_compute/core/Utils.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000029#include "support/StringSupport.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010030
steniu015f910722017-08-23 10:15:22 +010031#include <algorithm>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010032#include <fstream>
33#include <iostream>
34#include <utility>
35#include <vector>
36
37using namespace arm_compute;
38
Georgios Pinitas388d3ec2017-11-02 12:17:56 +000039CLBuildOptions::CLBuildOptions()
40 : _build_opts()
41{
42}
43
44void CLBuildOptions::add_option(std::string option)
45{
46 _build_opts.emplace(std::move(option));
47}
48
49void CLBuildOptions::add_option_if(bool cond, std::string option)
50{
51 if(cond)
52 {
53 add_option(std::move(option));
54 }
55}
56
57void CLBuildOptions::add_option_if_else(bool cond, std::string option_true, std::string option_false)
58{
59 (cond) ? add_option(std::move(option_true)) : add_option(std::move(option_false));
60}
61
Chunosovf450caa2017-11-08 16:09:35 +070062void CLBuildOptions::add_options(const StringSet &options)
63{
64 _build_opts.insert(options.begin(), options.end());
65}
66
67void CLBuildOptions::add_options_if(bool cond, const StringSet &options)
68{
69 if(cond)
70 {
71 add_options(options);
72 }
73}
74
Chunosovd621bca2017-11-03 17:33:15 +070075const CLBuildOptions::StringSet &CLBuildOptions::options() const
Georgios Pinitas388d3ec2017-11-02 12:17:56 +000076{
77 return _build_opts;
78}
79
Anthony Barbier6ff3b192017-09-04 18:44:23 +010080Program::Program()
81 : _context(), _device(), _is_binary(false), _name(), _source(), _binary()
82{
83}
84
85Program::Program(cl::Context context, std::string name, std::string source)
86 : _context(std::move(context)), _device(), _is_binary(false), _name(std::move(name)), _source(std::move(source)), _binary()
87{
88}
89
90Program::Program(cl::Context context, cl::Device device, std::string name, std::vector<unsigned char> binary)
91 : _context(std::move(context)), _device(std::move(device)), _is_binary(true), _name(std::move(name)), _source(), _binary(std::move(binary))
92{
93}
94
95Program::operator cl::Program() const
96{
97 if(_is_binary)
98 {
99 return cl::Program(_context, { _device }, { _binary });
100 }
101 else
102 {
103 return cl::Program(_context, _source, false);
104 }
105}
106
107bool Program::build(const cl::Program &program, const std::string &build_options)
108{
109 try
110 {
111 return program.build(build_options.c_str()) == CL_SUCCESS;
112 }
113 catch(const cl::Error &e)
114 {
115 cl_int err = CL_SUCCESS;
116 const auto build_info = program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(&err);
117
118 for(auto &pair : build_info)
119 {
120 std::cerr << pair.second << std::endl;
121 }
122
123 return false;
124 }
125}
126
127cl::Program Program::build(const std::string &build_options) const
128{
129 cl::Program cl_program = static_cast<cl::Program>(*this);
130 build(cl_program, build_options);
131 return cl_program;
132}
133
134Kernel::Kernel()
135 : _name(), _kernel()
136{
137}
138
139Kernel::Kernel(std::string name, const cl::Program &program)
140 : _name(std::move(name)),
141 _kernel(cl::Kernel(program, _name.c_str()))
142{
143}
144
145const std::map<std::string, std::string> CLKernelLibrary::_kernel_program_map =
146{
147 { "absdiff", "absdiff.cl" },
148 { "accumulate", "accumulate.cl" },
149 { "accumulate_squared", "accumulate.cl" },
150 { "accumulate_weighted", "accumulate.cl" },
151 { "activation_layer", "activation_layer.cl" },
Manuel Bottini30dbeef2019-06-26 16:23:03 +0100152 { "activation_layer_quant", "activation_layer_quant.cl" },
153 { "activation_layer_quant_f32", "activation_layer_quant.cl" },
Manuel Bottini7b9998d2019-10-21 17:59:07 +0100154 { "arg_min_max_x", "arg_min_max.cl" },
155 { "arg_min_max_y", "arg_min_max.cl" },
156 { "arg_min_max_z", "arg_min_max.cl" },
157 { "arg_min_max_w", "arg_min_max.cl" },
Michalis Spyrouf1addb62018-09-11 11:16:47 +0100158 { "batch_to_space_nchw", "batch_to_space.cl" },
159 { "batch_to_space_static_nchw", "batch_to_space.cl" },
160 { "batch_to_space_nhwc", "batch_to_space.cl" },
161 { "batch_to_space_static_nhwc", "batch_to_space.cl" },
Michele Di Giorgiobf3c6622018-03-08 11:52:27 +0000162 { "batchnormalization_layer_nchw", "batchnormalization_layer.cl" },
163 { "batchnormalization_layer_nhwc", "batchnormalization_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100164 { "bitwise_or", "bitwise_op.cl" },
165 { "bitwise_and", "bitwise_op.cl" },
166 { "bitwise_xor", "bitwise_op.cl" },
167 { "bitwise_not", "bitwise_op.cl" },
giuros01c04a0e82018-10-03 12:44:35 +0100168 { "bounding_box_transform", "bounding_box_transform.cl" },
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100169 { "bounding_box_transform_quantized", "bounding_box_transform_quantized.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100170 { "channel_combine_NV", "channel_combine.cl" },
171 { "channel_combine_RGB888", "channel_combine.cl" },
172 { "channel_combine_RGBA8888", "channel_combine.cl" },
173 { "channel_combine_UYVY422", "channel_combine.cl" },
174 { "channel_combine_YUYV422", "channel_combine.cl" },
Michele Di Giorgio72175632018-05-01 16:52:00 +0100175 { "channel_shuffle_nchw", "channel_shuffle.cl" },
Gian Marco Iodice8bab0ee2018-09-13 11:51:56 +0100176 { "channel_shuffle_nhwc", "channel_shuffle.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100177 { "channel_extract_NV12", "channel_extract.cl" },
178 { "channel_extract_NV21", "channel_extract.cl" },
179 { "channel_extract_RGB888", "channel_extract.cl" },
180 { "channel_extract_RGBA8888", "channel_extract.cl" },
181 { "channel_extract_UYVY422", "channel_extract.cl" },
182 { "channel_extract_YUYV422", "channel_extract.cl" },
183 { "combine_gradients_L1", "canny.cl" },
184 { "combine_gradients_L2", "canny.cl" },
Georgios Pinitas7900a9e2018-11-23 11:44:58 +0000185 { "compare_equal", "comparisons.cl" },
186 { "compare_equal_quantized", "comparisons.cl" },
187 { "compare_notequal", "comparisons.cl" },
188 { "compare_notequal_quantized", "comparisons.cl" },
189 { "compare_greater", "comparisons.cl" },
190 { "compare_greater_quantized", "comparisons.cl" },
191 { "compare_greaterequal", "comparisons.cl" },
192 { "compare_greaterequal_quantized", "comparisons.cl" },
193 { "compare_less", "comparisons.cl" },
194 { "compare_less_quantized", "comparisons.cl" },
195 { "compare_lessequal", "comparisons.cl" },
196 { "compare_lessequal_quantized", "comparisons.cl" },
Vidhya Sudhan Loganathan338595b2019-06-28 14:09:53 +0100197 { "concatenate", "concatenate.cl" },
Michalis Spyrou55b3d122018-05-09 09:59:23 +0100198 { "concatenate_width", "concatenate.cl" },
Pablo Tello6a14adb2019-03-05 17:33:08 +0000199 { "concatenate_height", "concatenate.cl" },
Michele Di Giorgio27400b92018-11-01 13:44:05 +0000200 { "concatenate_width_x2", "concatenate.cl" },
201 { "concatenate_width_x4", "concatenate.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100202 { "convolution_rectangle", "convolution_rectangle.cl" },
Gian Marco76faef82018-01-29 12:15:32 +0000203 { "col2im", "col2im.cl" },
Giorgio Arena657bdb32018-04-26 18:52:01 +0100204 { "convert_depth_down", "depth_convert.cl" },
205 { "convert_depth_up", "depth_convert.cl" },
206 { "convert_fc_weights", "convert_fc_weights.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100207 { "convolution3x3_static", "convolution3x3.cl" },
208 { "convolution5x5_static", "convolution5x5.cl" },
209 { "convolution7x7_static", "convolution7x7.cl" },
210 { "convolution9x9_static", "convolution9x9.cl" },
211 { "convolution_separable1x5_static", "convolution5x5.cl" },
212 { "convolution_separable5x1_static", "convolution5x5.cl" },
213 { "convolution_separable1x7_static", "convolution7x7.cl" },
214 { "convolution_separable7x1_static", "convolution7x7.cl" },
215 { "convolution_separable1x9_static", "convolution9x9.cl" },
216 { "convolution_separable9x1_static", "convolution9x9.cl" },
Michalis Spyrou5c8e05c2018-03-22 11:56:01 +0000217 { "copy_tensor", "copy_tensor.cl" },
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100218 { "copy_pad_tensor", "copy_tensor.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100219 { "copy_plane", "channel_extract.cl" },
220 { "copy_planes_3p", "channel_combine.cl" },
221 { "copy_to_keypoint", "fast_corners.cl" },
George Wort894066d2019-02-15 15:12:52 +0000222 { "crop_tensor", "crop_tensor.cl" },
giuros0146a49a02019-04-01 13:50:22 +0100223 { "deconvolution_reshape", "deconvolution_layer.cl" },
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000224 { "deconvolution_upsample", "deconvolution_layer.cl" },
Giorgio Arena93a690e2017-08-01 16:09:33 +0100225 { "depthwise_convolution_3x3", "depthwise_convolution.cl" },
Michele Di Giorgio933fe862018-02-19 15:42:12 +0000226 { "depthwise_convolution_3x3_f16", "depthwise_convolution.cl" },
Giorgio Arenad051e972018-06-20 11:46:42 +0100227 { "depthwise_convolution_3x3_nhwc", "depthwise_convolution.cl" },
228 { "depthwise_convolution_3x3_nhwc_stride1", "depthwise_convolution.cl" },
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100229 { "dwc_MxN_native_fp_nhwc", "depthwise_convolution.cl" },
Michele Di Giorgioa046e162019-10-08 09:36:26 +0100230 { "dwc_MxN_native_quantized8_nhwc", "depthwise_convolution_quantized.cl" },
Michele Di Giorgiodf4cf572019-10-09 15:32:39 +0100231 { "dwc_3x3_native_quantized8_nchw", "depthwise_convolution_quantized.cl" },
232 { "dwc_3x3_native_quantized8_dot8_nchw", "depthwise_convolution_quantized.cl" },
233 { "dwc_3x3_reshaped_quantized8_nhwc", "depthwise_convolution_quantized.cl" },
234 { "dwc_3x3_reshaped_quantized8_stride1_nhwc", "depthwise_convolution_quantized.cl" },
235 { "dwc_3x3_reshaped_quantized8_dot8_stride1_nhwc", "depthwise_convolution_quantized.cl" },
Michalis Spyrou649962c2019-05-22 11:11:55 +0100236 { "depth_to_space_nchw", "depth_to_space.cl" },
237 { "depth_to_space_nhwc", "depth_to_space.cl" },
Michele Di Giorgio3ebef322018-02-21 10:02:58 +0000238 { "depthwise_convolution_3x3_stridex1_stridey1_bifrost_f16", "depthwise_convolution.cl" },
239 { "depthwise_convolution_3x3_stridex2_stridey2_bifrost_f16", "depthwise_convolution.cl" },
240 { "depthwise_convolution_3x3_stridex1_stridey1_bifrost_f32", "depthwise_convolution.cl" },
241 { "depthwise_convolution_3x3_stridex2_stridey2_bifrost_f32", "depthwise_convolution.cl" },
giuros016d109962019-01-07 17:47:19 +0000242 { "depthwise_convolution_reshape_weights", "depthwise_convolution.cl" },
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100243 { "dequantization_layer", "dequantization_layer.cl" },
Michalis Spyrou3f632f32019-08-22 16:52:00 +0100244 { "dequantization_layer_per_channel_nhwc", "dequantization_layer.cl" },
245 { "dequantization_layer_per_channel_nchw", "dequantization_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100246 { "derivative", "derivative.cl" },
247 { "dilate", "dilate.cl" },
SiCong Lic51b72f2017-07-28 14:46:20 +0100248 { "direct_convolution1x1", "direct_convolution1x1.cl" },
Pablo Tello3d319462018-06-21 15:13:17 +0100249 { "direct_convolution1x1_nhwc", "direct_convolution1x1.cl" },
Gian Marco Iodice1c8409d2017-09-06 17:24:25 +0100250 { "direct_convolution1x1_f32_bifrost", "direct_convolution1x1.cl" },
SiCong Lic51b72f2017-07-28 14:46:20 +0100251 { "direct_convolution3x3", "direct_convolution3x3.cl" },
Pablo Tello3d319462018-06-21 15:13:17 +0100252 { "direct_convolution3x3_nhwc", "direct_convolution3x3.cl" },
Gian Marco Iodice1246b632017-08-16 18:38:32 +0100253 { "direct_convolution3x3_f32_bifrost", "direct_convolution3x3.cl" },
steniu01db006682017-08-09 16:26:22 +0100254 { "direct_convolution5x5", "direct_convolution5x5.cl" },
Pablo Tello3d319462018-06-21 15:13:17 +0100255 { "direct_convolution5x5_nhwc", "direct_convolution5x5.cl" },
Gian Marco Iodice1246b632017-08-16 18:38:32 +0100256 { "direct_convolution5x5_f32_bifrost", "direct_convolution5x5.cl" },
Sang-Hoon Parkab5b1a22019-10-15 09:29:13 +0100257 { "direct_convolution_quantized", "direct_convolution_quantized.cl" },
Michalis Spyrou45091732019-05-13 17:41:01 +0100258 { "direct_convolution9x9_nhwc", "direct_convolution9x9.cl" },
giuros01164a2722018-11-20 18:34:46 +0000259 { "elementwise_operation_ADD", "elementwise_operation.cl" },
260 { "elementwise_operation_SUB", "elementwise_operation.cl" },
261 { "elementwise_operation_MAX", "elementwise_operation.cl" },
262 { "elementwise_operation_MIN", "elementwise_operation.cl" },
263 { "elementwise_operation_DIV", "elementwise_operation.cl" },
264 { "elementwise_operation_SQUARED_DIFF", "elementwise_operation.cl" },
Usama Arif52c54f62019-05-14 10:22:36 +0100265 { "elementwise_operation_POWER", "elementwise_operation.cl" },
giuros011e6e1b82019-05-14 16:12:53 +0100266 { "elementwise_operation_PRELU", "elementwise_operation.cl" },
giuros01164a2722018-11-20 18:34:46 +0000267 { "elementwise_operation_ADD_quantized", "elementwise_operation_quantized.cl" },
268 { "elementwise_operation_SUB_quantized", "elementwise_operation_quantized.cl" },
269 { "elementwise_operation_MAX_quantized", "elementwise_operation_quantized.cl" },
270 { "elementwise_operation_MIN_quantized", "elementwise_operation_quantized.cl" },
271 { "elementwise_operation_DIV_quantized", "elementwise_operation_quantized.cl" },
272 { "elementwise_operation_SQUARED_DIFF_quantized", "elementwise_operation_quantized.cl" },
giuros011e6e1b82019-05-14 16:12:53 +0100273 { "elementwise_operation_PRELU_quantized", "elementwise_operation_quantized.cl" },
Michalis Spyroue9362622018-11-23 17:41:37 +0000274 { "elementwise_unary", "elementwise_unary.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100275 { "erode", "erode.cl" },
276 { "fast_corners", "fast_corners.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000277 { "fft_digit_reverse_axis_0", "fft_digit_reverse.cl" },
278 { "fft_digit_reverse_axis_1", "fft_digit_reverse.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000279 { "fft_radix_2_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000280 { "fft_radix_2_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000281 { "fft_radix_2_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000282 { "fft_radix_2_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000283 { "fft_radix_3_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000284 { "fft_radix_3_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000285 { "fft_radix_3_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000286 { "fft_radix_3_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000287 { "fft_radix_4_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000288 { "fft_radix_4_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000289 { "fft_radix_4_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000290 { "fft_radix_4_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000291 { "fft_radix_5_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000292 { "fft_radix_5_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000293 { "fft_radix_5_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000294 { "fft_radix_5_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000295 { "fft_radix_7_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000296 { "fft_radix_7_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000297 { "fft_radix_7_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000298 { "fft_radix_7_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000299 { "fft_radix_8_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000300 { "fft_radix_8_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000301 { "fft_radix_8_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000302 { "fft_radix_8_axis_1", "fft.cl" },
303 { "fft_scale_conj", "fft_scale.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100304 { "fill_image_borders_constant", "fill_border.cl" },
305 { "fill_image_borders_replicate", "fill_border.cl" },
306 { "finalize", "optical_flow_pyramid_lk.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000307 { "flatten", "flatten.cl" },
Georgios Pinitasd8e765b2017-08-02 13:44:33 +0100308 { "floor_layer", "floor.cl" },
Manuel Bottini2732cca2019-05-28 11:44:41 +0100309 { "fuse_batchnormalization_layer", "batchnormalization_layer.cl" },
Manuel Bottini8529bd62018-11-21 11:53:04 +0000310 { "gather", "gather.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100311 { "gaussian1x5_sub_x", "gaussian_pyramid.cl" },
312 { "gaussian5x1_sub_y", "gaussian_pyramid.cl" },
Gian Marco Iodice578ab612017-06-23 09:34:33 +0100313 { "gemm_accumulate_biases", "gemm.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100314 { "gemm_ma_f16", "gemm.cl" },
315 { "gemm_ma_f32", "gemm.cl" },
Giorgio Arena9fe41442017-08-23 16:36:24 +0100316 { "gemm_mv", "gemv.cl" },
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000317 { "gemm_mv_quantized", "gemv.cl" },
Gian Marco Iodiceedfa9f42017-08-15 11:45:22 +0100318 { "gemm_mm_interleaved_transposed_f16", "gemm.cl" },
Vidhya Sudhan Loganathan38d93bd2018-11-20 15:38:13 +0000319 { "gemm_mm_interleaved_transposed_f16_acc32", "gemm.cl" },
Gian Marco Iodicebb36a8e2018-04-19 12:05:08 +0100320 { "gemm_mm_interleaved_transposed_f16_bifrost", "gemm.cl" },
321 { "gemm_mm_interleaved_transposed_f32", "gemm.cl" },
Gian Marco Iodiceedfa9f42017-08-15 11:45:22 +0100322 { "gemm_mm_interleaved_transposed_f32_bifrost", "gemm.cl" },
Gian Marco Iodiceedfa9f42017-08-15 11:45:22 +0100323 { "gemm_mm_floating_point", "gemm.cl" },
Gian Marco Iodicefd683112018-04-17 09:52:44 +0100324 { "gemm_mm_floating_point_f16_bifrost", "gemm.cl" },
Vidhya Sudhan Loganathana25d16c2018-11-16 11:33:12 +0000325 { "gemm_mm_floating_point_f16_bifrost_acc32", "gemm.cl" },
Anton Lokhmotov3e80c7f2017-11-20 11:02:10 +0000326 { "gemm_mm_floating_point_f32_bifrost", "gemm.cl" },
327 { "gemm_mm_floating_point_f32_bifrost_1000", "gemm.cl" },
giuros01b3204e72019-04-01 13:50:22 +0100328 { "gemm_mm_native", "gemm.cl" },
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000329 { "gemm_mm_reshaped_lhs_nt_rhs_t", "gemm.cl" },
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100330 { "gemm_mm_reshaped_lhs_t_rhs_nt", "gemm.cl" },
Gian Marco Iodiceba5e0962019-03-11 12:17:44 +0000331 { "gemm_mm_reshaped_only_rhs_nt", "gemm.cl" },
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000332 { "gemm_mm_reshaped_only_rhs_t", "gemm.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100333 { "gemm_lc_vm_f32", "gemm.cl" },
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000334 { "gemm_reshape_lhs_matrix_nt", "gemm.cl" },
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +0000335 { "gemm_reshape_lhs_matrix_t", "gemm.cl" },
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000336 { "gemm_reshape_rhs_matrix_nt", "gemm.cl" },
337 { "gemm_reshape_rhs_matrix_t", "gemm.cl" },
Gian Marco05288a22017-11-21 10:57:50 +0000338 { "gemmlowp_matrix_a_reduction", "gemmlowp.cl" },
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100339 { "gemmlowp_matrix_a_reduction_dot8", "gemmlowp.cl" },
Gian Marco05288a22017-11-21 10:57:50 +0000340 { "gemmlowp_matrix_b_reduction", "gemmlowp.cl" },
Gian Marco7b4d5472018-01-10 15:56:30 +0000341 { "gemmlowp_mm_midgard", "gemmlowp.cl" },
Gian Marco Iodicee7510622019-06-03 17:28:17 +0100342 { "gemmlowp_mm_native", "gemmlowp.cl" },
Gian Marco Iodicedb63b9c2019-01-17 09:47:04 +0000343 { "gemmlowp_mm_reshaped_lhs_nt_rhs_t", "gemmlowp.cl" },
Gian Marco Iodice62251f72019-03-11 16:07:12 +0000344 { "gemmlowp_mm_reshaped_only_rhs_t", "gemmlowp.cl" },
Michele Di Giorgiob54ba282020-01-14 15:31:55 +0000345 { "gemmlowp_mm_reshaped_only_rhs_t_fused_output_stage_fixedpoint", "gemmlowp.cl" },
Gian Marco05288a22017-11-21 10:57:50 +0000346 { "gemmlowp_offset_contribution", "gemmlowp.cl" },
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100347 { "gemmlowp_offset_contribution_quantize_down", "gemmlowp.cl" },
348 { "gemmlowp_offset_contribution_quantize_down_fixedpoint", "gemmlowp.cl" },
Gian Marco05288a22017-11-21 10:57:50 +0000349 { "gemmlowp_output_stage_quantize_down", "gemmlowp.cl" },
Gian Marco58c57942017-11-28 09:10:03 +0000350 { "gemmlowp_output_stage_quantize_down_fixedpoint", "gemmlowp.cl" },
Manuel Bottini9c9b70b2019-07-01 17:35:56 +0100351 { "gemmlowp_output_stage_quantize_down_fixedpoint_qsymm16", "gemmlowp.cl" },
Georgios Pinitas51e53a32018-10-22 13:49:08 +0100352 { "gemmlowp_output_stage_quantize_down_float", "gemmlowp.cl" },
Manuel Bottini5209be52019-02-13 16:34:56 +0000353 { "generate_proposals_compute_all_anchors", "generate_proposals.cl" },
Michele Di Giorgio6b612f52019-09-05 12:30:22 +0100354 { "generate_proposals_compute_all_anchors_quantized", "generate_proposals_quantized.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100355 { "harris_score_3x3", "harris_corners.cl" },
356 { "harris_score_5x5", "harris_corners.cl" },
357 { "harris_score_7x7", "harris_corners.cl" },
358 { "hist_border_kernel", "histogram.cl" },
359 { "hist_border_kernel_fixed", "histogram.cl" },
360 { "hist_local_kernel", "histogram.cl" },
361 { "hist_local_kernel_fixed", "histogram.cl" },
362 { "hog_block_normalization", "hog.cl" },
363 { "hog_detector", "hog.cl" },
364 { "hog_orientation_binning", "hog.cl" },
365 { "hysteresis", "canny.cl" },
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +0100366 { "im2col1x1_stridex1_nchw", "im2col.cl" },
367 { "im2col3x3_nchw", "im2col.cl" },
368 { "im2col5x5_nchw", "im2col.cl" },
369 { "im2col11x11_padx0_pady0_nchw", "im2col.cl" },
370 { "im2col_generic_nchw", "im2col.cl" },
371 { "im2col_generic_padx0_pady0_nchw", "im2col.cl" },
Pablo Tello4a626a72018-04-04 10:01:14 +0100372 { "im2col3x3_nhwc", "im2col.cl" },
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000373 { "im2col9x9_nhwc", "im2col.cl" },
Pablo Tello4a626a72018-04-04 10:01:14 +0100374 { "im2col_generic_nhwc", "im2col.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100375 { "init_level", "optical_flow_pyramid_lk.cl" },
376 { "init_level_max", "optical_flow_pyramid_lk.cl" },
377 { "init_level_max_initial_estimate", "optical_flow_pyramid_lk.cl" },
Manuel Bottini79f88e62019-09-18 15:02:53 +0100378 { "instance_normalization", "instance_normalization.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100379 { "integral_horizontal", "integral_image.cl" },
380 { "integral_vertical", "integral_image.cl" },
381 { "IYUV_to_NV12_bt709", "color_convert.cl" },
382 { "IYUV_to_RGB888_bt709", "color_convert.cl" },
383 { "IYUV_to_RGBA8888_bt709", "color_convert.cl" },
384 { "IYUV_to_YUV444_bt709", "color_convert.cl" },
Michalis Spyrou5538d342018-11-14 08:10:13 +0000385 { "l2_normalize_x", "l2_normalize.cl" },
386 { "l2_normalize_y", "l2_normalize.cl" },
387 { "l2_normalize_z", "l2_normalize.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100388 { "lktracker_stage0", "optical_flow_pyramid_lk.cl" },
389 { "lktracker_stage1", "optical_flow_pyramid_lk.cl" },
390 { "magnitude_phase", "magnitude_phase.cl" },
391 { "mean_stddev_accumulate", "mean_stddev.cl" },
Michele Di Giorgio5b48ad72019-06-04 18:43:35 +0100392 { "mean_stddev_normalization", "mean_stddev_normalization.cl" },
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100393 { "memset", "memset.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100394 { "minmax", "minmaxloc.cl" },
395 { "minmax_border", "minmaxloc.cl" },
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100396 { "minmax_layer", "minmax_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100397 { "minmaxloc", "minmaxloc.cl" },
398 { "non_linear_filter_box3x3", "non_linear_filter3x3.cl" },
399 { "non_linear_filter_cross3x3", "non_linear_filter3x3.cl" },
400 { "non_linear_filter_disk3x3", "non_linear_filter3x3.cl" },
401 { "non_linear_filter_box5x5", "non_linear_filter5x5.cl" },
402 { "non_linear_filter_cross5x5", "non_linear_filter5x5.cl" },
403 { "non_linear_filter_disk5x5", "non_linear_filter5x5.cl" },
404 { "non_max_suppression", "nonmax.cl" },
405 { "normalization_layer_cross_map", "normalization_layer.cl" },
Michele Di Giorgio9d3a8312018-11-20 12:31:24 +0000406 { "normalization_layer_in_map_nchw", "normalization_layer.cl" },
407 { "normalization_layer_in_map_nhwc", "normalization_layer.cl" },
Michele Di Giorgiob57be0d2018-08-31 16:26:25 +0100408 { "normalize_planar_yuv_layer_nchw", "normalize_planar_yuv_layer.cl" },
409 { "normalize_planar_yuv_layer_nhwc", "normalize_planar_yuv_layer.cl" },
Michele Di Giorgiod63dfa22018-09-12 10:18:54 +0100410 { "normalize_planar_yuv_layer_q8_nchw", "normalize_planar_yuv_layer_quantized.cl" },
411 { "normalize_planar_yuv_layer_q8_nhwc", "normalize_planar_yuv_layer_quantized.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100412 { "NV12_to_IYUV_bt709", "color_convert.cl" },
413 { "NV12_to_RGB888_bt709", "color_convert.cl" },
414 { "NV12_to_RGBA8888_bt709", "color_convert.cl" },
415 { "NV12_to_YUV444_bt709", "color_convert.cl" },
416 { "NV21_to_IYUV_bt709", "color_convert.cl" },
417 { "NV21_to_RGB888_bt709", "color_convert.cl" },
418 { "NV21_to_RGBA8888_bt709", "color_convert.cl" },
419 { "NV21_to_YUV444_bt709", "color_convert.cl" },
Giorgio Arena5c4a8e92019-08-28 17:55:07 +0100420 { "pad_layer_constant", "pad_layer.cl" },
421 { "pad_layer_symmetric_reflect", "pad_layer.cl" },
shubhame1a4e372019-01-07 21:37:55 +0530422 { "permute", "permute.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000423 { "pixelwise_mul_complex", "pixelwise_mul_float.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100424 { "pixelwise_mul_float", "pixelwise_mul_float.cl" },
425 { "pixelwise_mul_int", "pixelwise_mul_int.cl" },
Georgios Pinitasbf28a3c2018-09-18 14:34:48 +0100426 { "pixelwise_mul_quantized", "pixelwise_mul_int.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100427 { "pooling_layer_2", "pooling_layer.cl" },
428 { "pooling_layer_3", "pooling_layer.cl" },
Anton Lokhmotovaf6204c2017-11-08 09:34:19 +0000429 { "pooling_layer_optimized_3", "pooling_layer.cl" },
Georgios Pinitasce093142017-06-19 16:11:53 +0100430 { "pooling_layer_7", "pooling_layer.cl" },
Michalis Spyroue74b2012018-04-18 09:49:16 +0100431 { "pooling_layer_MxN_nchw", "pooling_layer.cl" },
432 { "pooling_layer_MxN_nhwc", "pooling_layer.cl" },
433 { "pooling_layer_MxN_quantized_nhwc", "pooling_layer_quantized.cl" },
434 { "pooling_layer_MxN_quantized_nchw", "pooling_layer_quantized.cl" },
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +0100435 { "prior_box_layer_nchw", "prior_box_layer.cl" },
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100436 { "quantization_layer", "quantization_layer.cl" },
Vidhya Sudhan Loganathan5e96be72018-12-18 14:17:00 +0000437 { "range", "range.cl" },
438 { "range_quantized", "range.cl" },
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100439 { "reduction_operation_x", "reduction_operation.cl" },
Michalis Spyrou7930db42018-11-22 17:36:28 +0000440 { "reduction_operation_non_parallel_x", "reduction_operation.cl" },
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100441 { "reduction_operation_y", "reduction_operation.cl" },
442 { "reduction_operation_z", "reduction_operation.cl" },
443 { "reduction_operation_w", "reduction_operation.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100444 { "remap_nearest_neighbour", "remap.cl" },
445 { "remap_bilinear", "remap.cl" },
Gian Marco Iodice477531c2018-08-21 17:53:38 +0100446 { "reorg_layer_nchw", "reorg_layer.cl" },
447 { "reorg_layer_nhwc", "reorg_layer.cl" },
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +0100448 { "reshape_layer", "reshape_layer.cl" },
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +0100449 { "reshape_to_columns", "convolution_layer.cl" },
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000450 { "reverse", "reverse.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100451 { "RGB888_to_IYUV_bt709", "color_convert.cl" },
452 { "RGB888_to_NV12_bt709", "color_convert.cl" },
453 { "RGB888_to_RGBA8888_bt709", "color_convert.cl" },
Manuel Bottiniacaf21d2018-09-26 17:38:19 +0100454 { "RGB888_to_U8_bt709", "color_convert.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100455 { "RGB888_to_YUV444_bt709", "color_convert.cl" },
456 { "RGBA8888_to_IYUV_bt709", "color_convert.cl" },
457 { "RGBA8888_to_NV12_bt709", "color_convert.cl" },
458 { "RGBA8888_to_RGB888_bt709", "color_convert.cl" },
459 { "RGBA8888_to_YUV444_bt709", "color_convert.cl" },
giuros0118870812018-09-13 09:31:40 +0100460 { "roi_align_layer", "roi_align_layer.cl" },
Michele Di Giorgio578a9fc2019-08-23 11:49:04 +0100461 { "roi_align_layer_quantized", "roi_align_layer_quantized.cl" },
SiCong Li3e363692017-07-04 15:02:10 +0100462 { "roi_pooling_layer", "roi_pooling_layer.cl" },
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100463 { "scale_nearest_neighbour_nchw", "scale.cl" },
464 { "scale_nearest_neighbour_nhwc", "scale.cl" },
465 { "scale_bilinear_nchw", "scale.cl" },
466 { "scale_bilinear_nhwc", "scale.cl" },
Michalis Spyrou17220e22018-09-12 13:35:38 +0100467 { "scale_bilinear_quantized_nchw", "scale_quantized.cl" },
468 { "scale_bilinear_quantized_nhwc", "scale_quantized.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100469 { "scharr3x3", "scharr_filter.cl" },
Georgios Pinitasaaa27182018-11-21 16:32:15 +0000470 { "select_same_rank", "select.cl" },
471 { "select_different_rank_2", "select.cl" },
472 { "select_different_rank_n", "select.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100473 { "sobel3x3", "sobel_filter.cl" },
474 { "sobel_separable5x1", "sobel_filter.cl" },
475 { "sobel_separable1x5", "sobel_filter.cl" },
476 { "sobel_separable7x1", "sobel_filter.cl" },
477 { "sobel_separable1x7", "sobel_filter.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100478 { "softmax_layer_norm", "softmax_layer.cl" },
Chunosovf450caa2017-11-08 16:09:35 +0700479 { "softmax_layer_norm_quantized", "softmax_layer_quantized.cl" },
Giorgio Arena4402cb92018-02-15 13:37:40 +0000480 { "softmax_layer_max_shift_exp_sum_quantized_serial", "softmax_layer_quantized.cl" },
481 { "softmax_layer_max_shift_exp_sum_quantized_parallel", "softmax_layer_quantized.cl" },
Chunosovd6afedc2017-11-06 22:09:45 +0700482 { "softmax_layer_max_shift_exp_sum_serial", "softmax_layer.cl" },
Michalis Spyrou13a51e12018-09-18 13:09:30 +0100483 { "space_to_batch_nchw", "space_to_batch.cl" },
484 { "space_to_batch_static_nchw", "space_to_batch.cl" },
485 { "space_to_batch_nhwc", "space_to_batch.cl" },
486 { "space_to_batch_static_nhwc", "space_to_batch.cl" },
Michalis Spyroud69b3b22019-05-29 17:03:38 +0100487 { "space_to_depth_nchw", "space_to_depth.cl" },
488 { "space_to_depth_nhwc", "space_to_depth.cl" },
Chunosovd6afedc2017-11-06 22:09:45 +0700489 { "softmax_layer_max_shift_exp_sum_parallel", "softmax_layer.cl" },
Gian Marco Iodice8aa985e2018-11-27 15:58:08 +0000490 { "stack_layer", "stack_layer.cl" },
Georgios Pinitasc1a72452018-08-24 11:25:32 +0100491 { "strided_slice", "slice_ops.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100492 { "suppress_non_maximum", "canny.cl" },
493 { "tablelookup_U8", "tablelookup.cl" },
494 { "tablelookup_S16", "tablelookup.cl" },
495 { "threshold_binary", "threshold.cl" },
496 { "threshold_range", "threshold.cl" },
giuros013175fcf2018-11-21 09:59:17 +0000497 { "tile", "tile.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100498 { "transpose", "transpose.cl" },
499 { "UYVY422_to_IYUV_bt709", "color_convert.cl" },
500 { "UYVY422_to_NV12_bt709", "color_convert.cl" },
501 { "UYVY422_to_RGB888_bt709", "color_convert.cl" },
502 { "UYVY422_to_RGBA8888_bt709", "color_convert.cl" },
Michalis Spyrouceb889e2018-09-17 18:24:41 +0100503 { "upsample_layer_nchw", "upsample_layer.cl" },
504 { "upsample_layer_nhwc", "upsample_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100505 { "warp_affine_nearest_neighbour", "warp_affine.cl" },
506 { "warp_affine_bilinear", "warp_affine.cl" },
507 { "warp_perspective_nearest_neighbour", "warp_perspective.cl" },
508 { "warp_perspective_bilinear", "warp_perspective.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100509 { "winograd_filter_transform_2x2_3x3_nchw", "winograd_filter_transform.cl" },
510 { "winograd_filter_transform_2x1_3x1_nchw", "winograd_filter_transform.cl" },
511 { "winograd_filter_transform_1x2_1x3_nchw", "winograd_filter_transform.cl" },
512 { "winograd_filter_transform_4x4_3x3_nchw", "winograd_filter_transform.cl" },
513 { "winograd_filter_transform_4x1_3x1_nchw", "winograd_filter_transform.cl" },
514 { "winograd_filter_transform_1x4_1x3_nchw", "winograd_filter_transform.cl" },
515 { "winograd_filter_transform_4x4_5x5_nchw", "winograd_filter_transform.cl" },
Gian Marco Iodice876be2a2018-07-03 12:22:09 +0100516 { "winograd_filter_transform_4x1_5x1_nchw", "winograd_filter_transform.cl" },
517 { "winograd_filter_transform_1x4_1x5_nchw", "winograd_filter_transform.cl" },
Giorgio Arena149fdf32018-07-04 17:03:33 +0100518 { "winograd_filter_transform_4x1_3x1_nhwc", "winograd_filter_transform.cl" },
519 { "winograd_filter_transform_1x4_1x3_nhwc", "winograd_filter_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100520 { "winograd_filter_transform_4x4_3x3_nhwc", "winograd_filter_transform.cl" },
521 { "winograd_filter_transform_4x4_5x5_nhwc", "winograd_filter_transform.cl" },
Gian Marco Iodiced28b7512018-07-06 12:59:28 +0100522 { "winograd_filter_transform_4x1_5x1_nhwc", "winograd_filter_transform.cl" },
523 { "winograd_filter_transform_1x4_1x5_nhwc", "winograd_filter_transform.cl" },
Michele Di Giorgio881c6842019-02-27 14:26:51 +0000524 { "winograd_filter_transform_2x2_7x7_nhwc", "winograd_filter_transform.cl" },
525 { "winograd_filter_transform_2x1_7x1_nhwc", "winograd_filter_transform.cl" },
526 { "winograd_filter_transform_1x2_1x7_nhwc", "winograd_filter_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100527 { "winograd_input_transform_2x2_3x3_stepz1_nchw", "winograd_input_transform.cl" },
528 { "winograd_input_transform_2x2_3x3_stepz2_nchw", "winograd_input_transform.cl" },
529 { "winograd_input_transform_2x1_3x1_stepz1_nchw", "winograd_input_transform.cl" },
530 { "winograd_input_transform_2x1_3x1_stepz2_nchw", "winograd_input_transform.cl" },
531 { "winograd_input_transform_1x2_1x3_stepz1_nchw", "winograd_input_transform.cl" },
532 { "winograd_input_transform_1x2_1x3_stepz2_nchw", "winograd_input_transform.cl" },
533 { "winograd_input_transform_4x4_3x3_stepz1_nchw", "winograd_input_transform.cl" },
534 { "winograd_input_transform_4x1_3x1_stepz1_nchw", "winograd_input_transform.cl" },
535 { "winograd_input_transform_1x4_1x3_stepz1_nchw", "winograd_input_transform.cl" },
536 { "winograd_input_transform_4x4_5x5_stepz1_nchw", "winograd_input_transform.cl" },
Gian Marco Iodice876be2a2018-07-03 12:22:09 +0100537 { "winograd_input_transform_4x1_5x1_stepz1_nchw", "winograd_input_transform.cl" },
538 { "winograd_input_transform_1x4_1x5_stepz1_nchw", "winograd_input_transform.cl" },
Giorgio Arena149fdf32018-07-04 17:03:33 +0100539 { "winograd_input_transform_4x1_3x1_stepz1_nhwc", "winograd_input_transform.cl" },
540 { "winograd_input_transform_1x4_1x3_stepz1_nhwc", "winograd_input_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100541 { "winograd_input_transform_4x4_3x3_stepz1_nhwc", "winograd_input_transform.cl" },
542 { "winograd_input_transform_4x4_5x5_stepz1_nhwc", "winograd_input_transform.cl" },
Gian Marco Iodiced28b7512018-07-06 12:59:28 +0100543 { "winograd_input_transform_4x1_5x1_stepz1_nhwc", "winograd_input_transform.cl" },
544 { "winograd_input_transform_1x4_1x5_stepz1_nhwc", "winograd_input_transform.cl" },
Michele Di Giorgiof955d512019-02-27 14:26:51 +0000545 { "winograd_input_transform_2x2_7x7_stepz1_nhwc", "winograd_input_transform.cl" },
546 { "winograd_input_transform_2x1_7x1_stepz1_nhwc", "winograd_input_transform.cl" },
547 { "winograd_input_transform_1x2_1x7_stepz1_nhwc", "winograd_input_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100548 { "winograd_output_transform_2x2_3x3_nchw", "winograd_output_transform.cl" },
549 { "winograd_output_transform_2x1_3x1_nchw", "winograd_output_transform.cl" },
550 { "winograd_output_transform_1x2_1x3_nchw", "winograd_output_transform.cl" },
551 { "winograd_output_transform_4x4_3x3_nchw", "winograd_output_transform.cl" },
552 { "winograd_output_transform_4x1_3x1_nchw", "winograd_output_transform.cl" },
553 { "winograd_output_transform_1x4_1x3_nchw", "winograd_output_transform.cl" },
554 { "winograd_output_transform_4x4_5x5_nchw", "winograd_output_transform.cl" },
Gian Marco Iodice876be2a2018-07-03 12:22:09 +0100555 { "winograd_output_transform_4x1_5x1_nchw", "winograd_output_transform.cl" },
556 { "winograd_output_transform_1x4_1x5_nchw", "winograd_output_transform.cl" },
Giorgio Arena149fdf32018-07-04 17:03:33 +0100557 { "winograd_output_transform_4x1_3x1_nhwc", "winograd_output_transform.cl" },
558 { "winograd_output_transform_1x4_1x3_nhwc", "winograd_output_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100559 { "winograd_output_transform_4x4_3x3_nhwc", "winograd_output_transform.cl" },
560 { "winograd_output_transform_4x4_5x5_nhwc", "winograd_output_transform.cl" },
Gian Marco Iodiced28b7512018-07-06 12:59:28 +0100561 { "winograd_output_transform_4x1_5x1_nhwc", "winograd_output_transform.cl" },
562 { "winograd_output_transform_1x4_1x5_nhwc", "winograd_output_transform.cl" },
giuros013bfacb22019-04-01 12:07:02 +0100563 { "winograd_output_transform_2x2_7x7_nhwc", "winograd_output_transform.cl" },
564 { "winograd_output_transform_2x1_7x1_nhwc", "winograd_output_transform.cl" },
565 { "winograd_output_transform_1x2_1x7_nhwc", "winograd_output_transform.cl" },
Giorgio Arena73023022018-09-04 14:55:55 +0100566 { "yolo_layer_nchw", "yolo_layer.cl" },
567 { "yolo_layer_nhwc", "yolo_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100568 { "YUYV422_to_IYUV_bt709", "color_convert.cl" },
569 { "YUYV422_to_NV12_bt709", "color_convert.cl" },
570 { "YUYV422_to_RGB888_bt709", "color_convert.cl" },
571 { "YUYV422_to_RGBA8888_bt709", "color_convert.cl" },
572};
573
574const std::map<std::string, std::string> CLKernelLibrary::_program_source_map =
575{
576#ifdef EMBEDDED_KERNELS
577 {
578 "absdiff.cl",
579#include "./cl_kernels/absdiff.clembed"
580 },
581 {
582 "accumulate.cl",
583#include "./cl_kernels/accumulate.clembed"
584 },
585 {
586 "activation_layer.cl",
587#include "./cl_kernels/activation_layer.clembed"
588 },
589 {
Manuel Bottini30dbeef2019-06-26 16:23:03 +0100590 "activation_layer_quant.cl",
591#include "./cl_kernels/activation_layer_quant.clembed"
Michel Iwaniec00633802017-10-12 14:14:15 +0100592 },
593 {
Manuel Bottini7b9998d2019-10-21 17:59:07 +0100594 "arg_min_max.cl",
595#include "./cl_kernels/arg_min_max.clembed"
596 },
597 {
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +0100598 "batch_to_space.cl",
599#include "./cl_kernels/batch_to_space.clembed"
600 },
601 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100602 "bitwise_op.cl",
603#include "./cl_kernels/bitwise_op.clembed"
604 },
605 {
giuros01c04a0e82018-10-03 12:44:35 +0100606 "bounding_box_transform.cl",
607#include "./cl_kernels/bounding_box_transform.clembed"
608 },
609 {
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100610 "bounding_box_transform_quantized.cl",
611#include "./cl_kernels/bounding_box_transform_quantized.clembed"
612 },
613 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100614 "canny.cl",
615#include "./cl_kernels/canny.clembed"
616 },
617 {
618 "channel_combine.cl",
619#include "./cl_kernels/channel_combine.clembed"
620 },
621 {
622 "channel_extract.cl",
623#include "./cl_kernels/channel_extract.clembed"
624 },
625 {
Michele Di Giorgio72175632018-05-01 16:52:00 +0100626 "channel_shuffle.cl",
627#include "./cl_kernels/channel_shuffle.clembed"
628 },
629 {
Gian Marco76faef82018-01-29 12:15:32 +0000630 "col2im.cl",
631#include "./cl_kernels/col2im.clembed"
632 },
633 {
Georgios Pinitas7900a9e2018-11-23 11:44:58 +0000634 "comparisons.cl",
635#include "./cl_kernels/comparisons.clembed"
636 },
637 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100638 "concatenate.cl",
639#include "./cl_kernels/concatenate.clembed"
640 },
641 {
642 "color_convert.cl",
643#include "./cl_kernels/color_convert.clembed"
644 },
645 {
Giorgio Arena657bdb32018-04-26 18:52:01 +0100646 "convert_fc_weights.cl",
647#include "./cl_kernels/convert_fc_weights.clembed"
648 },
649 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100650 "convolution3x3.cl",
651#include "./cl_kernels/convolution3x3.clembed"
652 },
653 {
654 "convolution5x5.cl",
655#include "./cl_kernels/convolution5x5.clembed"
656 },
657 {
658 "convolution7x7.cl",
659#include "./cl_kernels/convolution7x7.clembed"
660 },
661 {
662 "convolution9x9.cl",
663#include "./cl_kernels/convolution9x9.clembed"
664 },
665 {
666 "convolution_layer.cl",
667#include "./cl_kernels/convolution_layer.clembed"
668 },
669 {
670 "convolution_rectangle.cl",
671#include "./cl_kernels/convolution_rectangle.clembed"
672 },
673 {
Michalis Spyrou5c8e05c2018-03-22 11:56:01 +0000674 "copy_tensor.cl",
675#include "./cl_kernels/copy_tensor.clembed"
676 },
677 {
George Wort894066d2019-02-15 15:12:52 +0000678 "crop_tensor.cl",
679#include "./cl_kernels/crop_tensor.clembed"
680 },
681 {
Michalis Spyrouceb889e2018-09-17 18:24:41 +0100682 "upsample_layer.cl",
683#include "./cl_kernels/upsample_layer.clembed"
684 },
685 {
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000686 "deconvolution_layer.cl",
687#include "./cl_kernels/deconvolution_layer.clembed"
688 },
689 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100690 "depth_convert.cl",
691#include "./cl_kernels/depth_convert.clembed"
692 },
693 {
Michalis Spyrou649962c2019-05-22 11:11:55 +0100694 "depth_to_space.cl",
695#include "./cl_kernels/depth_to_space.clembed"
696 },
697 {
Giorgio Arena93a690e2017-08-01 16:09:33 +0100698 "depthwise_convolution.cl",
699#include "./cl_kernels/depthwise_convolution.clembed"
700 },
701 {
Dmitry Savenkod7295b72017-11-20 22:00:08 +0700702 "depthwise_convolution_quantized.cl",
703#include "./cl_kernels/depthwise_convolution_quantized.clembed"
704 },
705 {
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100706 "dequantization_layer.cl",
707#include "./cl_kernels/dequantization_layer.clembed"
708 },
709 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100710 "derivative.cl",
711#include "./cl_kernels/derivative.clembed"
712 },
713 {
714 "dilate.cl",
715#include "./cl_kernels/dilate.clembed"
716 },
717 {
SiCong Lic51b72f2017-07-28 14:46:20 +0100718 "direct_convolution1x1.cl",
719#include "./cl_kernels/direct_convolution1x1.clembed"
720 },
721 {
722 "direct_convolution3x3.cl",
723#include "./cl_kernels/direct_convolution3x3.clembed"
steniu0127b386c2017-07-18 17:37:43 +0100724 },
725 {
steniu01db006682017-08-09 16:26:22 +0100726 "direct_convolution5x5.cl",
727#include "./cl_kernels/direct_convolution5x5.clembed"
728 },
729 {
Sang-Hoon Parkab5b1a22019-10-15 09:29:13 +0100730 "direct_convolution_quantized.cl",
731#include "./cl_kernels/direct_convolution_quantized.clembed"
Chunosovd621bca2017-11-03 17:33:15 +0700732 },
733 {
Michalis Spyrou45091732019-05-13 17:41:01 +0100734 "direct_convolution9x9.cl",
735#include "./cl_kernels/direct_convolution9x9.clembed"
736 },
737 {
giuros01164a2722018-11-20 18:34:46 +0000738 "elementwise_operation.cl",
739#include "./cl_kernels/elementwise_operation.clembed"
740 },
741 {
742 "elementwise_operation_quantized.cl",
743#include "./cl_kernels/elementwise_operation_quantized.clembed"
744 },
745 {
Michalis Spyroue9362622018-11-23 17:41:37 +0000746 "elementwise_unary.cl",
747#include "./cl_kernels/elementwise_unary.clembed"
748 },
749 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100750 "erode.cl",
751#include "./cl_kernels/erode.clembed"
752 },
753 {
754 "fast_corners.cl",
755#include "./cl_kernels/fast_corners.clembed"
756 },
757 {
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000758 "fft.cl",
759#include "./cl_kernels/fft.clembed"
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +0100760 },
761 {
Georgios Pinitas8be91482019-03-26 17:23:28 +0000762 "fft_digit_reverse.cl",
763#include "./cl_kernels/fft_digit_reverse.clembed"
764 },
765 {
766 "fft_scale.cl",
767#include "./cl_kernels/fft_scale.clembed"
768 },
769 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100770 "fill_border.cl",
771#include "./cl_kernels/fill_border.clembed"
772 },
773 {
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000774 "flatten.cl",
775#include "./cl_kernels/flatten.clembed"
776 },
777 {
Georgios Pinitasd8e765b2017-08-02 13:44:33 +0100778 "floor.cl",
779#include "./cl_kernels/floor.clembed"
780 },
781 {
Manuel Bottini8529bd62018-11-21 11:53:04 +0000782 "gather.cl",
783#include "./cl_kernels/gather.clembed"
784 },
785 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100786 "gaussian_pyramid.cl",
787#include "./cl_kernels/gaussian_pyramid.clembed"
788 },
789 {
790 "gemm.cl",
791#include "./cl_kernels/gemm.clembed"
792 },
793 {
Gian Marco05288a22017-11-21 10:57:50 +0000794 "gemmlowp.cl",
795#include "./cl_kernels/gemmlowp.clembed"
796 },
797 {
Giorgio Arena9fe41442017-08-23 16:36:24 +0100798 "gemv.cl",
799#include "./cl_kernels/gemv.clembed"
800 },
801 {
Manuel Bottini5209be52019-02-13 16:34:56 +0000802 "generate_proposals.cl",
803#include "./cl_kernels/generate_proposals.clembed"
804 },
805 {
Michele Di Giorgio6b612f52019-09-05 12:30:22 +0100806 "generate_proposals_quantized.cl",
807#include "./cl_kernels/generate_proposals_quantized.clembed"
808 },
809 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100810 "harris_corners.cl",
811#include "./cl_kernels/harris_corners.clembed"
812 },
813 {
814 "helpers.h",
815#include "./cl_kernels/helpers.hembed"
816 },
817 {
Chunosovd621bca2017-11-03 17:33:15 +0700818 "helpers_asymm.h",
819#include "./cl_kernels/helpers_asymm.hembed"
820 },
821 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100822 "histogram.cl",
823#include "./cl_kernels/histogram.clembed"
824 },
825 {
826 "hog.cl",
827#include "./cl_kernels/hog.clembed"
828 },
829 {
Gian Marco76faef82018-01-29 12:15:32 +0000830 "im2col.cl",
831#include "./cl_kernels/im2col.clembed"
832 },
833 {
Manuel Bottini79f88e62019-09-18 15:02:53 +0100834 "instance_normalization.cl",
835#include "./cl_kernels/instance_normalization.clembed"
836 },
837 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100838 "integral_image.cl",
839#include "./cl_kernels/integral_image.clembed"
840 },
841 {
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100842 "l2_normalize.cl",
843#include "./cl_kernels/l2_normalize.clembed"
844 },
845 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100846 "magnitude_phase.cl",
847#include "./cl_kernels/magnitude_phase.clembed"
848 },
849 {
850 "mean_stddev.cl",
851#include "./cl_kernels/mean_stddev.clembed"
852 },
853 {
Michele Di Giorgio5b48ad72019-06-04 18:43:35 +0100854 "mean_stddev_normalization.cl",
855#include "./cl_kernels/mean_stddev_normalization.clembed"
856 },
857 {
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100858 "memset.cl",
859#include "./cl_kernels/memset.clembed"
860 },
861 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100862 "minmaxloc.cl",
863#include "./cl_kernels/minmaxloc.clembed"
864 },
865 {
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100866 "minmax_layer.cl",
867#include "./cl_kernels/minmax_layer.clembed"
868 },
869 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100870 "non_linear_filter3x3.cl",
871#include "./cl_kernels/non_linear_filter3x3.clembed"
872 },
873 {
874 "non_linear_filter5x5.cl",
875#include "./cl_kernels/non_linear_filter5x5.clembed"
876 },
877 {
878 "non_linear_filter_helpers.h",
879#include "./cl_kernels/non_linear_filter_helpers.hembed"
880 },
881 {
882 "nonmax.cl",
883#include "./cl_kernels/nonmax.clembed"
884 },
885 {
886 "normalization_layer.cl",
887#include "./cl_kernels/normalization_layer.clembed"
888 },
889 {
Michele Di Giorgiob57be0d2018-08-31 16:26:25 +0100890 "normalize_planar_yuv_layer.cl",
891#include "./cl_kernels/normalize_planar_yuv_layer.clembed"
892 },
893 {
Michele Di Giorgiod63dfa22018-09-12 10:18:54 +0100894 "normalize_planar_yuv_layer_quantized.cl",
895#include "./cl_kernels/normalize_planar_yuv_layer_quantized.clembed"
896 },
897 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100898 "batchnormalization_layer.cl",
899#include "./cl_kernels/batchnormalization_layer.clembed"
900 },
901 {
902 "optical_flow_pyramid_lk.cl",
903#include "./cl_kernels/optical_flow_pyramid_lk.clembed"
904 },
905 {
Giorgio Arena205eed82019-08-14 10:13:50 +0100906 "pad_layer.cl",
907#include "./cl_kernels/pad_layer.clembed"
908 },
909 {
Michalis Spyrou5237e012018-01-17 09:40:27 +0000910 "permute.cl",
911#include "./cl_kernels/permute.clembed"
912 },
913 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100914 "pixelwise_mul_float.cl",
915#include "./cl_kernels/pixelwise_mul_float.clembed"
916 },
917 {
918 "pixelwise_mul_int.cl",
919#include "./cl_kernels/pixelwise_mul_int.clembed"
920 },
921 {
922 "pooling_layer.cl",
923#include "./cl_kernels/pooling_layer.clembed"
924 },
925 {
Anton Lokhmotovaf6204c2017-11-08 09:34:19 +0000926 "pooling_layer_quantized.cl",
927#include "./cl_kernels/pooling_layer_quantized.clembed"
928 },
929 {
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +0100930 "prior_box_layer.cl",
931#include "./cl_kernels/prior_box_layer.clembed"
932 },
933 {
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100934 "quantization_layer.cl",
935#include "./cl_kernels/quantization_layer.clembed"
936 },
937 {
Vidhya Sudhan Loganathan5e96be72018-12-18 14:17:00 +0000938 "range.cl",
939#include "./cl_kernels/range.clembed"
940 },
941 {
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100942 "reduction_operation.cl",
943#include "./cl_kernels/reduction_operation.clembed"
944 },
945 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100946 "remap.cl",
947#include "./cl_kernels/remap.clembed"
948 },
949 {
Gian Marco Iodice477531c2018-08-21 17:53:38 +0100950 "reorg_layer.cl",
951#include "./cl_kernels/reorg_layer.clembed"
952 },
953 {
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +0100954 "reshape_layer.cl",
955#include "./cl_kernels/reshape_layer.clembed"
956 },
957 {
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000958 "reverse.cl",
959#include "./cl_kernels/reverse.clembed"
960 },
961 {
giuros0118870812018-09-13 09:31:40 +0100962 "roi_align_layer.cl",
963#include "./cl_kernels/roi_align_layer.clembed"
964 },
965 {
Michele Di Giorgio578a9fc2019-08-23 11:49:04 +0100966 "roi_align_layer_quantized.cl",
967#include "./cl_kernels/roi_align_layer_quantized.clembed"
968 },
969 {
SiCong Li3e363692017-07-04 15:02:10 +0100970 "roi_pooling_layer.cl",
971#include "./cl_kernels/roi_pooling_layer.clembed"
972 },
973 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100974 "scale.cl",
975#include "./cl_kernels/scale.clembed"
976 },
977 {
Michalis Spyrou17220e22018-09-12 13:35:38 +0100978 "scale_quantized.cl",
979#include "./cl_kernels/scale_quantized.clembed"
980 },
981 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100982 "scharr_filter.cl",
983#include "./cl_kernels/scharr_filter.clembed"
984 },
985 {
Georgios Pinitasaaa27182018-11-21 16:32:15 +0000986 "select.cl",
987#include "./cl_kernels/select.clembed"
988 },
989 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100990 "sobel_filter.cl",
991#include "./cl_kernels/sobel_filter.clembed"
992 },
993 {
994 "softmax_layer.cl",
995#include "./cl_kernels/softmax_layer.clembed"
996 },
997 {
Chunosovf450caa2017-11-08 16:09:35 +0700998 "softmax_layer_quantized.cl",
999#include "./cl_kernels/softmax_layer_quantized.clembed"
1000 },
1001 {
Georgios Pinitasc1a72452018-08-24 11:25:32 +01001002 "slice_ops.cl",
1003#include "./cl_kernels/slice_ops.clembed"
Georgios Pinitas77589b52018-08-21 14:41:35 +01001004 },
1005 {
Michalis Spyrou16934a52018-08-21 18:03:58 +01001006 "space_to_batch.cl",
1007#include "./cl_kernels/space_to_batch.clembed"
1008 },
1009 {
Michalis Spyroud69b3b22019-05-29 17:03:38 +01001010 "space_to_depth.cl",
1011#include "./cl_kernels/space_to_depth.clembed"
1012 },
1013 {
Gian Marco Iodice8aa985e2018-11-27 15:58:08 +00001014 "stack_layer.cl",
1015#include "./cl_kernels/stack_layer.clembed"
1016 },
1017 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001018 "tablelookup.cl",
1019#include "./cl_kernels/tablelookup.clembed"
1020 },
1021 {
1022 "threshold.cl",
1023#include "./cl_kernels/threshold.clembed"
1024 },
1025 {
giuros013175fcf2018-11-21 09:59:17 +00001026 "tile.cl",
1027#include "./cl_kernels/tile.clembed"
1028 },
1029 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001030 "transpose.cl",
1031#include "./cl_kernels/transpose.clembed"
1032 },
1033 {
1034 "types.h",
1035#include "./cl_kernels/types.hembed"
1036 },
1037 {
1038 "warp_affine.cl",
1039#include "./cl_kernels/warp_affine.clembed"
1040 },
1041 {
1042 "warp_helpers.h",
1043#include "./cl_kernels/warp_helpers.hembed"
1044 },
1045 {
1046 "warp_perspective.cl",
1047#include "./cl_kernels/warp_perspective.clembed"
Michalis Spyroud7e82812017-06-20 15:00:14 +01001048 },
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +00001049 {
Giorgio Arenaa50e5e02018-07-02 13:42:23 +01001050 "winograd_filter_transform.cl",
1051#include "./cl_kernels/winograd_filter_transform.clembed"
1052 },
1053 {
1054 "winograd_input_transform.cl",
1055#include "./cl_kernels/winograd_input_transform.clembed"
1056 },
1057 {
1058 "winograd_output_transform.cl",
1059#include "./cl_kernels/winograd_output_transform.clembed"
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +00001060 },
Giorgio Arena73023022018-09-04 14:55:55 +01001061 {
1062 "yolo_layer.cl",
1063#include "./cl_kernels/yolo_layer.clembed"
1064 },
Anthony Barbierac69aa12017-07-03 17:39:37 +01001065#endif /* EMBEDDED_KERNELS */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001066};
1067
1068CLKernelLibrary::CLKernelLibrary()
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001069 : _context(), _device(), _kernel_path("."), _programs_map(), _built_programs_map()
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001070{
Anthony Barbierecb1c622018-04-17 11:45:10 +01001071 opencl_is_available(); // Make sure the OpenCL symbols are initialised *before* the CLKernelLibrary is built
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001072}
1073
1074CLKernelLibrary &CLKernelLibrary::get()
1075{
1076 static CLKernelLibrary _kernel_library;
1077 return _kernel_library;
1078}
1079
1080Kernel CLKernelLibrary::create_kernel(const std::string &kernel_name, const StringSet &build_options_set) const
1081{
1082 // Find which program contains the kernel
1083 auto kernel_program_it = _kernel_program_map.find(kernel_name);
1084
1085 if(_kernel_program_map.end() == kernel_program_it)
1086 {
Michalis Spyrou7c60c992019-10-10 14:33:47 +01001087 ARM_COMPUTE_ERROR_VAR("Kernel %s not found in the CLKernelLibrary", kernel_name.c_str());
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001088 }
steniu0134702472017-07-11 09:22:58 +01001089 std::string concat_str;
1090
Georgios Pinitasdf473ea2018-05-31 18:53:52 +01001091#if defined(ARM_COMPUTE_DEBUG_ENABLED)
1092 // Enable debug properties in CL kernels
1093 concat_str += " -DARM_COMPUTE_DEBUG_ENABLED";
1094#endif // defined(ARM_COMPUTE_DEBUG_ENABLED)
1095
Usama Arife2428a02019-05-09 11:03:17 +01001096 GPUTarget gpu_arch = get_arch_from_target(get_target_from_device(_device));
1097 concat_str += " -DGPU_ARCH=" + support::cpp11::to_string(
1098 static_cast<std::underlying_type<GPUTarget>::type>(gpu_arch));
Vidhya Sudhan Loganathanf1f49062018-05-25 13:21:26 +01001099 if(fp16_supported())
Matthew Bentham6f31f8c2017-10-27 11:50:06 +01001100 {
1101 concat_str += " -DARM_COMPUTE_OPENCL_FP16_ENABLED=1 ";
1102 }
1103
Michalis Spyroue03342e2018-01-15 14:39:13 +00001104 if(dot8_supported(_device))
1105 {
1106 concat_str += " -DARM_COMPUTE_OPENCL_DOT8_ENABLED=1 ";
1107 }
1108
Giorgio Arenaeff8d952018-07-02 15:29:57 +01001109 if(dot8_acc_supported(_device))
1110 {
1111 concat_str += " -DARM_COMPUTE_OPENCL_DOT8_ACC_ENABLED=1 ";
1112 }
1113
Pablo Telloe86a09f2018-01-11 15:44:48 +00001114 if(get_cl_version(_device) == CLVersion::CL20)
steniu0134702472017-07-11 09:22:58 +01001115 {
1116 concat_str += " -cl-std=CL2.0 ";
1117 }
Anthony Barbierd727e852018-04-20 11:05:29 +01001118 else if(arm_non_uniform_workgroup_supported(_device))
Pablo Telloe86a09f2018-01-11 15:44:48 +00001119 {
1120 concat_str += " -cl-arm-non-uniform-work-group-size ";
1121 }
steniu0134702472017-07-11 09:22:58 +01001122 else
1123 {
1124 ARM_COMPUTE_ERROR("Non uniform workgroup size is not supported!!");
1125 }
1126
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001127 // Check if the program has been built before with same build options.
steniu0134702472017-07-11 09:22:58 +01001128 const std::string program_name = kernel_program_it->second;
1129 const std::string build_options = stringify_set(build_options_set) + concat_str;
1130
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001131 const std::string built_program_name = program_name + "_" + build_options;
1132 auto built_program_it = _built_programs_map.find(built_program_name);
1133
1134 cl::Program cl_program;
1135
1136 if(_built_programs_map.end() != built_program_it)
1137 {
1138 // If program has been built, retrieve to create kernel from it
1139 cl_program = built_program_it->second;
1140 }
1141 else
1142 {
1143 // Get program
1144 Program program = load_program(program_name);
1145
1146 // Build program
1147 cl_program = program.build(build_options);
1148
1149 // Add built program to internal map
1150 _built_programs_map.emplace(built_program_name, cl_program);
1151 }
1152
1153 // Create and return kernel
1154 return Kernel(kernel_name, cl_program);
1155}
1156
Pablo Tellodb8485a2019-09-24 11:03:47 +01001157void CLKernelLibrary::init(std::string kernel_path, cl::Context context, cl::Device device)
1158{
1159 _kernel_path = std::move(kernel_path);
1160 _context = std::move(context);
1161 _device = std::move(device);
1162}
1163
1164void CLKernelLibrary::set_kernel_path(const std::string &kernel_path)
1165{
1166 _kernel_path = kernel_path;
1167}
1168
1169cl::Context &CLKernelLibrary::context()
1170{
1171 return _context;
1172}
1173
1174cl::Device &CLKernelLibrary::get_device()
1175{
1176 return _device;
1177}
1178
1179void CLKernelLibrary::set_device(cl::Device device)
1180{
1181 _device = std::move(device);
1182}
1183
1184std::string CLKernelLibrary::get_kernel_path()
1185{
1186 return _kernel_path;
1187}
1188
1189void CLKernelLibrary::clear_programs_cache()
1190{
1191 _programs_map.clear();
1192 _built_programs_map.clear();
1193}
1194
1195const std::map<std::string, cl::Program> &CLKernelLibrary::get_built_programs() const
1196{
1197 return _built_programs_map;
1198}
1199
giuros0146a49a02019-04-01 13:50:22 +01001200void CLKernelLibrary::add_built_program(const std::string &built_program_name, const cl::Program &program)
Anthony Barbier7da55aa2018-04-13 16:58:43 +01001201{
1202 _built_programs_map.emplace(built_program_name, program);
1203}
1204
Vidhya Sudhan Loganathanf1f49062018-05-25 13:21:26 +01001205bool CLKernelLibrary::fp16_supported() const
1206{
1207 return ::fp16_supported(_device);
1208}
1209
Vidhya Sudhan Loganathan76c85642018-05-25 13:53:02 +01001210bool CLKernelLibrary::int64_base_atomics_supported() const
1211{
1212 return device_supports_extension(_device, "cl_khr_int64_base_atomics");
1213}
1214
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001215const Program &CLKernelLibrary::load_program(const std::string &program_name) const
1216{
1217 const auto program_it = _programs_map.find(program_name);
1218
1219 if(program_it != _programs_map.end())
1220 {
1221 return program_it->second;
1222 }
1223
1224 Program program;
1225
1226#ifdef EMBEDDED_KERNELS
1227 const auto program_source_it = _program_source_map.find(program_name);
1228
1229 if(_program_source_map.end() == program_source_it)
1230 {
Michalis Spyrou7c60c992019-10-10 14:33:47 +01001231 ARM_COMPUTE_ERROR_VAR("Embedded program for %s does not exist.", program_name.c_str());
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001232 }
1233
1234 program = Program(_context, program_name, program_source_it->second);
Anthony Barbierac69aa12017-07-03 17:39:37 +01001235#else /* EMBEDDED_KERNELS */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001236 // Check for binary
1237 std::string source_name = _kernel_path + program_name;
1238 std::string binary_name = source_name + "bin";
1239
1240 if(std::ifstream(binary_name).is_open())
1241 {
1242 const std::string program_binary = read_file(binary_name, true);
1243 program = Program(_context, _device, program_name, std::vector<unsigned char>(program_binary.begin(), program_binary.end()));
1244 }
1245 else if(std::ifstream(source_name).is_open())
1246 {
1247 program = Program(_context, program_name, read_file(source_name, false));
1248 }
1249 else
1250 {
Michalis Spyrou7c60c992019-10-10 14:33:47 +01001251 ARM_COMPUTE_ERROR_VAR("Kernel file %s does not exist.", source_name.c_str());
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001252 }
Anthony Barbierac69aa12017-07-03 17:39:37 +01001253#endif /* EMBEDDED_KERNELS */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001254
1255 // Insert program to program map
1256 const auto new_program = _programs_map.emplace(program_name, std::move(program));
1257
1258 return new_program.first->second;
1259}
1260
Pablo Tellodb8485a2019-09-24 11:03:47 +01001261void CLKernelLibrary::set_context(cl::Context context)
1262{
1263 _context = std::move(context);
1264 if(_context.get() == nullptr)
1265 {
1266 _device = cl::Device();
1267 }
1268 else
1269 {
1270 const auto cl_devices = _context.getInfo<CL_CONTEXT_DEVICES>();
1271
1272 if(cl_devices.empty())
1273 {
1274 _device = cl::Device();
1275 }
1276 else
1277 {
1278 _device = cl_devices[0];
1279 }
1280 }
1281}
1282
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001283std::string CLKernelLibrary::stringify_set(const StringSet &s) const
1284{
steniu0134702472017-07-11 09:22:58 +01001285 std::string concat_set;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001286
1287#ifndef EMBEDDED_KERNELS
1288 concat_set += "-I" + _kernel_path + " ";
1289#endif /* EMBEDDED_KERNELS */
1290
1291 // Concatenate set
1292 for(const auto &el : s)
1293 {
1294 concat_set += " " + el;
1295 }
1296
1297 return concat_set;
1298}
Michalis Spyroud7e82812017-06-20 15:00:14 +01001299
1300std::string CLKernelLibrary::get_program_source(const std::string &program_name)
1301{
1302 const auto program_source_it = _program_source_map.find(program_name);
1303
1304 if(program_source_it == _program_source_map.end())
1305 {
Michalis Spyrou7c60c992019-10-10 14:33:47 +01001306 ARM_COMPUTE_ERROR_VAR("Embedded program for %s does not exist.", program_name.c_str());
Michalis Spyroud7e82812017-06-20 15:00:14 +01001307 }
1308
1309 return program_source_it->second;
1310}
steniu015f910722017-08-23 10:15:22 +01001311
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001312size_t CLKernelLibrary::max_local_workgroup_size(const cl::Kernel &kernel) const
steniu015f910722017-08-23 10:15:22 +01001313{
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001314 size_t result;
steniu015f910722017-08-23 10:15:22 +01001315
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001316 size_t err = kernel.getWorkGroupInfo(_device, CL_KERNEL_WORK_GROUP_SIZE, &result);
1317 ARM_COMPUTE_ERROR_ON_MSG(err != 0, "clGetKernelWorkGroupInfo failed to return the maximum workgroup size for the kernel");
1318 ARM_COMPUTE_UNUSED(err);
1319
1320 return result;
steniu015f910722017-08-23 10:15:22 +01001321}
1322
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001323cl::NDRange CLKernelLibrary::default_ndrange() const
steniu015f910722017-08-23 10:15:22 +01001324{
Anthony Barbierb6eb3532018-08-08 13:20:04 +01001325 GPUTarget _target = get_target_from_device(_device);
Michalis Spyroua9676112018-02-22 18:07:43 +00001326 cl::NDRange default_range;
1327
1328 switch(_target)
1329 {
1330 case GPUTarget::MIDGARD:
1331 case GPUTarget::T600:
1332 case GPUTarget::T700:
1333 case GPUTarget::T800:
1334 default_range = cl::NDRange(128u, 1);
1335 break;
1336 default:
1337 default_range = cl::NullRange;
1338 }
1339
1340 return default_range;
steniu015f910722017-08-23 10:15:22 +01001341}
Anthony Barbier847864d2018-03-07 11:35:53 +00001342
1343std::string CLKernelLibrary::get_device_version()
1344{
1345 return _device.getInfo<CL_DEVICE_VERSION>();
1346}
Giorgio Arena5d42b462019-07-26 15:54:20 +01001347
1348cl_uint CLKernelLibrary::get_num_compute_units()
1349{
1350 return _device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>();
Michele Di Giorgio578a9fc2019-08-23 11:49:04 +01001351}