blob: 5d672402992c85a4c8ac9d99638f5e7df458769e [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"
29
steniu015f910722017-08-23 10:15:22 +010030#include <algorithm>
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031#include <fstream>
32#include <iostream>
33#include <utility>
34#include <vector>
35
36using namespace arm_compute;
37
Georgios Pinitas388d3ec2017-11-02 12:17:56 +000038CLBuildOptions::CLBuildOptions()
39 : _build_opts()
40{
41}
42
43void CLBuildOptions::add_option(std::string option)
44{
45 _build_opts.emplace(std::move(option));
46}
47
48void CLBuildOptions::add_option_if(bool cond, std::string option)
49{
50 if(cond)
51 {
52 add_option(std::move(option));
53 }
54}
55
56void CLBuildOptions::add_option_if_else(bool cond, std::string option_true, std::string option_false)
57{
58 (cond) ? add_option(std::move(option_true)) : add_option(std::move(option_false));
59}
60
Chunosovf450caa2017-11-08 16:09:35 +070061void CLBuildOptions::add_options(const StringSet &options)
62{
63 _build_opts.insert(options.begin(), options.end());
64}
65
66void CLBuildOptions::add_options_if(bool cond, const StringSet &options)
67{
68 if(cond)
69 {
70 add_options(options);
71 }
72}
73
Chunosovd621bca2017-11-03 17:33:15 +070074const CLBuildOptions::StringSet &CLBuildOptions::options() const
Georgios Pinitas388d3ec2017-11-02 12:17:56 +000075{
76 return _build_opts;
77}
78
Anthony Barbier6ff3b192017-09-04 18:44:23 +010079Program::Program()
80 : _context(), _device(), _is_binary(false), _name(), _source(), _binary()
81{
82}
83
84Program::Program(cl::Context context, std::string name, std::string source)
85 : _context(std::move(context)), _device(), _is_binary(false), _name(std::move(name)), _source(std::move(source)), _binary()
86{
87}
88
89Program::Program(cl::Context context, cl::Device device, std::string name, std::vector<unsigned char> binary)
90 : _context(std::move(context)), _device(std::move(device)), _is_binary(true), _name(std::move(name)), _source(), _binary(std::move(binary))
91{
92}
93
94Program::operator cl::Program() const
95{
96 if(_is_binary)
97 {
98 return cl::Program(_context, { _device }, { _binary });
99 }
100 else
101 {
102 return cl::Program(_context, _source, false);
103 }
104}
105
106bool Program::build(const cl::Program &program, const std::string &build_options)
107{
108 try
109 {
110 return program.build(build_options.c_str()) == CL_SUCCESS;
111 }
112 catch(const cl::Error &e)
113 {
114 cl_int err = CL_SUCCESS;
115 const auto build_info = program.getBuildInfo<CL_PROGRAM_BUILD_LOG>(&err);
116
117 for(auto &pair : build_info)
118 {
119 std::cerr << pair.second << std::endl;
120 }
121
122 return false;
123 }
124}
125
126cl::Program Program::build(const std::string &build_options) const
127{
128 cl::Program cl_program = static_cast<cl::Program>(*this);
129 build(cl_program, build_options);
130 return cl_program;
131}
132
133Kernel::Kernel()
134 : _name(), _kernel()
135{
136}
137
138Kernel::Kernel(std::string name, const cl::Program &program)
139 : _name(std::move(name)),
140 _kernel(cl::Kernel(program, _name.c_str()))
141{
142}
143
144const std::map<std::string, std::string> CLKernelLibrary::_kernel_program_map =
145{
146 { "absdiff", "absdiff.cl" },
147 { "accumulate", "accumulate.cl" },
148 { "accumulate_squared", "accumulate.cl" },
149 { "accumulate_weighted", "accumulate.cl" },
150 { "activation_layer", "activation_layer.cl" },
Manuel Bottini30dbeef2019-06-26 16:23:03 +0100151 { "activation_layer_quant", "activation_layer_quant.cl" },
152 { "activation_layer_quant_f32", "activation_layer_quant.cl" },
Manuel Bottini7b9998d2019-10-21 17:59:07 +0100153 { "arg_min_max_x", "arg_min_max.cl" },
154 { "arg_min_max_y", "arg_min_max.cl" },
155 { "arg_min_max_z", "arg_min_max.cl" },
156 { "arg_min_max_w", "arg_min_max.cl" },
Michalis Spyrouf1addb62018-09-11 11:16:47 +0100157 { "batch_to_space_nchw", "batch_to_space.cl" },
158 { "batch_to_space_static_nchw", "batch_to_space.cl" },
159 { "batch_to_space_nhwc", "batch_to_space.cl" },
160 { "batch_to_space_static_nhwc", "batch_to_space.cl" },
Michele Di Giorgiobf3c6622018-03-08 11:52:27 +0000161 { "batchnormalization_layer_nchw", "batchnormalization_layer.cl" },
162 { "batchnormalization_layer_nhwc", "batchnormalization_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100163 { "bitwise_or", "bitwise_op.cl" },
164 { "bitwise_and", "bitwise_op.cl" },
165 { "bitwise_xor", "bitwise_op.cl" },
166 { "bitwise_not", "bitwise_op.cl" },
giuros01c04a0e82018-10-03 12:44:35 +0100167 { "bounding_box_transform", "bounding_box_transform.cl" },
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100168 { "bounding_box_transform_quantized", "bounding_box_transform_quantized.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100169 { "channel_combine_NV", "channel_combine.cl" },
170 { "channel_combine_RGB888", "channel_combine.cl" },
171 { "channel_combine_RGBA8888", "channel_combine.cl" },
172 { "channel_combine_UYVY422", "channel_combine.cl" },
173 { "channel_combine_YUYV422", "channel_combine.cl" },
Michele Di Giorgio72175632018-05-01 16:52:00 +0100174 { "channel_shuffle_nchw", "channel_shuffle.cl" },
Gian Marco Iodice8bab0ee2018-09-13 11:51:56 +0100175 { "channel_shuffle_nhwc", "channel_shuffle.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100176 { "channel_extract_NV12", "channel_extract.cl" },
177 { "channel_extract_NV21", "channel_extract.cl" },
178 { "channel_extract_RGB888", "channel_extract.cl" },
179 { "channel_extract_RGBA8888", "channel_extract.cl" },
180 { "channel_extract_UYVY422", "channel_extract.cl" },
181 { "channel_extract_YUYV422", "channel_extract.cl" },
182 { "combine_gradients_L1", "canny.cl" },
183 { "combine_gradients_L2", "canny.cl" },
Georgios Pinitas7900a9e2018-11-23 11:44:58 +0000184 { "compare_equal", "comparisons.cl" },
185 { "compare_equal_quantized", "comparisons.cl" },
186 { "compare_notequal", "comparisons.cl" },
187 { "compare_notequal_quantized", "comparisons.cl" },
188 { "compare_greater", "comparisons.cl" },
189 { "compare_greater_quantized", "comparisons.cl" },
190 { "compare_greaterequal", "comparisons.cl" },
191 { "compare_greaterequal_quantized", "comparisons.cl" },
192 { "compare_less", "comparisons.cl" },
193 { "compare_less_quantized", "comparisons.cl" },
194 { "compare_lessequal", "comparisons.cl" },
195 { "compare_lessequal_quantized", "comparisons.cl" },
Vidhya Sudhan Loganathan338595b2019-06-28 14:09:53 +0100196 { "concatenate", "concatenate.cl" },
Michalis Spyrou55b3d122018-05-09 09:59:23 +0100197 { "concatenate_width", "concatenate.cl" },
Pablo Tello6a14adb2019-03-05 17:33:08 +0000198 { "concatenate_height", "concatenate.cl" },
Michele Di Giorgio27400b92018-11-01 13:44:05 +0000199 { "concatenate_width_x2", "concatenate.cl" },
200 { "concatenate_width_x4", "concatenate.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100201 { "convolution_rectangle", "convolution_rectangle.cl" },
Gian Marco76faef82018-01-29 12:15:32 +0000202 { "col2im", "col2im.cl" },
Giorgio Arena657bdb32018-04-26 18:52:01 +0100203 { "convert_depth_down", "depth_convert.cl" },
204 { "convert_depth_up", "depth_convert.cl" },
205 { "convert_fc_weights", "convert_fc_weights.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100206 { "convolution3x3_static", "convolution3x3.cl" },
207 { "convolution5x5_static", "convolution5x5.cl" },
208 { "convolution7x7_static", "convolution7x7.cl" },
209 { "convolution9x9_static", "convolution9x9.cl" },
210 { "convolution_separable1x5_static", "convolution5x5.cl" },
211 { "convolution_separable5x1_static", "convolution5x5.cl" },
212 { "convolution_separable1x7_static", "convolution7x7.cl" },
213 { "convolution_separable7x1_static", "convolution7x7.cl" },
214 { "convolution_separable1x9_static", "convolution9x9.cl" },
215 { "convolution_separable9x1_static", "convolution9x9.cl" },
Michalis Spyrou5c8e05c2018-03-22 11:56:01 +0000216 { "copy_tensor", "copy_tensor.cl" },
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100217 { "copy_pad_tensor", "copy_tensor.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100218 { "copy_plane", "channel_extract.cl" },
219 { "copy_planes_3p", "channel_combine.cl" },
220 { "copy_to_keypoint", "fast_corners.cl" },
George Wort894066d2019-02-15 15:12:52 +0000221 { "crop_tensor", "crop_tensor.cl" },
giuros0146a49a02019-04-01 13:50:22 +0100222 { "deconvolution_reshape", "deconvolution_layer.cl" },
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000223 { "deconvolution_upsample", "deconvolution_layer.cl" },
Giorgio Arena93a690e2017-08-01 16:09:33 +0100224 { "depthwise_convolution_3x3", "depthwise_convolution.cl" },
Michele Di Giorgio933fe862018-02-19 15:42:12 +0000225 { "depthwise_convolution_3x3_f16", "depthwise_convolution.cl" },
Giorgio Arenad051e972018-06-20 11:46:42 +0100226 { "depthwise_convolution_3x3_nhwc", "depthwise_convolution.cl" },
227 { "depthwise_convolution_3x3_nhwc_stride1", "depthwise_convolution.cl" },
Gian Marco Iodice9285adb2019-09-05 16:10:27 +0100228 { "dwc_MxN_native_fp_nhwc", "depthwise_convolution.cl" },
Michele Di Giorgioa046e162019-10-08 09:36:26 +0100229 { "dwc_MxN_native_quantized8_nhwc", "depthwise_convolution_quantized.cl" },
Michele Di Giorgiodf4cf572019-10-09 15:32:39 +0100230 { "dwc_3x3_native_quantized8_nchw", "depthwise_convolution_quantized.cl" },
231 { "dwc_3x3_native_quantized8_dot8_nchw", "depthwise_convolution_quantized.cl" },
232 { "dwc_3x3_reshaped_quantized8_nhwc", "depthwise_convolution_quantized.cl" },
233 { "dwc_3x3_reshaped_quantized8_stride1_nhwc", "depthwise_convolution_quantized.cl" },
234 { "dwc_3x3_reshaped_quantized8_dot8_stride1_nhwc", "depthwise_convolution_quantized.cl" },
Michalis Spyrou649962c2019-05-22 11:11:55 +0100235 { "depth_to_space_nchw", "depth_to_space.cl" },
236 { "depth_to_space_nhwc", "depth_to_space.cl" },
Michele Di Giorgio3ebef322018-02-21 10:02:58 +0000237 { "depthwise_convolution_3x3_stridex1_stridey1_bifrost_f16", "depthwise_convolution.cl" },
238 { "depthwise_convolution_3x3_stridex2_stridey2_bifrost_f16", "depthwise_convolution.cl" },
239 { "depthwise_convolution_3x3_stridex1_stridey1_bifrost_f32", "depthwise_convolution.cl" },
240 { "depthwise_convolution_3x3_stridex2_stridey2_bifrost_f32", "depthwise_convolution.cl" },
giuros016d109962019-01-07 17:47:19 +0000241 { "depthwise_convolution_reshape_weights", "depthwise_convolution.cl" },
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100242 { "dequantization_layer", "dequantization_layer.cl" },
Michalis Spyrou3f632f32019-08-22 16:52:00 +0100243 { "dequantization_layer_per_channel_nhwc", "dequantization_layer.cl" },
244 { "dequantization_layer_per_channel_nchw", "dequantization_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100245 { "derivative", "derivative.cl" },
246 { "dilate", "dilate.cl" },
SiCong Lic51b72f2017-07-28 14:46:20 +0100247 { "direct_convolution1x1", "direct_convolution1x1.cl" },
Pablo Tello3d319462018-06-21 15:13:17 +0100248 { "direct_convolution1x1_nhwc", "direct_convolution1x1.cl" },
Gian Marco Iodice1c8409d2017-09-06 17:24:25 +0100249 { "direct_convolution1x1_f32_bifrost", "direct_convolution1x1.cl" },
SiCong Lic51b72f2017-07-28 14:46:20 +0100250 { "direct_convolution3x3", "direct_convolution3x3.cl" },
Pablo Tello3d319462018-06-21 15:13:17 +0100251 { "direct_convolution3x3_nhwc", "direct_convolution3x3.cl" },
Gian Marco Iodice1246b632017-08-16 18:38:32 +0100252 { "direct_convolution3x3_f32_bifrost", "direct_convolution3x3.cl" },
steniu01db006682017-08-09 16:26:22 +0100253 { "direct_convolution5x5", "direct_convolution5x5.cl" },
Pablo Tello3d319462018-06-21 15:13:17 +0100254 { "direct_convolution5x5_nhwc", "direct_convolution5x5.cl" },
Gian Marco Iodice1246b632017-08-16 18:38:32 +0100255 { "direct_convolution5x5_f32_bifrost", "direct_convolution5x5.cl" },
Sang-Hoon Parkab5b1a22019-10-15 09:29:13 +0100256 { "direct_convolution_quantized", "direct_convolution_quantized.cl" },
Michalis Spyrou45091732019-05-13 17:41:01 +0100257 { "direct_convolution9x9_nhwc", "direct_convolution9x9.cl" },
giuros01164a2722018-11-20 18:34:46 +0000258 { "elementwise_operation_ADD", "elementwise_operation.cl" },
259 { "elementwise_operation_SUB", "elementwise_operation.cl" },
260 { "elementwise_operation_MAX", "elementwise_operation.cl" },
261 { "elementwise_operation_MIN", "elementwise_operation.cl" },
262 { "elementwise_operation_DIV", "elementwise_operation.cl" },
263 { "elementwise_operation_SQUARED_DIFF", "elementwise_operation.cl" },
Usama Arif52c54f62019-05-14 10:22:36 +0100264 { "elementwise_operation_POWER", "elementwise_operation.cl" },
giuros011e6e1b82019-05-14 16:12:53 +0100265 { "elementwise_operation_PRELU", "elementwise_operation.cl" },
giuros01164a2722018-11-20 18:34:46 +0000266 { "elementwise_operation_ADD_quantized", "elementwise_operation_quantized.cl" },
267 { "elementwise_operation_SUB_quantized", "elementwise_operation_quantized.cl" },
268 { "elementwise_operation_MAX_quantized", "elementwise_operation_quantized.cl" },
269 { "elementwise_operation_MIN_quantized", "elementwise_operation_quantized.cl" },
270 { "elementwise_operation_DIV_quantized", "elementwise_operation_quantized.cl" },
271 { "elementwise_operation_SQUARED_DIFF_quantized", "elementwise_operation_quantized.cl" },
giuros011e6e1b82019-05-14 16:12:53 +0100272 { "elementwise_operation_PRELU_quantized", "elementwise_operation_quantized.cl" },
Michalis Spyroue9362622018-11-23 17:41:37 +0000273 { "elementwise_unary", "elementwise_unary.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100274 { "erode", "erode.cl" },
275 { "fast_corners", "fast_corners.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000276 { "fft_digit_reverse_axis_0", "fft_digit_reverse.cl" },
277 { "fft_digit_reverse_axis_1", "fft_digit_reverse.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000278 { "fft_radix_2_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000279 { "fft_radix_2_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000280 { "fft_radix_2_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000281 { "fft_radix_2_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000282 { "fft_radix_3_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000283 { "fft_radix_3_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000284 { "fft_radix_3_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000285 { "fft_radix_3_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000286 { "fft_radix_4_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000287 { "fft_radix_4_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000288 { "fft_radix_4_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000289 { "fft_radix_4_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000290 { "fft_radix_5_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000291 { "fft_radix_5_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000292 { "fft_radix_5_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000293 { "fft_radix_5_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000294 { "fft_radix_7_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000295 { "fft_radix_7_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000296 { "fft_radix_7_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000297 { "fft_radix_7_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000298 { "fft_radix_8_first_stage_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000299 { "fft_radix_8_first_stage_axis_1", "fft.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000300 { "fft_radix_8_axis_0", "fft.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000301 { "fft_radix_8_axis_1", "fft.cl" },
302 { "fft_scale_conj", "fft_scale.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100303 { "fill_image_borders_constant", "fill_border.cl" },
304 { "fill_image_borders_replicate", "fill_border.cl" },
305 { "finalize", "optical_flow_pyramid_lk.cl" },
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000306 { "flatten", "flatten.cl" },
Georgios Pinitasd8e765b2017-08-02 13:44:33 +0100307 { "floor_layer", "floor.cl" },
Manuel Bottini2732cca2019-05-28 11:44:41 +0100308 { "fuse_batchnormalization_layer", "batchnormalization_layer.cl" },
Manuel Bottini8529bd62018-11-21 11:53:04 +0000309 { "gather", "gather.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100310 { "gaussian1x5_sub_x", "gaussian_pyramid.cl" },
311 { "gaussian5x1_sub_y", "gaussian_pyramid.cl" },
Gian Marco Iodice578ab612017-06-23 09:34:33 +0100312 { "gemm_accumulate_biases", "gemm.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100313 { "gemm_ma_f16", "gemm.cl" },
314 { "gemm_ma_f32", "gemm.cl" },
Giorgio Arena9fe41442017-08-23 16:36:24 +0100315 { "gemm_mv", "gemv.cl" },
Georgios Pinitasde5a1cc2018-02-02 12:52:07 +0000316 { "gemm_mv_quantized", "gemv.cl" },
Gian Marco Iodiceedfa9f42017-08-15 11:45:22 +0100317 { "gemm_mm_interleaved_transposed_f16", "gemm.cl" },
Vidhya Sudhan Loganathan38d93bd2018-11-20 15:38:13 +0000318 { "gemm_mm_interleaved_transposed_f16_acc32", "gemm.cl" },
Gian Marco Iodicebb36a8e2018-04-19 12:05:08 +0100319 { "gemm_mm_interleaved_transposed_f16_bifrost", "gemm.cl" },
320 { "gemm_mm_interleaved_transposed_f32", "gemm.cl" },
Gian Marco Iodiceedfa9f42017-08-15 11:45:22 +0100321 { "gemm_mm_interleaved_transposed_f32_bifrost", "gemm.cl" },
Gian Marco Iodiceedfa9f42017-08-15 11:45:22 +0100322 { "gemm_mm_floating_point", "gemm.cl" },
Gian Marco Iodicefd683112018-04-17 09:52:44 +0100323 { "gemm_mm_floating_point_f16_bifrost", "gemm.cl" },
Vidhya Sudhan Loganathana25d16c2018-11-16 11:33:12 +0000324 { "gemm_mm_floating_point_f16_bifrost_acc32", "gemm.cl" },
Anton Lokhmotov3e80c7f2017-11-20 11:02:10 +0000325 { "gemm_mm_floating_point_f32_bifrost", "gemm.cl" },
326 { "gemm_mm_floating_point_f32_bifrost_1000", "gemm.cl" },
giuros01b3204e72019-04-01 13:50:22 +0100327 { "gemm_mm_native", "gemm.cl" },
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000328 { "gemm_mm_reshaped_lhs_nt_rhs_t", "gemm.cl" },
Giorgio Arenaae99b6e2019-08-01 14:22:12 +0100329 { "gemm_mm_reshaped_lhs_t_rhs_nt", "gemm.cl" },
Gian Marco Iodiceba5e0962019-03-11 12:17:44 +0000330 { "gemm_mm_reshaped_only_rhs_nt", "gemm.cl" },
Gian Marco Iodiceadc53952019-02-15 11:10:31 +0000331 { "gemm_mm_reshaped_only_rhs_t", "gemm.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100332 { "gemm_lc_vm_f32", "gemm.cl" },
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000333 { "gemm_reshape_lhs_matrix_nt", "gemm.cl" },
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +0000334 { "gemm_reshape_lhs_matrix_t", "gemm.cl" },
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000335 { "gemm_reshape_rhs_matrix_nt", "gemm.cl" },
336 { "gemm_reshape_rhs_matrix_t", "gemm.cl" },
Gian Marco05288a22017-11-21 10:57:50 +0000337 { "gemmlowp_matrix_a_reduction", "gemmlowp.cl" },
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100338 { "gemmlowp_matrix_a_reduction_dot8", "gemmlowp.cl" },
Gian Marco05288a22017-11-21 10:57:50 +0000339 { "gemmlowp_matrix_b_reduction", "gemmlowp.cl" },
Gian Marco7b4d5472018-01-10 15:56:30 +0000340 { "gemmlowp_mm_midgard", "gemmlowp.cl" },
Gian Marco Iodicee7510622019-06-03 17:28:17 +0100341 { "gemmlowp_mm_native", "gemmlowp.cl" },
Gian Marco Iodicedb63b9c2019-01-17 09:47:04 +0000342 { "gemmlowp_mm_reshaped_lhs_nt_rhs_t", "gemmlowp.cl" },
Gian Marco Iodice62251f72019-03-11 16:07:12 +0000343 { "gemmlowp_mm_reshaped_only_rhs_t", "gemmlowp.cl" },
Michele Di Giorgiob54ba282020-01-14 15:31:55 +0000344 { "gemmlowp_mm_reshaped_only_rhs_t_fused_output_stage_fixedpoint", "gemmlowp.cl" },
Gian Marco05288a22017-11-21 10:57:50 +0000345 { "gemmlowp_offset_contribution", "gemmlowp.cl" },
Gian Marco Iodice4b908652018-10-18 10:21:02 +0100346 { "gemmlowp_offset_contribution_quantize_down", "gemmlowp.cl" },
347 { "gemmlowp_offset_contribution_quantize_down_fixedpoint", "gemmlowp.cl" },
Gian Marco05288a22017-11-21 10:57:50 +0000348 { "gemmlowp_output_stage_quantize_down", "gemmlowp.cl" },
Gian Marco58c57942017-11-28 09:10:03 +0000349 { "gemmlowp_output_stage_quantize_down_fixedpoint", "gemmlowp.cl" },
Manuel Bottini9c9b70b2019-07-01 17:35:56 +0100350 { "gemmlowp_output_stage_quantize_down_fixedpoint_qsymm16", "gemmlowp.cl" },
Georgios Pinitas51e53a32018-10-22 13:49:08 +0100351 { "gemmlowp_output_stage_quantize_down_float", "gemmlowp.cl" },
Manuel Bottini5209be52019-02-13 16:34:56 +0000352 { "generate_proposals_compute_all_anchors", "generate_proposals.cl" },
Michele Di Giorgio6b612f52019-09-05 12:30:22 +0100353 { "generate_proposals_compute_all_anchors_quantized", "generate_proposals_quantized.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100354 { "harris_score_3x3", "harris_corners.cl" },
355 { "harris_score_5x5", "harris_corners.cl" },
356 { "harris_score_7x7", "harris_corners.cl" },
357 { "hist_border_kernel", "histogram.cl" },
358 { "hist_border_kernel_fixed", "histogram.cl" },
359 { "hist_local_kernel", "histogram.cl" },
360 { "hist_local_kernel_fixed", "histogram.cl" },
361 { "hog_block_normalization", "hog.cl" },
362 { "hog_detector", "hog.cl" },
363 { "hog_orientation_binning", "hog.cl" },
364 { "hysteresis", "canny.cl" },
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +0100365 { "im2col1x1_stridex1_nchw", "im2col.cl" },
366 { "im2col3x3_nchw", "im2col.cl" },
367 { "im2col5x5_nchw", "im2col.cl" },
368 { "im2col11x11_padx0_pady0_nchw", "im2col.cl" },
369 { "im2col_generic_nchw", "im2col.cl" },
370 { "im2col_generic_padx0_pady0_nchw", "im2col.cl" },
Pablo Tello4a626a72018-04-04 10:01:14 +0100371 { "im2col3x3_nhwc", "im2col.cl" },
Gian Marco Iodicebf9731e2018-12-12 10:18:04 +0000372 { "im2col9x9_nhwc", "im2col.cl" },
Pablo Tello4a626a72018-04-04 10:01:14 +0100373 { "im2col_generic_nhwc", "im2col.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100374 { "init_level", "optical_flow_pyramid_lk.cl" },
375 { "init_level_max", "optical_flow_pyramid_lk.cl" },
376 { "init_level_max_initial_estimate", "optical_flow_pyramid_lk.cl" },
Manuel Bottini79f88e62019-09-18 15:02:53 +0100377 { "instance_normalization", "instance_normalization.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100378 { "integral_horizontal", "integral_image.cl" },
379 { "integral_vertical", "integral_image.cl" },
380 { "IYUV_to_NV12_bt709", "color_convert.cl" },
381 { "IYUV_to_RGB888_bt709", "color_convert.cl" },
382 { "IYUV_to_RGBA8888_bt709", "color_convert.cl" },
383 { "IYUV_to_YUV444_bt709", "color_convert.cl" },
Michalis Spyrou5538d342018-11-14 08:10:13 +0000384 { "l2_normalize_x", "l2_normalize.cl" },
385 { "l2_normalize_y", "l2_normalize.cl" },
386 { "l2_normalize_z", "l2_normalize.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100387 { "lktracker_stage0", "optical_flow_pyramid_lk.cl" },
388 { "lktracker_stage1", "optical_flow_pyramid_lk.cl" },
389 { "magnitude_phase", "magnitude_phase.cl" },
390 { "mean_stddev_accumulate", "mean_stddev.cl" },
Michele Di Giorgio5b48ad72019-06-04 18:43:35 +0100391 { "mean_stddev_normalization", "mean_stddev_normalization.cl" },
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100392 { "memset", "memset.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100393 { "minmax", "minmaxloc.cl" },
394 { "minmax_border", "minmaxloc.cl" },
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100395 { "minmax_layer", "minmax_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100396 { "minmaxloc", "minmaxloc.cl" },
397 { "non_linear_filter_box3x3", "non_linear_filter3x3.cl" },
398 { "non_linear_filter_cross3x3", "non_linear_filter3x3.cl" },
399 { "non_linear_filter_disk3x3", "non_linear_filter3x3.cl" },
400 { "non_linear_filter_box5x5", "non_linear_filter5x5.cl" },
401 { "non_linear_filter_cross5x5", "non_linear_filter5x5.cl" },
402 { "non_linear_filter_disk5x5", "non_linear_filter5x5.cl" },
403 { "non_max_suppression", "nonmax.cl" },
404 { "normalization_layer_cross_map", "normalization_layer.cl" },
Michele Di Giorgio9d3a8312018-11-20 12:31:24 +0000405 { "normalization_layer_in_map_nchw", "normalization_layer.cl" },
406 { "normalization_layer_in_map_nhwc", "normalization_layer.cl" },
Michele Di Giorgiob57be0d2018-08-31 16:26:25 +0100407 { "normalize_planar_yuv_layer_nchw", "normalize_planar_yuv_layer.cl" },
408 { "normalize_planar_yuv_layer_nhwc", "normalize_planar_yuv_layer.cl" },
Michele Di Giorgiod63dfa22018-09-12 10:18:54 +0100409 { "normalize_planar_yuv_layer_q8_nchw", "normalize_planar_yuv_layer_quantized.cl" },
410 { "normalize_planar_yuv_layer_q8_nhwc", "normalize_planar_yuv_layer_quantized.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100411 { "NV12_to_IYUV_bt709", "color_convert.cl" },
412 { "NV12_to_RGB888_bt709", "color_convert.cl" },
413 { "NV12_to_RGBA8888_bt709", "color_convert.cl" },
414 { "NV12_to_YUV444_bt709", "color_convert.cl" },
415 { "NV21_to_IYUV_bt709", "color_convert.cl" },
416 { "NV21_to_RGB888_bt709", "color_convert.cl" },
417 { "NV21_to_RGBA8888_bt709", "color_convert.cl" },
418 { "NV21_to_YUV444_bt709", "color_convert.cl" },
Giorgio Arena5c4a8e92019-08-28 17:55:07 +0100419 { "pad_layer_constant", "pad_layer.cl" },
420 { "pad_layer_symmetric_reflect", "pad_layer.cl" },
shubhame1a4e372019-01-07 21:37:55 +0530421 { "permute", "permute.cl" },
Georgios Pinitas8be91482019-03-26 17:23:28 +0000422 { "pixelwise_mul_complex", "pixelwise_mul_float.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100423 { "pixelwise_mul_float", "pixelwise_mul_float.cl" },
424 { "pixelwise_mul_int", "pixelwise_mul_int.cl" },
Georgios Pinitasbf28a3c2018-09-18 14:34:48 +0100425 { "pixelwise_mul_quantized", "pixelwise_mul_int.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100426 { "pooling_layer_2", "pooling_layer.cl" },
427 { "pooling_layer_3", "pooling_layer.cl" },
Anton Lokhmotovaf6204c2017-11-08 09:34:19 +0000428 { "pooling_layer_optimized_3", "pooling_layer.cl" },
Georgios Pinitasce093142017-06-19 16:11:53 +0100429 { "pooling_layer_7", "pooling_layer.cl" },
Michalis Spyroue74b2012018-04-18 09:49:16 +0100430 { "pooling_layer_MxN_nchw", "pooling_layer.cl" },
431 { "pooling_layer_MxN_nhwc", "pooling_layer.cl" },
432 { "pooling_layer_MxN_quantized_nhwc", "pooling_layer_quantized.cl" },
433 { "pooling_layer_MxN_quantized_nchw", "pooling_layer_quantized.cl" },
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +0100434 { "prior_box_layer_nchw", "prior_box_layer.cl" },
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100435 { "quantization_layer", "quantization_layer.cl" },
Vidhya Sudhan Loganathan5e96be72018-12-18 14:17:00 +0000436 { "range", "range.cl" },
437 { "range_quantized", "range.cl" },
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100438 { "reduction_operation_x", "reduction_operation.cl" },
Michalis Spyrou7930db42018-11-22 17:36:28 +0000439 { "reduction_operation_non_parallel_x", "reduction_operation.cl" },
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100440 { "reduction_operation_y", "reduction_operation.cl" },
441 { "reduction_operation_z", "reduction_operation.cl" },
442 { "reduction_operation_w", "reduction_operation.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100443 { "remap_nearest_neighbour", "remap.cl" },
444 { "remap_bilinear", "remap.cl" },
Gian Marco Iodice477531c2018-08-21 17:53:38 +0100445 { "reorg_layer_nchw", "reorg_layer.cl" },
446 { "reorg_layer_nhwc", "reorg_layer.cl" },
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +0100447 { "reshape_layer", "reshape_layer.cl" },
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +0100448 { "reshape_to_columns", "convolution_layer.cl" },
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000449 { "reverse", "reverse.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100450 { "RGB888_to_IYUV_bt709", "color_convert.cl" },
451 { "RGB888_to_NV12_bt709", "color_convert.cl" },
452 { "RGB888_to_RGBA8888_bt709", "color_convert.cl" },
Manuel Bottiniacaf21d2018-09-26 17:38:19 +0100453 { "RGB888_to_U8_bt709", "color_convert.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100454 { "RGB888_to_YUV444_bt709", "color_convert.cl" },
455 { "RGBA8888_to_IYUV_bt709", "color_convert.cl" },
456 { "RGBA8888_to_NV12_bt709", "color_convert.cl" },
457 { "RGBA8888_to_RGB888_bt709", "color_convert.cl" },
458 { "RGBA8888_to_YUV444_bt709", "color_convert.cl" },
giuros0118870812018-09-13 09:31:40 +0100459 { "roi_align_layer", "roi_align_layer.cl" },
Michele Di Giorgio578a9fc2019-08-23 11:49:04 +0100460 { "roi_align_layer_quantized", "roi_align_layer_quantized.cl" },
SiCong Li3e363692017-07-04 15:02:10 +0100461 { "roi_pooling_layer", "roi_pooling_layer.cl" },
Michalis Spyrou46da23f2018-04-10 13:41:30 +0100462 { "scale_nearest_neighbour_nchw", "scale.cl" },
463 { "scale_nearest_neighbour_nhwc", "scale.cl" },
464 { "scale_bilinear_nchw", "scale.cl" },
465 { "scale_bilinear_nhwc", "scale.cl" },
Michalis Spyrou17220e22018-09-12 13:35:38 +0100466 { "scale_bilinear_quantized_nchw", "scale_quantized.cl" },
467 { "scale_bilinear_quantized_nhwc", "scale_quantized.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100468 { "scharr3x3", "scharr_filter.cl" },
Georgios Pinitasaaa27182018-11-21 16:32:15 +0000469 { "select_same_rank", "select.cl" },
470 { "select_different_rank_2", "select.cl" },
471 { "select_different_rank_n", "select.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100472 { "sobel3x3", "sobel_filter.cl" },
473 { "sobel_separable5x1", "sobel_filter.cl" },
474 { "sobel_separable1x5", "sobel_filter.cl" },
475 { "sobel_separable7x1", "sobel_filter.cl" },
476 { "sobel_separable1x7", "sobel_filter.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100477 { "softmax_layer_norm", "softmax_layer.cl" },
Chunosovf450caa2017-11-08 16:09:35 +0700478 { "softmax_layer_norm_quantized", "softmax_layer_quantized.cl" },
Giorgio Arena4402cb92018-02-15 13:37:40 +0000479 { "softmax_layer_max_shift_exp_sum_quantized_serial", "softmax_layer_quantized.cl" },
480 { "softmax_layer_max_shift_exp_sum_quantized_parallel", "softmax_layer_quantized.cl" },
Chunosovd6afedc2017-11-06 22:09:45 +0700481 { "softmax_layer_max_shift_exp_sum_serial", "softmax_layer.cl" },
Michalis Spyrou13a51e12018-09-18 13:09:30 +0100482 { "space_to_batch_nchw", "space_to_batch.cl" },
483 { "space_to_batch_static_nchw", "space_to_batch.cl" },
484 { "space_to_batch_nhwc", "space_to_batch.cl" },
485 { "space_to_batch_static_nhwc", "space_to_batch.cl" },
Michalis Spyroud69b3b22019-05-29 17:03:38 +0100486 { "space_to_depth_nchw", "space_to_depth.cl" },
487 { "space_to_depth_nhwc", "space_to_depth.cl" },
Chunosovd6afedc2017-11-06 22:09:45 +0700488 { "softmax_layer_max_shift_exp_sum_parallel", "softmax_layer.cl" },
Gian Marco Iodice8aa985e2018-11-27 15:58:08 +0000489 { "stack_layer", "stack_layer.cl" },
Georgios Pinitasc1a72452018-08-24 11:25:32 +0100490 { "strided_slice", "slice_ops.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100491 { "suppress_non_maximum", "canny.cl" },
492 { "tablelookup_U8", "tablelookup.cl" },
493 { "tablelookup_S16", "tablelookup.cl" },
494 { "threshold_binary", "threshold.cl" },
495 { "threshold_range", "threshold.cl" },
giuros013175fcf2018-11-21 09:59:17 +0000496 { "tile", "tile.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100497 { "transpose", "transpose.cl" },
498 { "UYVY422_to_IYUV_bt709", "color_convert.cl" },
499 { "UYVY422_to_NV12_bt709", "color_convert.cl" },
500 { "UYVY422_to_RGB888_bt709", "color_convert.cl" },
501 { "UYVY422_to_RGBA8888_bt709", "color_convert.cl" },
Michalis Spyrouceb889e2018-09-17 18:24:41 +0100502 { "upsample_layer_nchw", "upsample_layer.cl" },
503 { "upsample_layer_nhwc", "upsample_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100504 { "warp_affine_nearest_neighbour", "warp_affine.cl" },
505 { "warp_affine_bilinear", "warp_affine.cl" },
506 { "warp_perspective_nearest_neighbour", "warp_perspective.cl" },
507 { "warp_perspective_bilinear", "warp_perspective.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100508 { "winograd_filter_transform_2x2_3x3_nchw", "winograd_filter_transform.cl" },
509 { "winograd_filter_transform_2x1_3x1_nchw", "winograd_filter_transform.cl" },
510 { "winograd_filter_transform_1x2_1x3_nchw", "winograd_filter_transform.cl" },
511 { "winograd_filter_transform_4x4_3x3_nchw", "winograd_filter_transform.cl" },
512 { "winograd_filter_transform_4x1_3x1_nchw", "winograd_filter_transform.cl" },
513 { "winograd_filter_transform_1x4_1x3_nchw", "winograd_filter_transform.cl" },
514 { "winograd_filter_transform_4x4_5x5_nchw", "winograd_filter_transform.cl" },
Gian Marco Iodice876be2a2018-07-03 12:22:09 +0100515 { "winograd_filter_transform_4x1_5x1_nchw", "winograd_filter_transform.cl" },
516 { "winograd_filter_transform_1x4_1x5_nchw", "winograd_filter_transform.cl" },
Giorgio Arena149fdf32018-07-04 17:03:33 +0100517 { "winograd_filter_transform_4x1_3x1_nhwc", "winograd_filter_transform.cl" },
518 { "winograd_filter_transform_1x4_1x3_nhwc", "winograd_filter_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100519 { "winograd_filter_transform_4x4_3x3_nhwc", "winograd_filter_transform.cl" },
520 { "winograd_filter_transform_4x4_5x5_nhwc", "winograd_filter_transform.cl" },
Gian Marco Iodiced28b7512018-07-06 12:59:28 +0100521 { "winograd_filter_transform_4x1_5x1_nhwc", "winograd_filter_transform.cl" },
522 { "winograd_filter_transform_1x4_1x5_nhwc", "winograd_filter_transform.cl" },
Michele Di Giorgio881c6842019-02-27 14:26:51 +0000523 { "winograd_filter_transform_2x2_7x7_nhwc", "winograd_filter_transform.cl" },
524 { "winograd_filter_transform_2x1_7x1_nhwc", "winograd_filter_transform.cl" },
525 { "winograd_filter_transform_1x2_1x7_nhwc", "winograd_filter_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100526 { "winograd_input_transform_2x2_3x3_stepz1_nchw", "winograd_input_transform.cl" },
527 { "winograd_input_transform_2x2_3x3_stepz2_nchw", "winograd_input_transform.cl" },
528 { "winograd_input_transform_2x1_3x1_stepz1_nchw", "winograd_input_transform.cl" },
529 { "winograd_input_transform_2x1_3x1_stepz2_nchw", "winograd_input_transform.cl" },
530 { "winograd_input_transform_1x2_1x3_stepz1_nchw", "winograd_input_transform.cl" },
531 { "winograd_input_transform_1x2_1x3_stepz2_nchw", "winograd_input_transform.cl" },
532 { "winograd_input_transform_4x4_3x3_stepz1_nchw", "winograd_input_transform.cl" },
533 { "winograd_input_transform_4x1_3x1_stepz1_nchw", "winograd_input_transform.cl" },
534 { "winograd_input_transform_1x4_1x3_stepz1_nchw", "winograd_input_transform.cl" },
535 { "winograd_input_transform_4x4_5x5_stepz1_nchw", "winograd_input_transform.cl" },
Gian Marco Iodice876be2a2018-07-03 12:22:09 +0100536 { "winograd_input_transform_4x1_5x1_stepz1_nchw", "winograd_input_transform.cl" },
537 { "winograd_input_transform_1x4_1x5_stepz1_nchw", "winograd_input_transform.cl" },
Giorgio Arena149fdf32018-07-04 17:03:33 +0100538 { "winograd_input_transform_4x1_3x1_stepz1_nhwc", "winograd_input_transform.cl" },
539 { "winograd_input_transform_1x4_1x3_stepz1_nhwc", "winograd_input_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100540 { "winograd_input_transform_4x4_3x3_stepz1_nhwc", "winograd_input_transform.cl" },
541 { "winograd_input_transform_4x4_5x5_stepz1_nhwc", "winograd_input_transform.cl" },
Gian Marco Iodiced28b7512018-07-06 12:59:28 +0100542 { "winograd_input_transform_4x1_5x1_stepz1_nhwc", "winograd_input_transform.cl" },
543 { "winograd_input_transform_1x4_1x5_stepz1_nhwc", "winograd_input_transform.cl" },
Michele Di Giorgiof955d512019-02-27 14:26:51 +0000544 { "winograd_input_transform_2x2_7x7_stepz1_nhwc", "winograd_input_transform.cl" },
545 { "winograd_input_transform_2x1_7x1_stepz1_nhwc", "winograd_input_transform.cl" },
546 { "winograd_input_transform_1x2_1x7_stepz1_nhwc", "winograd_input_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100547 { "winograd_output_transform_2x2_3x3_nchw", "winograd_output_transform.cl" },
548 { "winograd_output_transform_2x1_3x1_nchw", "winograd_output_transform.cl" },
549 { "winograd_output_transform_1x2_1x3_nchw", "winograd_output_transform.cl" },
550 { "winograd_output_transform_4x4_3x3_nchw", "winograd_output_transform.cl" },
551 { "winograd_output_transform_4x1_3x1_nchw", "winograd_output_transform.cl" },
552 { "winograd_output_transform_1x4_1x3_nchw", "winograd_output_transform.cl" },
553 { "winograd_output_transform_4x4_5x5_nchw", "winograd_output_transform.cl" },
Gian Marco Iodice876be2a2018-07-03 12:22:09 +0100554 { "winograd_output_transform_4x1_5x1_nchw", "winograd_output_transform.cl" },
555 { "winograd_output_transform_1x4_1x5_nchw", "winograd_output_transform.cl" },
Giorgio Arena149fdf32018-07-04 17:03:33 +0100556 { "winograd_output_transform_4x1_3x1_nhwc", "winograd_output_transform.cl" },
557 { "winograd_output_transform_1x4_1x3_nhwc", "winograd_output_transform.cl" },
Giorgio Arenaa50e5e02018-07-02 13:42:23 +0100558 { "winograd_output_transform_4x4_3x3_nhwc", "winograd_output_transform.cl" },
559 { "winograd_output_transform_4x4_5x5_nhwc", "winograd_output_transform.cl" },
Gian Marco Iodiced28b7512018-07-06 12:59:28 +0100560 { "winograd_output_transform_4x1_5x1_nhwc", "winograd_output_transform.cl" },
561 { "winograd_output_transform_1x4_1x5_nhwc", "winograd_output_transform.cl" },
giuros013bfacb22019-04-01 12:07:02 +0100562 { "winograd_output_transform_2x2_7x7_nhwc", "winograd_output_transform.cl" },
563 { "winograd_output_transform_2x1_7x1_nhwc", "winograd_output_transform.cl" },
564 { "winograd_output_transform_1x2_1x7_nhwc", "winograd_output_transform.cl" },
Giorgio Arena73023022018-09-04 14:55:55 +0100565 { "yolo_layer_nchw", "yolo_layer.cl" },
566 { "yolo_layer_nhwc", "yolo_layer.cl" },
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100567 { "YUYV422_to_IYUV_bt709", "color_convert.cl" },
568 { "YUYV422_to_NV12_bt709", "color_convert.cl" },
569 { "YUYV422_to_RGB888_bt709", "color_convert.cl" },
570 { "YUYV422_to_RGBA8888_bt709", "color_convert.cl" },
571};
572
573const std::map<std::string, std::string> CLKernelLibrary::_program_source_map =
574{
575#ifdef EMBEDDED_KERNELS
576 {
577 "absdiff.cl",
578#include "./cl_kernels/absdiff.clembed"
579 },
580 {
581 "accumulate.cl",
582#include "./cl_kernels/accumulate.clembed"
583 },
584 {
585 "activation_layer.cl",
586#include "./cl_kernels/activation_layer.clembed"
587 },
588 {
Manuel Bottini30dbeef2019-06-26 16:23:03 +0100589 "activation_layer_quant.cl",
590#include "./cl_kernels/activation_layer_quant.clembed"
Michel Iwaniec00633802017-10-12 14:14:15 +0100591 },
592 {
Manuel Bottini7b9998d2019-10-21 17:59:07 +0100593 "arg_min_max.cl",
594#include "./cl_kernels/arg_min_max.clembed"
595 },
596 {
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +0100597 "batch_to_space.cl",
598#include "./cl_kernels/batch_to_space.clembed"
599 },
600 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100601 "bitwise_op.cl",
602#include "./cl_kernels/bitwise_op.clembed"
603 },
604 {
giuros01c04a0e82018-10-03 12:44:35 +0100605 "bounding_box_transform.cl",
606#include "./cl_kernels/bounding_box_transform.clembed"
607 },
608 {
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100609 "bounding_box_transform_quantized.cl",
610#include "./cl_kernels/bounding_box_transform_quantized.clembed"
611 },
612 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100613 "canny.cl",
614#include "./cl_kernels/canny.clembed"
615 },
616 {
617 "channel_combine.cl",
618#include "./cl_kernels/channel_combine.clembed"
619 },
620 {
621 "channel_extract.cl",
622#include "./cl_kernels/channel_extract.clembed"
623 },
624 {
Michele Di Giorgio72175632018-05-01 16:52:00 +0100625 "channel_shuffle.cl",
626#include "./cl_kernels/channel_shuffle.clembed"
627 },
628 {
Gian Marco76faef82018-01-29 12:15:32 +0000629 "col2im.cl",
630#include "./cl_kernels/col2im.clembed"
631 },
632 {
Georgios Pinitas7900a9e2018-11-23 11:44:58 +0000633 "comparisons.cl",
634#include "./cl_kernels/comparisons.clembed"
635 },
636 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100637 "concatenate.cl",
638#include "./cl_kernels/concatenate.clembed"
639 },
640 {
641 "color_convert.cl",
642#include "./cl_kernels/color_convert.clembed"
643 },
644 {
Giorgio Arena657bdb32018-04-26 18:52:01 +0100645 "convert_fc_weights.cl",
646#include "./cl_kernels/convert_fc_weights.clembed"
647 },
648 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100649 "convolution3x3.cl",
650#include "./cl_kernels/convolution3x3.clembed"
651 },
652 {
653 "convolution5x5.cl",
654#include "./cl_kernels/convolution5x5.clembed"
655 },
656 {
657 "convolution7x7.cl",
658#include "./cl_kernels/convolution7x7.clembed"
659 },
660 {
661 "convolution9x9.cl",
662#include "./cl_kernels/convolution9x9.clembed"
663 },
664 {
665 "convolution_layer.cl",
666#include "./cl_kernels/convolution_layer.clembed"
667 },
668 {
669 "convolution_rectangle.cl",
670#include "./cl_kernels/convolution_rectangle.clembed"
671 },
672 {
Michalis Spyrou5c8e05c2018-03-22 11:56:01 +0000673 "copy_tensor.cl",
674#include "./cl_kernels/copy_tensor.clembed"
675 },
676 {
George Wort894066d2019-02-15 15:12:52 +0000677 "crop_tensor.cl",
678#include "./cl_kernels/crop_tensor.clembed"
679 },
680 {
Michalis Spyrouceb889e2018-09-17 18:24:41 +0100681 "upsample_layer.cl",
682#include "./cl_kernels/upsample_layer.clembed"
683 },
684 {
Michalis Spyrou780db4e2017-11-23 09:49:51 +0000685 "deconvolution_layer.cl",
686#include "./cl_kernels/deconvolution_layer.clembed"
687 },
688 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100689 "depth_convert.cl",
690#include "./cl_kernels/depth_convert.clembed"
691 },
692 {
Michalis Spyrou649962c2019-05-22 11:11:55 +0100693 "depth_to_space.cl",
694#include "./cl_kernels/depth_to_space.clembed"
695 },
696 {
Giorgio Arena93a690e2017-08-01 16:09:33 +0100697 "depthwise_convolution.cl",
698#include "./cl_kernels/depthwise_convolution.clembed"
699 },
700 {
Dmitry Savenkod7295b72017-11-20 22:00:08 +0700701 "depthwise_convolution_quantized.cl",
702#include "./cl_kernels/depthwise_convolution_quantized.clembed"
703 },
704 {
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100705 "dequantization_layer.cl",
706#include "./cl_kernels/dequantization_layer.clembed"
707 },
708 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100709 "derivative.cl",
710#include "./cl_kernels/derivative.clembed"
711 },
712 {
713 "dilate.cl",
714#include "./cl_kernels/dilate.clembed"
715 },
716 {
SiCong Lic51b72f2017-07-28 14:46:20 +0100717 "direct_convolution1x1.cl",
718#include "./cl_kernels/direct_convolution1x1.clembed"
719 },
720 {
721 "direct_convolution3x3.cl",
722#include "./cl_kernels/direct_convolution3x3.clembed"
steniu0127b386c2017-07-18 17:37:43 +0100723 },
724 {
steniu01db006682017-08-09 16:26:22 +0100725 "direct_convolution5x5.cl",
726#include "./cl_kernels/direct_convolution5x5.clembed"
727 },
728 {
Sang-Hoon Parkab5b1a22019-10-15 09:29:13 +0100729 "direct_convolution_quantized.cl",
730#include "./cl_kernels/direct_convolution_quantized.clembed"
Chunosovd621bca2017-11-03 17:33:15 +0700731 },
732 {
Michalis Spyrou45091732019-05-13 17:41:01 +0100733 "direct_convolution9x9.cl",
734#include "./cl_kernels/direct_convolution9x9.clembed"
735 },
736 {
giuros01164a2722018-11-20 18:34:46 +0000737 "elementwise_operation.cl",
738#include "./cl_kernels/elementwise_operation.clembed"
739 },
740 {
741 "elementwise_operation_quantized.cl",
742#include "./cl_kernels/elementwise_operation_quantized.clembed"
743 },
744 {
Michalis Spyroue9362622018-11-23 17:41:37 +0000745 "elementwise_unary.cl",
746#include "./cl_kernels/elementwise_unary.clembed"
747 },
748 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100749 "erode.cl",
750#include "./cl_kernels/erode.clembed"
751 },
752 {
753 "fast_corners.cl",
754#include "./cl_kernels/fast_corners.clembed"
755 },
756 {
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000757 "fft.cl",
758#include "./cl_kernels/fft.clembed"
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +0100759 },
760 {
Georgios Pinitas8be91482019-03-26 17:23:28 +0000761 "fft_digit_reverse.cl",
762#include "./cl_kernels/fft_digit_reverse.clembed"
763 },
764 {
765 "fft_scale.cl",
766#include "./cl_kernels/fft_scale.clembed"
767 },
768 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100769 "fill_border.cl",
770#include "./cl_kernels/fill_border.clembed"
771 },
772 {
Georgios Pinitas0bc78492019-03-18 20:07:37 +0000773 "flatten.cl",
774#include "./cl_kernels/flatten.clembed"
775 },
776 {
Georgios Pinitasd8e765b2017-08-02 13:44:33 +0100777 "floor.cl",
778#include "./cl_kernels/floor.clembed"
779 },
780 {
Manuel Bottini8529bd62018-11-21 11:53:04 +0000781 "gather.cl",
782#include "./cl_kernels/gather.clembed"
783 },
784 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100785 "gaussian_pyramid.cl",
786#include "./cl_kernels/gaussian_pyramid.clembed"
787 },
788 {
789 "gemm.cl",
790#include "./cl_kernels/gemm.clembed"
791 },
792 {
Gian Marco05288a22017-11-21 10:57:50 +0000793 "gemmlowp.cl",
794#include "./cl_kernels/gemmlowp.clembed"
795 },
796 {
Giorgio Arena9fe41442017-08-23 16:36:24 +0100797 "gemv.cl",
798#include "./cl_kernels/gemv.clembed"
799 },
800 {
Manuel Bottini5209be52019-02-13 16:34:56 +0000801 "generate_proposals.cl",
802#include "./cl_kernels/generate_proposals.clembed"
803 },
804 {
Michele Di Giorgio6b612f52019-09-05 12:30:22 +0100805 "generate_proposals_quantized.cl",
806#include "./cl_kernels/generate_proposals_quantized.clembed"
807 },
808 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100809 "harris_corners.cl",
810#include "./cl_kernels/harris_corners.clembed"
811 },
812 {
813 "helpers.h",
814#include "./cl_kernels/helpers.hembed"
815 },
816 {
Chunosovd621bca2017-11-03 17:33:15 +0700817 "helpers_asymm.h",
818#include "./cl_kernels/helpers_asymm.hembed"
819 },
820 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100821 "histogram.cl",
822#include "./cl_kernels/histogram.clembed"
823 },
824 {
825 "hog.cl",
826#include "./cl_kernels/hog.clembed"
827 },
828 {
Gian Marco76faef82018-01-29 12:15:32 +0000829 "im2col.cl",
830#include "./cl_kernels/im2col.clembed"
831 },
832 {
Manuel Bottini79f88e62019-09-18 15:02:53 +0100833 "instance_normalization.cl",
834#include "./cl_kernels/instance_normalization.clembed"
835 },
836 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100837 "integral_image.cl",
838#include "./cl_kernels/integral_image.clembed"
839 },
840 {
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100841 "l2_normalize.cl",
842#include "./cl_kernels/l2_normalize.clembed"
843 },
844 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100845 "magnitude_phase.cl",
846#include "./cl_kernels/magnitude_phase.clembed"
847 },
848 {
849 "mean_stddev.cl",
850#include "./cl_kernels/mean_stddev.clembed"
851 },
852 {
Michele Di Giorgio5b48ad72019-06-04 18:43:35 +0100853 "mean_stddev_normalization.cl",
854#include "./cl_kernels/mean_stddev_normalization.clembed"
855 },
856 {
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100857 "memset.cl",
858#include "./cl_kernels/memset.clembed"
859 },
860 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100861 "minmaxloc.cl",
862#include "./cl_kernels/minmaxloc.clembed"
863 },
864 {
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100865 "minmax_layer.cl",
866#include "./cl_kernels/minmax_layer.clembed"
867 },
868 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100869 "non_linear_filter3x3.cl",
870#include "./cl_kernels/non_linear_filter3x3.clembed"
871 },
872 {
873 "non_linear_filter5x5.cl",
874#include "./cl_kernels/non_linear_filter5x5.clembed"
875 },
876 {
877 "non_linear_filter_helpers.h",
878#include "./cl_kernels/non_linear_filter_helpers.hembed"
879 },
880 {
881 "nonmax.cl",
882#include "./cl_kernels/nonmax.clembed"
883 },
884 {
885 "normalization_layer.cl",
886#include "./cl_kernels/normalization_layer.clembed"
887 },
888 {
Michele Di Giorgiob57be0d2018-08-31 16:26:25 +0100889 "normalize_planar_yuv_layer.cl",
890#include "./cl_kernels/normalize_planar_yuv_layer.clembed"
891 },
892 {
Michele Di Giorgiod63dfa22018-09-12 10:18:54 +0100893 "normalize_planar_yuv_layer_quantized.cl",
894#include "./cl_kernels/normalize_planar_yuv_layer_quantized.clembed"
895 },
896 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100897 "batchnormalization_layer.cl",
898#include "./cl_kernels/batchnormalization_layer.clembed"
899 },
900 {
901 "optical_flow_pyramid_lk.cl",
902#include "./cl_kernels/optical_flow_pyramid_lk.clembed"
903 },
904 {
Giorgio Arena205eed82019-08-14 10:13:50 +0100905 "pad_layer.cl",
906#include "./cl_kernels/pad_layer.clembed"
907 },
908 {
Michalis Spyrou5237e012018-01-17 09:40:27 +0000909 "permute.cl",
910#include "./cl_kernels/permute.clembed"
911 },
912 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100913 "pixelwise_mul_float.cl",
914#include "./cl_kernels/pixelwise_mul_float.clembed"
915 },
916 {
917 "pixelwise_mul_int.cl",
918#include "./cl_kernels/pixelwise_mul_int.clembed"
919 },
920 {
921 "pooling_layer.cl",
922#include "./cl_kernels/pooling_layer.clembed"
923 },
924 {
Anton Lokhmotovaf6204c2017-11-08 09:34:19 +0000925 "pooling_layer_quantized.cl",
926#include "./cl_kernels/pooling_layer_quantized.clembed"
927 },
928 {
Michalis Spyrou6c7c38e2018-08-29 16:28:11 +0100929 "prior_box_layer.cl",
930#include "./cl_kernels/prior_box_layer.clembed"
931 },
932 {
Michele Di Giorgio56dd7262017-07-27 09:53:49 +0100933 "quantization_layer.cl",
934#include "./cl_kernels/quantization_layer.clembed"
935 },
936 {
Vidhya Sudhan Loganathan5e96be72018-12-18 14:17:00 +0000937 "range.cl",
938#include "./cl_kernels/range.clembed"
939 },
940 {
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100941 "reduction_operation.cl",
942#include "./cl_kernels/reduction_operation.clembed"
943 },
944 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100945 "remap.cl",
946#include "./cl_kernels/remap.clembed"
947 },
948 {
Gian Marco Iodice477531c2018-08-21 17:53:38 +0100949 "reorg_layer.cl",
950#include "./cl_kernels/reorg_layer.clembed"
951 },
952 {
Georgios Pinitas5ee66ea2017-09-07 17:29:16 +0100953 "reshape_layer.cl",
954#include "./cl_kernels/reshape_layer.clembed"
955 },
956 {
Michele Di Giorgio5daeffd2018-11-26 10:01:15 +0000957 "reverse.cl",
958#include "./cl_kernels/reverse.clembed"
959 },
960 {
giuros0118870812018-09-13 09:31:40 +0100961 "roi_align_layer.cl",
962#include "./cl_kernels/roi_align_layer.clembed"
963 },
964 {
Michele Di Giorgio578a9fc2019-08-23 11:49:04 +0100965 "roi_align_layer_quantized.cl",
966#include "./cl_kernels/roi_align_layer_quantized.clembed"
967 },
968 {
SiCong Li3e363692017-07-04 15:02:10 +0100969 "roi_pooling_layer.cl",
970#include "./cl_kernels/roi_pooling_layer.clembed"
971 },
972 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100973 "scale.cl",
974#include "./cl_kernels/scale.clembed"
975 },
976 {
Michalis Spyrou17220e22018-09-12 13:35:38 +0100977 "scale_quantized.cl",
978#include "./cl_kernels/scale_quantized.clembed"
979 },
980 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100981 "scharr_filter.cl",
982#include "./cl_kernels/scharr_filter.clembed"
983 },
984 {
Georgios Pinitasaaa27182018-11-21 16:32:15 +0000985 "select.cl",
986#include "./cl_kernels/select.clembed"
987 },
988 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100989 "sobel_filter.cl",
990#include "./cl_kernels/sobel_filter.clembed"
991 },
992 {
993 "softmax_layer.cl",
994#include "./cl_kernels/softmax_layer.clembed"
995 },
996 {
Chunosovf450caa2017-11-08 16:09:35 +0700997 "softmax_layer_quantized.cl",
998#include "./cl_kernels/softmax_layer_quantized.clembed"
999 },
1000 {
Georgios Pinitasc1a72452018-08-24 11:25:32 +01001001 "slice_ops.cl",
1002#include "./cl_kernels/slice_ops.clembed"
Georgios Pinitas77589b52018-08-21 14:41:35 +01001003 },
1004 {
Michalis Spyrou16934a52018-08-21 18:03:58 +01001005 "space_to_batch.cl",
1006#include "./cl_kernels/space_to_batch.clembed"
1007 },
1008 {
Michalis Spyroud69b3b22019-05-29 17:03:38 +01001009 "space_to_depth.cl",
1010#include "./cl_kernels/space_to_depth.clembed"
1011 },
1012 {
Gian Marco Iodice8aa985e2018-11-27 15:58:08 +00001013 "stack_layer.cl",
1014#include "./cl_kernels/stack_layer.clembed"
1015 },
1016 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001017 "tablelookup.cl",
1018#include "./cl_kernels/tablelookup.clembed"
1019 },
1020 {
1021 "threshold.cl",
1022#include "./cl_kernels/threshold.clembed"
1023 },
1024 {
giuros013175fcf2018-11-21 09:59:17 +00001025 "tile.cl",
1026#include "./cl_kernels/tile.clembed"
1027 },
1028 {
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001029 "transpose.cl",
1030#include "./cl_kernels/transpose.clembed"
1031 },
1032 {
1033 "types.h",
1034#include "./cl_kernels/types.hembed"
1035 },
1036 {
1037 "warp_affine.cl",
1038#include "./cl_kernels/warp_affine.clembed"
1039 },
1040 {
1041 "warp_helpers.h",
1042#include "./cl_kernels/warp_helpers.hembed"
1043 },
1044 {
1045 "warp_perspective.cl",
1046#include "./cl_kernels/warp_perspective.clembed"
Michalis Spyroud7e82812017-06-20 15:00:14 +01001047 },
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +00001048 {
Giorgio Arenaa50e5e02018-07-02 13:42:23 +01001049 "winograd_filter_transform.cl",
1050#include "./cl_kernels/winograd_filter_transform.clembed"
1051 },
1052 {
1053 "winograd_input_transform.cl",
1054#include "./cl_kernels/winograd_input_transform.clembed"
1055 },
1056 {
1057 "winograd_output_transform.cl",
1058#include "./cl_kernels/winograd_output_transform.clembed"
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +00001059 },
Giorgio Arena73023022018-09-04 14:55:55 +01001060 {
1061 "yolo_layer.cl",
1062#include "./cl_kernels/yolo_layer.clembed"
1063 },
Anthony Barbierac69aa12017-07-03 17:39:37 +01001064#endif /* EMBEDDED_KERNELS */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001065};
1066
1067CLKernelLibrary::CLKernelLibrary()
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001068 : _context(), _device(), _kernel_path("."), _programs_map(), _built_programs_map()
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001069{
Anthony Barbierecb1c622018-04-17 11:45:10 +01001070 opencl_is_available(); // Make sure the OpenCL symbols are initialised *before* the CLKernelLibrary is built
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001071}
1072
1073CLKernelLibrary &CLKernelLibrary::get()
1074{
1075 static CLKernelLibrary _kernel_library;
1076 return _kernel_library;
1077}
1078
1079Kernel CLKernelLibrary::create_kernel(const std::string &kernel_name, const StringSet &build_options_set) const
1080{
1081 // Find which program contains the kernel
1082 auto kernel_program_it = _kernel_program_map.find(kernel_name);
1083
1084 if(_kernel_program_map.end() == kernel_program_it)
1085 {
Michalis Spyrou7c60c992019-10-10 14:33:47 +01001086 ARM_COMPUTE_ERROR_VAR("Kernel %s not found in the CLKernelLibrary", kernel_name.c_str());
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001087 }
steniu0134702472017-07-11 09:22:58 +01001088 std::string concat_str;
1089
Georgios Pinitasdf473ea2018-05-31 18:53:52 +01001090#if defined(ARM_COMPUTE_DEBUG_ENABLED)
1091 // Enable debug properties in CL kernels
1092 concat_str += " -DARM_COMPUTE_DEBUG_ENABLED";
1093#endif // defined(ARM_COMPUTE_DEBUG_ENABLED)
1094
Usama Arife2428a02019-05-09 11:03:17 +01001095 GPUTarget gpu_arch = get_arch_from_target(get_target_from_device(_device));
1096 concat_str += " -DGPU_ARCH=" + support::cpp11::to_string(
1097 static_cast<std::underlying_type<GPUTarget>::type>(gpu_arch));
Vidhya Sudhan Loganathanf1f49062018-05-25 13:21:26 +01001098 if(fp16_supported())
Matthew Bentham6f31f8c2017-10-27 11:50:06 +01001099 {
1100 concat_str += " -DARM_COMPUTE_OPENCL_FP16_ENABLED=1 ";
1101 }
1102
Michalis Spyroue03342e2018-01-15 14:39:13 +00001103 if(dot8_supported(_device))
1104 {
1105 concat_str += " -DARM_COMPUTE_OPENCL_DOT8_ENABLED=1 ";
1106 }
1107
Giorgio Arenaeff8d952018-07-02 15:29:57 +01001108 if(dot8_acc_supported(_device))
1109 {
1110 concat_str += " -DARM_COMPUTE_OPENCL_DOT8_ACC_ENABLED=1 ";
1111 }
1112
Pablo Telloe86a09f2018-01-11 15:44:48 +00001113 if(get_cl_version(_device) == CLVersion::CL20)
steniu0134702472017-07-11 09:22:58 +01001114 {
1115 concat_str += " -cl-std=CL2.0 ";
1116 }
Anthony Barbierd727e852018-04-20 11:05:29 +01001117 else if(arm_non_uniform_workgroup_supported(_device))
Pablo Telloe86a09f2018-01-11 15:44:48 +00001118 {
1119 concat_str += " -cl-arm-non-uniform-work-group-size ";
1120 }
steniu0134702472017-07-11 09:22:58 +01001121 else
1122 {
1123 ARM_COMPUTE_ERROR("Non uniform workgroup size is not supported!!");
1124 }
1125
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001126 // Check if the program has been built before with same build options.
steniu0134702472017-07-11 09:22:58 +01001127 const std::string program_name = kernel_program_it->second;
1128 const std::string build_options = stringify_set(build_options_set) + concat_str;
1129
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001130 const std::string built_program_name = program_name + "_" + build_options;
1131 auto built_program_it = _built_programs_map.find(built_program_name);
1132
1133 cl::Program cl_program;
1134
1135 if(_built_programs_map.end() != built_program_it)
1136 {
1137 // If program has been built, retrieve to create kernel from it
1138 cl_program = built_program_it->second;
1139 }
1140 else
1141 {
1142 // Get program
1143 Program program = load_program(program_name);
1144
1145 // Build program
1146 cl_program = program.build(build_options);
1147
1148 // Add built program to internal map
1149 _built_programs_map.emplace(built_program_name, cl_program);
1150 }
1151
1152 // Create and return kernel
1153 return Kernel(kernel_name, cl_program);
1154}
1155
Pablo Tellodb8485a2019-09-24 11:03:47 +01001156void CLKernelLibrary::init(std::string kernel_path, cl::Context context, cl::Device device)
1157{
1158 _kernel_path = std::move(kernel_path);
1159 _context = std::move(context);
1160 _device = std::move(device);
1161}
1162
1163void CLKernelLibrary::set_kernel_path(const std::string &kernel_path)
1164{
1165 _kernel_path = kernel_path;
1166}
1167
1168cl::Context &CLKernelLibrary::context()
1169{
1170 return _context;
1171}
1172
1173cl::Device &CLKernelLibrary::get_device()
1174{
1175 return _device;
1176}
1177
1178void CLKernelLibrary::set_device(cl::Device device)
1179{
1180 _device = std::move(device);
1181}
1182
1183std::string CLKernelLibrary::get_kernel_path()
1184{
1185 return _kernel_path;
1186}
1187
1188void CLKernelLibrary::clear_programs_cache()
1189{
1190 _programs_map.clear();
1191 _built_programs_map.clear();
1192}
1193
1194const std::map<std::string, cl::Program> &CLKernelLibrary::get_built_programs() const
1195{
1196 return _built_programs_map;
1197}
1198
giuros0146a49a02019-04-01 13:50:22 +01001199void CLKernelLibrary::add_built_program(const std::string &built_program_name, const cl::Program &program)
Anthony Barbier7da55aa2018-04-13 16:58:43 +01001200{
1201 _built_programs_map.emplace(built_program_name, program);
1202}
1203
Vidhya Sudhan Loganathanf1f49062018-05-25 13:21:26 +01001204bool CLKernelLibrary::fp16_supported() const
1205{
1206 return ::fp16_supported(_device);
1207}
1208
Vidhya Sudhan Loganathan76c85642018-05-25 13:53:02 +01001209bool CLKernelLibrary::int64_base_atomics_supported() const
1210{
1211 return device_supports_extension(_device, "cl_khr_int64_base_atomics");
1212}
1213
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001214const Program &CLKernelLibrary::load_program(const std::string &program_name) const
1215{
1216 const auto program_it = _programs_map.find(program_name);
1217
1218 if(program_it != _programs_map.end())
1219 {
1220 return program_it->second;
1221 }
1222
1223 Program program;
1224
1225#ifdef EMBEDDED_KERNELS
1226 const auto program_source_it = _program_source_map.find(program_name);
1227
1228 if(_program_source_map.end() == program_source_it)
1229 {
Michalis Spyrou7c60c992019-10-10 14:33:47 +01001230 ARM_COMPUTE_ERROR_VAR("Embedded program for %s does not exist.", program_name.c_str());
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001231 }
1232
1233 program = Program(_context, program_name, program_source_it->second);
Anthony Barbierac69aa12017-07-03 17:39:37 +01001234#else /* EMBEDDED_KERNELS */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001235 // Check for binary
1236 std::string source_name = _kernel_path + program_name;
1237 std::string binary_name = source_name + "bin";
1238
1239 if(std::ifstream(binary_name).is_open())
1240 {
1241 const std::string program_binary = read_file(binary_name, true);
1242 program = Program(_context, _device, program_name, std::vector<unsigned char>(program_binary.begin(), program_binary.end()));
1243 }
1244 else if(std::ifstream(source_name).is_open())
1245 {
1246 program = Program(_context, program_name, read_file(source_name, false));
1247 }
1248 else
1249 {
Michalis Spyrou7c60c992019-10-10 14:33:47 +01001250 ARM_COMPUTE_ERROR_VAR("Kernel file %s does not exist.", source_name.c_str());
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001251 }
Anthony Barbierac69aa12017-07-03 17:39:37 +01001252#endif /* EMBEDDED_KERNELS */
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001253
1254 // Insert program to program map
1255 const auto new_program = _programs_map.emplace(program_name, std::move(program));
1256
1257 return new_program.first->second;
1258}
1259
Pablo Tellodb8485a2019-09-24 11:03:47 +01001260void CLKernelLibrary::set_context(cl::Context context)
1261{
1262 _context = std::move(context);
1263 if(_context.get() == nullptr)
1264 {
1265 _device = cl::Device();
1266 }
1267 else
1268 {
1269 const auto cl_devices = _context.getInfo<CL_CONTEXT_DEVICES>();
1270
1271 if(cl_devices.empty())
1272 {
1273 _device = cl::Device();
1274 }
1275 else
1276 {
1277 _device = cl_devices[0];
1278 }
1279 }
1280}
1281
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001282std::string CLKernelLibrary::stringify_set(const StringSet &s) const
1283{
steniu0134702472017-07-11 09:22:58 +01001284 std::string concat_set;
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001285
1286#ifndef EMBEDDED_KERNELS
1287 concat_set += "-I" + _kernel_path + " ";
1288#endif /* EMBEDDED_KERNELS */
1289
1290 // Concatenate set
1291 for(const auto &el : s)
1292 {
1293 concat_set += " " + el;
1294 }
1295
1296 return concat_set;
1297}
Michalis Spyroud7e82812017-06-20 15:00:14 +01001298
1299std::string CLKernelLibrary::get_program_source(const std::string &program_name)
1300{
1301 const auto program_source_it = _program_source_map.find(program_name);
1302
1303 if(program_source_it == _program_source_map.end())
1304 {
Michalis Spyrou7c60c992019-10-10 14:33:47 +01001305 ARM_COMPUTE_ERROR_VAR("Embedded program for %s does not exist.", program_name.c_str());
Michalis Spyroud7e82812017-06-20 15:00:14 +01001306 }
1307
1308 return program_source_it->second;
1309}
steniu015f910722017-08-23 10:15:22 +01001310
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001311size_t CLKernelLibrary::max_local_workgroup_size(const cl::Kernel &kernel) const
steniu015f910722017-08-23 10:15:22 +01001312{
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001313 size_t result;
steniu015f910722017-08-23 10:15:22 +01001314
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001315 size_t err = kernel.getWorkGroupInfo(_device, CL_KERNEL_WORK_GROUP_SIZE, &result);
1316 ARM_COMPUTE_ERROR_ON_MSG(err != 0, "clGetKernelWorkGroupInfo failed to return the maximum workgroup size for the kernel");
1317 ARM_COMPUTE_UNUSED(err);
1318
1319 return result;
steniu015f910722017-08-23 10:15:22 +01001320}
1321
Abel Bernabeu5a6e0532017-09-28 09:53:45 +01001322cl::NDRange CLKernelLibrary::default_ndrange() const
steniu015f910722017-08-23 10:15:22 +01001323{
Anthony Barbierb6eb3532018-08-08 13:20:04 +01001324 GPUTarget _target = get_target_from_device(_device);
Michalis Spyroua9676112018-02-22 18:07:43 +00001325 cl::NDRange default_range;
1326
1327 switch(_target)
1328 {
1329 case GPUTarget::MIDGARD:
1330 case GPUTarget::T600:
1331 case GPUTarget::T700:
1332 case GPUTarget::T800:
1333 default_range = cl::NDRange(128u, 1);
1334 break;
1335 default:
1336 default_range = cl::NullRange;
1337 }
1338
1339 return default_range;
steniu015f910722017-08-23 10:15:22 +01001340}
Anthony Barbier847864d2018-03-07 11:35:53 +00001341
1342std::string CLKernelLibrary::get_device_version()
1343{
1344 return _device.getInfo<CL_DEVICE_VERSION>();
1345}
Giorgio Arena5d42b462019-07-26 15:54:20 +01001346
1347cl_uint CLKernelLibrary::get_num_compute_units()
1348{
1349 return _device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>();
Michele Di Giorgio578a9fc2019-08-23 11:49:04 +01001350}