Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | 5237e01 | 2018-01-17 09:40:27 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2018 ARM Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 3 | * |
| 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 | |
steniu01 | 3470247 | 2017-07-11 09:22:58 +0100 | [diff] [blame] | 26 | #include "arm_compute/core/CL/CLHelpers.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/Error.h" |
| 28 | #include "arm_compute/core/Utils.h" |
| 29 | |
steniu01 | 5f91072 | 2017-08-23 10:15:22 +0100 | [diff] [blame] | 30 | #include <algorithm> |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 31 | #include <fstream> |
| 32 | #include <iostream> |
| 33 | #include <utility> |
| 34 | #include <vector> |
| 35 | |
| 36 | using namespace arm_compute; |
| 37 | |
Georgios Pinitas | 388d3ec | 2017-11-02 12:17:56 +0000 | [diff] [blame] | 38 | CLBuildOptions::CLBuildOptions() |
| 39 | : _build_opts() |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | void CLBuildOptions::add_option(std::string option) |
| 44 | { |
| 45 | _build_opts.emplace(std::move(option)); |
| 46 | } |
| 47 | |
| 48 | void CLBuildOptions::add_option_if(bool cond, std::string option) |
| 49 | { |
| 50 | if(cond) |
| 51 | { |
| 52 | add_option(std::move(option)); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | void 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 | |
Chunosov | f450caa | 2017-11-08 16:09:35 +0700 | [diff] [blame] | 61 | void CLBuildOptions::add_options(const StringSet &options) |
| 62 | { |
| 63 | _build_opts.insert(options.begin(), options.end()); |
| 64 | } |
| 65 | |
| 66 | void CLBuildOptions::add_options_if(bool cond, const StringSet &options) |
| 67 | { |
| 68 | if(cond) |
| 69 | { |
| 70 | add_options(options); |
| 71 | } |
| 72 | } |
| 73 | |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 74 | const CLBuildOptions::StringSet &CLBuildOptions::options() const |
Georgios Pinitas | 388d3ec | 2017-11-02 12:17:56 +0000 | [diff] [blame] | 75 | { |
| 76 | return _build_opts; |
| 77 | } |
| 78 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 79 | Program::Program() |
| 80 | : _context(), _device(), _is_binary(false), _name(), _source(), _binary() |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | Program::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 | |
| 89 | Program::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 | |
| 94 | Program::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 | |
| 106 | bool 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 | |
| 126 | cl::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 | |
| 133 | Kernel::Kernel() |
| 134 | : _name(), _kernel() |
| 135 | { |
| 136 | } |
| 137 | |
| 138 | Kernel::Kernel(std::string name, const cl::Program &program) |
| 139 | : _name(std::move(name)), |
| 140 | _kernel(cl::Kernel(program, _name.c_str())) |
| 141 | { |
| 142 | } |
| 143 | |
| 144 | const 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" }, |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 151 | { "activation_layer_qa8", "activation_layer_qa8.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 152 | { "arithmetic_add", "arithmetic_op.cl" }, |
| 153 | { "arithmetic_sub", "arithmetic_op.cl" }, |
Michalis Spyrou | 0a88792 | 2018-06-11 16:30:23 +0100 | [diff] [blame] | 154 | { "arithmetic_div", "arithmetic_op.cl" }, |
Michele Di Giorgio | bf3c662 | 2018-03-08 11:52:27 +0000 | [diff] [blame] | 155 | { "batchnormalization_layer_nchw", "batchnormalization_layer.cl" }, |
| 156 | { "batchnormalization_layer_nhwc", "batchnormalization_layer.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 157 | { "bitwise_or", "bitwise_op.cl" }, |
| 158 | { "bitwise_and", "bitwise_op.cl" }, |
| 159 | { "bitwise_xor", "bitwise_op.cl" }, |
| 160 | { "bitwise_not", "bitwise_op.cl" }, |
| 161 | { "channel_combine_NV", "channel_combine.cl" }, |
| 162 | { "channel_combine_RGB888", "channel_combine.cl" }, |
| 163 | { "channel_combine_RGBA8888", "channel_combine.cl" }, |
| 164 | { "channel_combine_UYVY422", "channel_combine.cl" }, |
| 165 | { "channel_combine_YUYV422", "channel_combine.cl" }, |
Michele Di Giorgio | 7217563 | 2018-05-01 16:52:00 +0100 | [diff] [blame] | 166 | { "channel_shuffle_nchw", "channel_shuffle.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 167 | { "channel_extract_NV12", "channel_extract.cl" }, |
| 168 | { "channel_extract_NV21", "channel_extract.cl" }, |
| 169 | { "channel_extract_RGB888", "channel_extract.cl" }, |
| 170 | { "channel_extract_RGBA8888", "channel_extract.cl" }, |
| 171 | { "channel_extract_UYVY422", "channel_extract.cl" }, |
| 172 | { "channel_extract_YUYV422", "channel_extract.cl" }, |
| 173 | { "combine_gradients_L1", "canny.cl" }, |
| 174 | { "combine_gradients_L2", "canny.cl" }, |
| 175 | { "concatenate_depth", "concatenate.cl" }, |
Michalis Spyrou | 55b3d12 | 2018-05-09 09:59:23 +0100 | [diff] [blame] | 176 | { "concatenate_width", "concatenate.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 177 | { "convolution_rectangle", "convolution_rectangle.cl" }, |
Gian Marco | 76faef8 | 2018-01-29 12:15:32 +0000 | [diff] [blame] | 178 | { "col2im", "col2im.cl" }, |
Giorgio Arena | 657bdb3 | 2018-04-26 18:52:01 +0100 | [diff] [blame] | 179 | { "convert_depth_down", "depth_convert.cl" }, |
| 180 | { "convert_depth_up", "depth_convert.cl" }, |
| 181 | { "convert_fc_weights", "convert_fc_weights.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 182 | { "convolution3x3_static", "convolution3x3.cl" }, |
| 183 | { "convolution5x5_static", "convolution5x5.cl" }, |
| 184 | { "convolution7x7_static", "convolution7x7.cl" }, |
| 185 | { "convolution9x9_static", "convolution9x9.cl" }, |
| 186 | { "convolution_separable1x5_static", "convolution5x5.cl" }, |
| 187 | { "convolution_separable5x1_static", "convolution5x5.cl" }, |
| 188 | { "convolution_separable1x7_static", "convolution7x7.cl" }, |
| 189 | { "convolution_separable7x1_static", "convolution7x7.cl" }, |
| 190 | { "convolution_separable1x9_static", "convolution9x9.cl" }, |
| 191 | { "convolution_separable9x1_static", "convolution9x9.cl" }, |
Michalis Spyrou | 5c8e05c | 2018-03-22 11:56:01 +0000 | [diff] [blame] | 192 | { "copy_tensor", "copy_tensor.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 193 | { "copy_plane", "channel_extract.cl" }, |
| 194 | { "copy_planes_3p", "channel_combine.cl" }, |
| 195 | { "copy_to_keypoint", "fast_corners.cl" }, |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 196 | { "deconvolution_upsample", "deconvolution_layer.cl" }, |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 197 | { "depthwise_convolution_3x3", "depthwise_convolution.cl" }, |
Michele Di Giorgio | 933fe86 | 2018-02-19 15:42:12 +0000 | [diff] [blame] | 198 | { "depthwise_convolution_3x3_f16", "depthwise_convolution.cl" }, |
Giorgio Arena | dfca60b | 2018-01-31 10:30:59 +0000 | [diff] [blame] | 199 | { "depthwise_convolution_3x3_quantized_nchw", "depthwise_convolution_quantized.cl" }, |
| 200 | { "depthwise_convolution_3x3_quantized_nhwc_stride1", "depthwise_convolution_quantized.cl" }, |
| 201 | { "depthwise_convolution_3x3_quantized_nhwc_stride2", "depthwise_convolution_quantized.cl" }, |
Michele Di Giorgio | 3ebef32 | 2018-02-21 10:02:58 +0000 | [diff] [blame] | 202 | { "depthwise_convolution_3x3_stridex1_stridey1_bifrost_f16", "depthwise_convolution.cl" }, |
| 203 | { "depthwise_convolution_3x3_stridex2_stridey2_bifrost_f16", "depthwise_convolution.cl" }, |
| 204 | { "depthwise_convolution_3x3_stridex1_stridey1_bifrost_f32", "depthwise_convolution.cl" }, |
| 205 | { "depthwise_convolution_3x3_stridex2_stridey2_bifrost_f32", "depthwise_convolution.cl" }, |
Giorgio Arena | 9fe4144 | 2017-08-23 16:36:24 +0100 | [diff] [blame] | 206 | { "depthwise_im2col", "depthwise_convolution.cl" }, |
| 207 | { "depthwise_vector_to_tensor", "depthwise_convolution.cl" }, |
| 208 | { "depthwise_weights_reshape", "depthwise_convolution.cl" }, |
Michele Di Giorgio | 56dd726 | 2017-07-27 09:53:49 +0100 | [diff] [blame] | 209 | { "dequantization_layer", "dequantization_layer.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 210 | { "derivative", "derivative.cl" }, |
| 211 | { "dilate", "dilate.cl" }, |
SiCong Li | c51b72f | 2017-07-28 14:46:20 +0100 | [diff] [blame] | 212 | { "direct_convolution1x1", "direct_convolution1x1.cl" }, |
Gian Marco Iodice | 1c8409d | 2017-09-06 17:24:25 +0100 | [diff] [blame] | 213 | { "direct_convolution1x1_f32_bifrost", "direct_convolution1x1.cl" }, |
SiCong Li | c51b72f | 2017-07-28 14:46:20 +0100 | [diff] [blame] | 214 | { "direct_convolution3x3", "direct_convolution3x3.cl" }, |
Gian Marco Iodice | 1246b63 | 2017-08-16 18:38:32 +0100 | [diff] [blame] | 215 | { "direct_convolution3x3_f32_bifrost", "direct_convolution3x3.cl" }, |
steniu01 | db00668 | 2017-08-09 16:26:22 +0100 | [diff] [blame] | 216 | { "direct_convolution5x5", "direct_convolution5x5.cl" }, |
Gian Marco Iodice | 1246b63 | 2017-08-16 18:38:32 +0100 | [diff] [blame] | 217 | { "direct_convolution5x5_f32_bifrost", "direct_convolution5x5.cl" }, |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 218 | { "direct_convolution_1x1_3x3_5x5_quantized", "direct_convolution_1x1_3x3_5x5_quantized.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 219 | { "erode", "erode.cl" }, |
| 220 | { "fast_corners", "fast_corners.cl" }, |
| 221 | { "fill_image_borders_constant", "fill_border.cl" }, |
| 222 | { "fill_image_borders_replicate", "fill_border.cl" }, |
| 223 | { "finalize", "optical_flow_pyramid_lk.cl" }, |
Georgios Pinitas | d8e765b | 2017-08-02 13:44:33 +0100 | [diff] [blame] | 224 | { "floor_layer", "floor.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 225 | { "gaussian1x5_sub_x", "gaussian_pyramid.cl" }, |
| 226 | { "gaussian5x1_sub_y", "gaussian_pyramid.cl" }, |
Gian Marco Iodice | 578ab61 | 2017-06-23 09:34:33 +0100 | [diff] [blame] | 227 | { "gemm_accumulate_biases", "gemm.cl" }, |
Gian Marco | 36a0a46 | 2018-01-12 10:21:40 +0000 | [diff] [blame] | 228 | { "gemm_interleave4x4", "gemm.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 229 | { "gemm_ma_f16", "gemm.cl" }, |
| 230 | { "gemm_ma_f32", "gemm.cl" }, |
Gian Marco Iodice | 3a3066b | 2017-06-23 13:38:14 +0100 | [diff] [blame] | 231 | { "gemm_ma_qs8", "gemm.cl" }, |
Gian Marco Iodice | 8a38369 | 2017-07-03 17:41:47 +0100 | [diff] [blame] | 232 | { "gemm_ma_qs16", "gemm.cl" }, |
Giorgio Arena | 9fe4144 | 2017-08-23 16:36:24 +0100 | [diff] [blame] | 233 | { "gemm_mv", "gemv.cl" }, |
Georgios Pinitas | de5a1cc | 2018-02-02 12:52:07 +0000 | [diff] [blame] | 234 | { "gemm_mv_quantized", "gemv.cl" }, |
Gian Marco Iodice | edfa9f4 | 2017-08-15 11:45:22 +0100 | [diff] [blame] | 235 | { "gemm_mm_interleaved_transposed_f16", "gemm.cl" }, |
Gian Marco Iodice | bb36a8e | 2018-04-19 12:05:08 +0100 | [diff] [blame] | 236 | { "gemm_mm_interleaved_transposed_f16_bifrost", "gemm.cl" }, |
| 237 | { "gemm_mm_interleaved_transposed_f32", "gemm.cl" }, |
Gian Marco Iodice | edfa9f4 | 2017-08-15 11:45:22 +0100 | [diff] [blame] | 238 | { "gemm_mm_interleaved_transposed_f32_bifrost", "gemm.cl" }, |
| 239 | { "gemm_mm_interleaved_transposed_qs8", "gemm.cl" }, |
| 240 | { "gemm_mm_interleaved_transposed_qs16", "gemm.cl" }, |
| 241 | { "gemm_mm_floating_point", "gemm.cl" }, |
Gian Marco Iodice | fd68311 | 2018-04-17 09:52:44 +0100 | [diff] [blame] | 242 | { "gemm_mm_floating_point_f16_bifrost", "gemm.cl" }, |
Anton Lokhmotov | 3e80c7f | 2017-11-20 11:02:10 +0000 | [diff] [blame] | 243 | { "gemm_mm_floating_point_f32_bifrost", "gemm.cl" }, |
| 244 | { "gemm_mm_floating_point_f32_bifrost_1000", "gemm.cl" }, |
Gian Marco Iodice | 3a3066b | 2017-06-23 13:38:14 +0100 | [diff] [blame] | 245 | { "gemm_mm_qs8", "gemm.cl" }, |
Gian Marco Iodice | 8a38369 | 2017-07-03 17:41:47 +0100 | [diff] [blame] | 246 | { "gemm_mm_qs16", "gemm.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 247 | { "gemm_lc_vm_f32", "gemm.cl" }, |
Gian Marco | 36a0a46 | 2018-01-12 10:21:40 +0000 | [diff] [blame] | 248 | { "gemm_transpose1xW", "gemm.cl" }, |
Gian Marco | 05288a2 | 2017-11-21 10:57:50 +0000 | [diff] [blame] | 249 | { "gemmlowp_matrix_a_reduction", "gemmlowp.cl" }, |
| 250 | { "gemmlowp_matrix_b_reduction", "gemmlowp.cl" }, |
Gian Marco | 7b4d547 | 2018-01-10 15:56:30 +0000 | [diff] [blame] | 251 | { "gemmlowp_mm_bifrost", "gemmlowp.cl" }, |
| 252 | { "gemmlowp_mm_midgard", "gemmlowp.cl" }, |
Gian Marco | 19835e5 | 2018-01-30 13:35:54 +0000 | [diff] [blame] | 253 | { "gemmlowp_mm_interleaved_transposed_bifrost", "gemmlowp.cl" }, |
| 254 | { "gemmlowp_mm_interleaved_transposed_midgard", "gemmlowp.cl" }, |
Gian Marco | 05288a2 | 2017-11-21 10:57:50 +0000 | [diff] [blame] | 255 | { "gemmlowp_offset_contribution", "gemmlowp.cl" }, |
| 256 | { "gemmlowp_output_stage_quantize_down", "gemmlowp.cl" }, |
Gian Marco | 58c5794 | 2017-11-28 09:10:03 +0000 | [diff] [blame] | 257 | { "gemmlowp_output_stage_quantize_down_fixedpoint", "gemmlowp.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 258 | { "harris_score_3x3", "harris_corners.cl" }, |
| 259 | { "harris_score_5x5", "harris_corners.cl" }, |
| 260 | { "harris_score_7x7", "harris_corners.cl" }, |
| 261 | { "hist_border_kernel", "histogram.cl" }, |
| 262 | { "hist_border_kernel_fixed", "histogram.cl" }, |
| 263 | { "hist_local_kernel", "histogram.cl" }, |
| 264 | { "hist_local_kernel_fixed", "histogram.cl" }, |
| 265 | { "hog_block_normalization", "hog.cl" }, |
| 266 | { "hog_detector", "hog.cl" }, |
| 267 | { "hog_orientation_binning", "hog.cl" }, |
| 268 | { "hysteresis", "canny.cl" }, |
Gian Marco | 76faef8 | 2018-01-29 12:15:32 +0000 | [diff] [blame] | 269 | { "im2col1x1_stridex1_dchw", "im2col.cl" }, |
| 270 | { "im2col3x3_dchw", "im2col.cl" }, |
| 271 | { "im2col5x5_dchw", "im2col.cl" }, |
| 272 | { "im2col11x11_padx0_pady0_dchw", "im2col.cl" }, |
| 273 | { "im2col_generic_dchw", "im2col.cl" }, |
| 274 | { "im2col_generic_padx0_pady0_dchw", "im2col.cl" }, |
| 275 | { "im2col_reduced_dchw", "im2col.cl" }, |
Pablo Tello | 4a626a7 | 2018-04-04 10:01:14 +0100 | [diff] [blame] | 276 | { "im2col3x3_nhwc", "im2col.cl" }, |
| 277 | { "im2col_generic_nhwc", "im2col.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 278 | { "init_level", "optical_flow_pyramid_lk.cl" }, |
| 279 | { "init_level_max", "optical_flow_pyramid_lk.cl" }, |
| 280 | { "init_level_max_initial_estimate", "optical_flow_pyramid_lk.cl" }, |
| 281 | { "integral_horizontal", "integral_image.cl" }, |
| 282 | { "integral_vertical", "integral_image.cl" }, |
| 283 | { "IYUV_to_NV12_bt709", "color_convert.cl" }, |
| 284 | { "IYUV_to_RGB888_bt709", "color_convert.cl" }, |
| 285 | { "IYUV_to_RGBA8888_bt709", "color_convert.cl" }, |
| 286 | { "IYUV_to_YUV444_bt709", "color_convert.cl" }, |
Michalis Spyrou | 04f089c | 2017-08-08 17:42:38 +0100 | [diff] [blame] | 287 | { "l2_normalize", "l2_normalize.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 288 | { "lktracker_stage0", "optical_flow_pyramid_lk.cl" }, |
| 289 | { "lktracker_stage1", "optical_flow_pyramid_lk.cl" }, |
| 290 | { "magnitude_phase", "magnitude_phase.cl" }, |
| 291 | { "mean_stddev_accumulate", "mean_stddev.cl" }, |
| 292 | { "minmax", "minmaxloc.cl" }, |
| 293 | { "minmax_border", "minmaxloc.cl" }, |
Michele Di Giorgio | 56dd726 | 2017-07-27 09:53:49 +0100 | [diff] [blame] | 294 | { "minmax_layer", "minmax_layer.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 295 | { "minmaxloc", "minmaxloc.cl" }, |
| 296 | { "non_linear_filter_box3x3", "non_linear_filter3x3.cl" }, |
| 297 | { "non_linear_filter_cross3x3", "non_linear_filter3x3.cl" }, |
| 298 | { "non_linear_filter_disk3x3", "non_linear_filter3x3.cl" }, |
| 299 | { "non_linear_filter_box5x5", "non_linear_filter5x5.cl" }, |
| 300 | { "non_linear_filter_cross5x5", "non_linear_filter5x5.cl" }, |
| 301 | { "non_linear_filter_disk5x5", "non_linear_filter5x5.cl" }, |
| 302 | { "non_max_suppression", "nonmax.cl" }, |
| 303 | { "normalization_layer_cross_map", "normalization_layer.cl" }, |
Georgios Pinitas | 0162436 | 2017-11-30 10:53:31 +0000 | [diff] [blame] | 304 | { "normalization_layer_in_map", "normalization_layer.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 305 | { "NV12_to_IYUV_bt709", "color_convert.cl" }, |
| 306 | { "NV12_to_RGB888_bt709", "color_convert.cl" }, |
| 307 | { "NV12_to_RGBA8888_bt709", "color_convert.cl" }, |
| 308 | { "NV12_to_YUV444_bt709", "color_convert.cl" }, |
| 309 | { "NV21_to_IYUV_bt709", "color_convert.cl" }, |
| 310 | { "NV21_to_RGB888_bt709", "color_convert.cl" }, |
| 311 | { "NV21_to_RGBA8888_bt709", "color_convert.cl" }, |
| 312 | { "NV21_to_YUV444_bt709", "color_convert.cl" }, |
Giorgio Arena | a086a0a | 2018-02-16 12:42:16 +0000 | [diff] [blame] | 313 | { "output_stage_quantized", "direct_convolution_1x1_3x3_5x5_quantized.cl" }, |
Michalis Spyrou | 5237e01 | 2018-01-17 09:40:27 +0000 | [diff] [blame] | 314 | { "permute_201", "permute.cl" }, |
| 315 | { "permute_120", "permute.cl" }, |
| 316 | { "permute_3201", "permute.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 317 | { "pixelwise_mul_float", "pixelwise_mul_float.cl" }, |
| 318 | { "pixelwise_mul_int", "pixelwise_mul_int.cl" }, |
| 319 | { "pooling_layer_2", "pooling_layer.cl" }, |
| 320 | { "pooling_layer_3", "pooling_layer.cl" }, |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 321 | { "pooling_layer_optimized_3", "pooling_layer.cl" }, |
Georgios Pinitas | ce09314 | 2017-06-19 16:11:53 +0100 | [diff] [blame] | 322 | { "pooling_layer_7", "pooling_layer.cl" }, |
Michalis Spyrou | e74b201 | 2018-04-18 09:49:16 +0100 | [diff] [blame] | 323 | { "pooling_layer_MxN_nchw", "pooling_layer.cl" }, |
| 324 | { "pooling_layer_MxN_nhwc", "pooling_layer.cl" }, |
| 325 | { "pooling_layer_MxN_quantized_nhwc", "pooling_layer_quantized.cl" }, |
| 326 | { "pooling_layer_MxN_quantized_nchw", "pooling_layer_quantized.cl" }, |
Michele Di Giorgio | 56dd726 | 2017-07-27 09:53:49 +0100 | [diff] [blame] | 327 | { "quantization_layer", "quantization_layer.cl" }, |
Michalis Spyrou | 04f089c | 2017-08-08 17:42:38 +0100 | [diff] [blame] | 328 | { "reduction_operation", "reduction_operation.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 329 | { "remap_nearest_neighbour", "remap.cl" }, |
| 330 | { "remap_bilinear", "remap.cl" }, |
Georgios Pinitas | 5ee66ea | 2017-09-07 17:29:16 +0100 | [diff] [blame] | 331 | { "reshape_layer", "reshape_layer.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 332 | { "reshape_to_columns", "convolution_layer.cl" }, |
| 333 | { "RGB888_to_IYUV_bt709", "color_convert.cl" }, |
| 334 | { "RGB888_to_NV12_bt709", "color_convert.cl" }, |
| 335 | { "RGB888_to_RGBA8888_bt709", "color_convert.cl" }, |
| 336 | { "RGB888_to_YUV444_bt709", "color_convert.cl" }, |
| 337 | { "RGBA8888_to_IYUV_bt709", "color_convert.cl" }, |
| 338 | { "RGBA8888_to_NV12_bt709", "color_convert.cl" }, |
| 339 | { "RGBA8888_to_RGB888_bt709", "color_convert.cl" }, |
| 340 | { "RGBA8888_to_YUV444_bt709", "color_convert.cl" }, |
SiCong Li | 3e36369 | 2017-07-04 15:02:10 +0100 | [diff] [blame] | 341 | { "roi_pooling_layer", "roi_pooling_layer.cl" }, |
Michalis Spyrou | 46da23f | 2018-04-10 13:41:30 +0100 | [diff] [blame] | 342 | { "scale_nearest_neighbour_nchw", "scale.cl" }, |
| 343 | { "scale_nearest_neighbour_nhwc", "scale.cl" }, |
| 344 | { "scale_bilinear_nchw", "scale.cl" }, |
| 345 | { "scale_bilinear_nhwc", "scale.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 346 | { "scharr3x3", "scharr_filter.cl" }, |
| 347 | { "sobel3x3", "sobel_filter.cl" }, |
| 348 | { "sobel_separable5x1", "sobel_filter.cl" }, |
| 349 | { "sobel_separable1x5", "sobel_filter.cl" }, |
| 350 | { "sobel_separable7x1", "sobel_filter.cl" }, |
| 351 | { "sobel_separable1x7", "sobel_filter.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 352 | { "softmax_layer_norm", "softmax_layer.cl" }, |
Chunosov | f450caa | 2017-11-08 16:09:35 +0700 | [diff] [blame] | 353 | { "softmax_layer_norm_quantized", "softmax_layer_quantized.cl" }, |
Giorgio Arena | 4402cb9 | 2018-02-15 13:37:40 +0000 | [diff] [blame] | 354 | { "softmax_layer_max_shift_exp_sum_quantized_serial", "softmax_layer_quantized.cl" }, |
| 355 | { "softmax_layer_max_shift_exp_sum_quantized_parallel", "softmax_layer_quantized.cl" }, |
Chunosov | d6afedc | 2017-11-06 22:09:45 +0700 | [diff] [blame] | 356 | { "softmax_layer_max_shift_exp_sum_serial", "softmax_layer.cl" }, |
| 357 | { "softmax_layer_max_shift_exp_sum_parallel", "softmax_layer.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 358 | { "suppress_non_maximum", "canny.cl" }, |
| 359 | { "tablelookup_U8", "tablelookup.cl" }, |
| 360 | { "tablelookup_S16", "tablelookup.cl" }, |
| 361 | { "threshold_binary", "threshold.cl" }, |
| 362 | { "threshold_range", "threshold.cl" }, |
| 363 | { "transpose", "transpose.cl" }, |
| 364 | { "UYVY422_to_IYUV_bt709", "color_convert.cl" }, |
| 365 | { "UYVY422_to_NV12_bt709", "color_convert.cl" }, |
| 366 | { "UYVY422_to_RGB888_bt709", "color_convert.cl" }, |
| 367 | { "UYVY422_to_RGBA8888_bt709", "color_convert.cl" }, |
| 368 | { "warp_affine_nearest_neighbour", "warp_affine.cl" }, |
| 369 | { "warp_affine_bilinear", "warp_affine.cl" }, |
| 370 | { "warp_perspective_nearest_neighbour", "warp_perspective.cl" }, |
| 371 | { "warp_perspective_bilinear", "warp_perspective.cl" }, |
Gian Marco Iodice | 7e4b239 | 2018-02-22 16:17:20 +0000 | [diff] [blame] | 372 | { "winograd_filter_transform_2x2_3x3_nchw", "winograd.cl" }, |
Giorgio Arena | 2d9de0a | 2018-03-15 17:58:20 +0000 | [diff] [blame] | 373 | { "winograd_filter_transform_4x4_3x3_nchw", "winograd.cl" }, |
Giorgio Arena | 9373c8b | 2018-04-11 19:07:17 +0100 | [diff] [blame] | 374 | { "winograd_filter_transform_4x4_5x5_nchw", "winograd.cl" }, |
Giorgio Arena | dcb5b28 | 2018-04-25 12:07:29 +0100 | [diff] [blame] | 375 | { "winograd_filter_transform_4x4_3x3_nhwc", "winograd.cl" }, |
Giorgio Arena | fe5ef38 | 2018-04-17 10:14:10 +0100 | [diff] [blame] | 376 | { "winograd_input_transform_4x4_5x5_stepz1_nchw", "winograd.cl" }, |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 377 | { "winograd_input_transform_2x2_3x3_stepz1_nchw", "winograd.cl" }, |
| 378 | { "winograd_input_transform_2x2_3x3_stepz2_nchw", "winograd.cl" }, |
Gian Marco Iodice | e52a300 | 2018-04-11 15:59:10 +0100 | [diff] [blame] | 379 | { "winograd_input_transform_4x4_3x3_stepz1_nchw", "winograd.cl" }, |
Giorgio Arena | c42f28d | 2018-04-26 11:33:05 +0100 | [diff] [blame] | 380 | { "winograd_input_transform_4x4_3x3_stepz1_nhwc", "winograd.cl" }, |
Gian Marco Iodice | d2fab73 | 2018-03-02 11:18:12 +0000 | [diff] [blame] | 381 | { "winograd_output_transform_2x2_3x3_nchw", "winograd.cl" }, |
Gian Marco Iodice | e52a300 | 2018-04-11 15:59:10 +0100 | [diff] [blame] | 382 | { "winograd_output_transform_4x4_3x3_nchw", "winograd.cl" }, |
Giorgio Arena | dd03870 | 2018-04-16 11:20:11 +0100 | [diff] [blame] | 383 | { "winograd_output_transform_4x4_5x5_nchw", "winograd.cl" }, |
Giorgio Arena | 3695f9a | 2018-04-23 17:41:22 +0100 | [diff] [blame] | 384 | { "winograd_output_transform_4x4_3x3_nhwc", "winograd.cl" }, |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 385 | { "YUYV422_to_IYUV_bt709", "color_convert.cl" }, |
| 386 | { "YUYV422_to_NV12_bt709", "color_convert.cl" }, |
| 387 | { "YUYV422_to_RGB888_bt709", "color_convert.cl" }, |
| 388 | { "YUYV422_to_RGBA8888_bt709", "color_convert.cl" }, |
| 389 | }; |
| 390 | |
| 391 | const std::map<std::string, std::string> CLKernelLibrary::_program_source_map = |
| 392 | { |
| 393 | #ifdef EMBEDDED_KERNELS |
| 394 | { |
| 395 | "absdiff.cl", |
| 396 | #include "./cl_kernels/absdiff.clembed" |
| 397 | }, |
| 398 | { |
| 399 | "accumulate.cl", |
| 400 | #include "./cl_kernels/accumulate.clembed" |
| 401 | }, |
| 402 | { |
| 403 | "activation_layer.cl", |
| 404 | #include "./cl_kernels/activation_layer.clembed" |
| 405 | }, |
| 406 | { |
Michel Iwaniec | 0063380 | 2017-10-12 14:14:15 +0100 | [diff] [blame] | 407 | "activation_layer_qa8.cl", |
| 408 | #include "./cl_kernels/activation_layer_qa8.clembed" |
| 409 | }, |
| 410 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 411 | "arithmetic_op.cl", |
| 412 | #include "./cl_kernels/arithmetic_op.clembed" |
| 413 | }, |
| 414 | { |
| 415 | "bitwise_op.cl", |
| 416 | #include "./cl_kernels/bitwise_op.clembed" |
| 417 | }, |
| 418 | { |
| 419 | "canny.cl", |
| 420 | #include "./cl_kernels/canny.clembed" |
| 421 | }, |
| 422 | { |
| 423 | "channel_combine.cl", |
| 424 | #include "./cl_kernels/channel_combine.clembed" |
| 425 | }, |
| 426 | { |
| 427 | "channel_extract.cl", |
| 428 | #include "./cl_kernels/channel_extract.clembed" |
| 429 | }, |
| 430 | { |
Michele Di Giorgio | 7217563 | 2018-05-01 16:52:00 +0100 | [diff] [blame] | 431 | "channel_shuffle.cl", |
| 432 | #include "./cl_kernels/channel_shuffle.clembed" |
| 433 | }, |
| 434 | { |
Gian Marco | 76faef8 | 2018-01-29 12:15:32 +0000 | [diff] [blame] | 435 | "col2im.cl", |
| 436 | #include "./cl_kernels/col2im.clembed" |
| 437 | }, |
| 438 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 439 | "concatenate.cl", |
| 440 | #include "./cl_kernels/concatenate.clembed" |
| 441 | }, |
| 442 | { |
| 443 | "color_convert.cl", |
| 444 | #include "./cl_kernels/color_convert.clembed" |
| 445 | }, |
| 446 | { |
Giorgio Arena | 657bdb3 | 2018-04-26 18:52:01 +0100 | [diff] [blame] | 447 | "convert_fc_weights.cl", |
| 448 | #include "./cl_kernels/convert_fc_weights.clembed" |
| 449 | }, |
| 450 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 451 | "convolution3x3.cl", |
| 452 | #include "./cl_kernels/convolution3x3.clembed" |
| 453 | }, |
| 454 | { |
| 455 | "convolution5x5.cl", |
| 456 | #include "./cl_kernels/convolution5x5.clembed" |
| 457 | }, |
| 458 | { |
| 459 | "convolution7x7.cl", |
| 460 | #include "./cl_kernels/convolution7x7.clembed" |
| 461 | }, |
| 462 | { |
| 463 | "convolution9x9.cl", |
| 464 | #include "./cl_kernels/convolution9x9.clembed" |
| 465 | }, |
| 466 | { |
| 467 | "convolution_layer.cl", |
| 468 | #include "./cl_kernels/convolution_layer.clembed" |
| 469 | }, |
| 470 | { |
| 471 | "convolution_rectangle.cl", |
| 472 | #include "./cl_kernels/convolution_rectangle.clembed" |
| 473 | }, |
| 474 | { |
Michalis Spyrou | 5c8e05c | 2018-03-22 11:56:01 +0000 | [diff] [blame] | 475 | "copy_tensor.cl", |
| 476 | #include "./cl_kernels/copy_tensor.clembed" |
| 477 | }, |
| 478 | { |
Michalis Spyrou | 780db4e | 2017-11-23 09:49:51 +0000 | [diff] [blame] | 479 | "deconvolution_layer.cl", |
| 480 | #include "./cl_kernels/deconvolution_layer.clembed" |
| 481 | }, |
| 482 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 483 | "depth_convert.cl", |
| 484 | #include "./cl_kernels/depth_convert.clembed" |
| 485 | }, |
| 486 | { |
Giorgio Arena | 93a690e | 2017-08-01 16:09:33 +0100 | [diff] [blame] | 487 | "depthwise_convolution.cl", |
| 488 | #include "./cl_kernels/depthwise_convolution.clembed" |
| 489 | }, |
| 490 | { |
Dmitry Savenko | d7295b7 | 2017-11-20 22:00:08 +0700 | [diff] [blame] | 491 | "depthwise_convolution_quantized.cl", |
| 492 | #include "./cl_kernels/depthwise_convolution_quantized.clembed" |
| 493 | }, |
| 494 | { |
Michele Di Giorgio | 56dd726 | 2017-07-27 09:53:49 +0100 | [diff] [blame] | 495 | "dequantization_layer.cl", |
| 496 | #include "./cl_kernels/dequantization_layer.clembed" |
| 497 | }, |
| 498 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 499 | "derivative.cl", |
| 500 | #include "./cl_kernels/derivative.clembed" |
| 501 | }, |
| 502 | { |
| 503 | "dilate.cl", |
| 504 | #include "./cl_kernels/dilate.clembed" |
| 505 | }, |
| 506 | { |
SiCong Li | c51b72f | 2017-07-28 14:46:20 +0100 | [diff] [blame] | 507 | "direct_convolution1x1.cl", |
| 508 | #include "./cl_kernels/direct_convolution1x1.clembed" |
| 509 | }, |
| 510 | { |
| 511 | "direct_convolution3x3.cl", |
| 512 | #include "./cl_kernels/direct_convolution3x3.clembed" |
steniu01 | 27b386c | 2017-07-18 17:37:43 +0100 | [diff] [blame] | 513 | }, |
| 514 | { |
steniu01 | db00668 | 2017-08-09 16:26:22 +0100 | [diff] [blame] | 515 | "direct_convolution5x5.cl", |
| 516 | #include "./cl_kernels/direct_convolution5x5.clembed" |
| 517 | }, |
| 518 | { |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 519 | "direct_convolution_1x1_3x3_5x5_quantized.cl", |
| 520 | #include "./cl_kernels/direct_convolution_1x1_3x3_5x5_quantized.clembed" |
| 521 | }, |
| 522 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 523 | "erode.cl", |
| 524 | #include "./cl_kernels/erode.clembed" |
| 525 | }, |
| 526 | { |
| 527 | "fast_corners.cl", |
| 528 | #include "./cl_kernels/fast_corners.clembed" |
| 529 | }, |
| 530 | { |
| 531 | "fill_border.cl", |
| 532 | #include "./cl_kernels/fill_border.clembed" |
| 533 | }, |
| 534 | { |
Georgios Pinitas | e5f8fd6 | 2017-06-23 18:03:44 +0100 | [diff] [blame] | 535 | "fixed_point.h", |
| 536 | #include "./cl_kernels/fixed_point.hembed" |
| 537 | }, |
| 538 | { |
Georgios Pinitas | d8e765b | 2017-08-02 13:44:33 +0100 | [diff] [blame] | 539 | "floor.cl", |
| 540 | #include "./cl_kernels/floor.clembed" |
| 541 | }, |
| 542 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 543 | "gaussian_pyramid.cl", |
| 544 | #include "./cl_kernels/gaussian_pyramid.clembed" |
| 545 | }, |
| 546 | { |
| 547 | "gemm.cl", |
| 548 | #include "./cl_kernels/gemm.clembed" |
| 549 | }, |
| 550 | { |
Gian Marco | 05288a2 | 2017-11-21 10:57:50 +0000 | [diff] [blame] | 551 | "gemmlowp.cl", |
| 552 | #include "./cl_kernels/gemmlowp.clembed" |
| 553 | }, |
| 554 | { |
Giorgio Arena | 9fe4144 | 2017-08-23 16:36:24 +0100 | [diff] [blame] | 555 | "gemv.cl", |
| 556 | #include "./cl_kernels/gemv.clembed" |
| 557 | }, |
| 558 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 559 | "harris_corners.cl", |
| 560 | #include "./cl_kernels/harris_corners.clembed" |
| 561 | }, |
| 562 | { |
| 563 | "helpers.h", |
| 564 | #include "./cl_kernels/helpers.hembed" |
| 565 | }, |
| 566 | { |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 567 | "helpers_asymm.h", |
| 568 | #include "./cl_kernels/helpers_asymm.hembed" |
| 569 | }, |
| 570 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 571 | "histogram.cl", |
| 572 | #include "./cl_kernels/histogram.clembed" |
| 573 | }, |
| 574 | { |
| 575 | "hog.cl", |
| 576 | #include "./cl_kernels/hog.clembed" |
| 577 | }, |
| 578 | { |
Gian Marco | 76faef8 | 2018-01-29 12:15:32 +0000 | [diff] [blame] | 579 | "im2col.cl", |
| 580 | #include "./cl_kernels/im2col.clembed" |
| 581 | }, |
| 582 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 583 | "integral_image.cl", |
| 584 | #include "./cl_kernels/integral_image.clembed" |
| 585 | }, |
| 586 | { |
Michalis Spyrou | 04f089c | 2017-08-08 17:42:38 +0100 | [diff] [blame] | 587 | "l2_normalize.cl", |
| 588 | #include "./cl_kernels/l2_normalize.clembed" |
| 589 | }, |
| 590 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 591 | "magnitude_phase.cl", |
| 592 | #include "./cl_kernels/magnitude_phase.clembed" |
| 593 | }, |
| 594 | { |
| 595 | "mean_stddev.cl", |
| 596 | #include "./cl_kernels/mean_stddev.clembed" |
| 597 | }, |
| 598 | { |
| 599 | "minmaxloc.cl", |
| 600 | #include "./cl_kernels/minmaxloc.clembed" |
| 601 | }, |
| 602 | { |
Michele Di Giorgio | 56dd726 | 2017-07-27 09:53:49 +0100 | [diff] [blame] | 603 | "minmax_layer.cl", |
| 604 | #include "./cl_kernels/minmax_layer.clembed" |
| 605 | }, |
| 606 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 607 | "non_linear_filter3x3.cl", |
| 608 | #include "./cl_kernels/non_linear_filter3x3.clembed" |
| 609 | }, |
| 610 | { |
| 611 | "non_linear_filter5x5.cl", |
| 612 | #include "./cl_kernels/non_linear_filter5x5.clembed" |
| 613 | }, |
| 614 | { |
| 615 | "non_linear_filter_helpers.h", |
| 616 | #include "./cl_kernels/non_linear_filter_helpers.hembed" |
| 617 | }, |
| 618 | { |
| 619 | "nonmax.cl", |
| 620 | #include "./cl_kernels/nonmax.clembed" |
| 621 | }, |
| 622 | { |
| 623 | "normalization_layer.cl", |
| 624 | #include "./cl_kernels/normalization_layer.clembed" |
| 625 | }, |
| 626 | { |
| 627 | "batchnormalization_layer.cl", |
| 628 | #include "./cl_kernels/batchnormalization_layer.clembed" |
| 629 | }, |
| 630 | { |
| 631 | "optical_flow_pyramid_lk.cl", |
| 632 | #include "./cl_kernels/optical_flow_pyramid_lk.clembed" |
| 633 | }, |
| 634 | { |
Michalis Spyrou | 5237e01 | 2018-01-17 09:40:27 +0000 | [diff] [blame] | 635 | "permute.cl", |
| 636 | #include "./cl_kernels/permute.clembed" |
| 637 | }, |
| 638 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 639 | "pixelwise_mul_float.cl", |
| 640 | #include "./cl_kernels/pixelwise_mul_float.clembed" |
| 641 | }, |
| 642 | { |
| 643 | "pixelwise_mul_int.cl", |
| 644 | #include "./cl_kernels/pixelwise_mul_int.clembed" |
| 645 | }, |
| 646 | { |
| 647 | "pooling_layer.cl", |
| 648 | #include "./cl_kernels/pooling_layer.clembed" |
| 649 | }, |
| 650 | { |
Anton Lokhmotov | af6204c | 2017-11-08 09:34:19 +0000 | [diff] [blame] | 651 | "pooling_layer_quantized.cl", |
| 652 | #include "./cl_kernels/pooling_layer_quantized.clembed" |
| 653 | }, |
| 654 | { |
Michele Di Giorgio | 56dd726 | 2017-07-27 09:53:49 +0100 | [diff] [blame] | 655 | "quantization_layer.cl", |
| 656 | #include "./cl_kernels/quantization_layer.clembed" |
| 657 | }, |
| 658 | { |
Michalis Spyrou | 04f089c | 2017-08-08 17:42:38 +0100 | [diff] [blame] | 659 | "reduction_operation.cl", |
| 660 | #include "./cl_kernels/reduction_operation.clembed" |
| 661 | }, |
| 662 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 663 | "remap.cl", |
| 664 | #include "./cl_kernels/remap.clembed" |
| 665 | }, |
| 666 | { |
Georgios Pinitas | 5ee66ea | 2017-09-07 17:29:16 +0100 | [diff] [blame] | 667 | "reshape_layer.cl", |
| 668 | #include "./cl_kernels/reshape_layer.clembed" |
| 669 | }, |
| 670 | { |
SiCong Li | 3e36369 | 2017-07-04 15:02:10 +0100 | [diff] [blame] | 671 | "roi_pooling_layer.cl", |
| 672 | #include "./cl_kernels/roi_pooling_layer.clembed" |
| 673 | }, |
| 674 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 675 | "scale.cl", |
| 676 | #include "./cl_kernels/scale.clembed" |
| 677 | }, |
| 678 | { |
| 679 | "scharr_filter.cl", |
| 680 | #include "./cl_kernels/scharr_filter.clembed" |
| 681 | }, |
| 682 | { |
| 683 | "sobel_filter.cl", |
| 684 | #include "./cl_kernels/sobel_filter.clembed" |
| 685 | }, |
| 686 | { |
| 687 | "softmax_layer.cl", |
| 688 | #include "./cl_kernels/softmax_layer.clembed" |
| 689 | }, |
| 690 | { |
Chunosov | f450caa | 2017-11-08 16:09:35 +0700 | [diff] [blame] | 691 | "softmax_layer_quantized.cl", |
| 692 | #include "./cl_kernels/softmax_layer_quantized.clembed" |
| 693 | }, |
| 694 | { |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 695 | "tablelookup.cl", |
| 696 | #include "./cl_kernels/tablelookup.clembed" |
| 697 | }, |
| 698 | { |
| 699 | "threshold.cl", |
| 700 | #include "./cl_kernels/threshold.clembed" |
| 701 | }, |
| 702 | { |
| 703 | "transpose.cl", |
| 704 | #include "./cl_kernels/transpose.clembed" |
| 705 | }, |
| 706 | { |
| 707 | "types.h", |
| 708 | #include "./cl_kernels/types.hembed" |
| 709 | }, |
| 710 | { |
| 711 | "warp_affine.cl", |
| 712 | #include "./cl_kernels/warp_affine.clembed" |
| 713 | }, |
| 714 | { |
| 715 | "warp_helpers.h", |
| 716 | #include "./cl_kernels/warp_helpers.hembed" |
| 717 | }, |
| 718 | { |
| 719 | "warp_perspective.cl", |
| 720 | #include "./cl_kernels/warp_perspective.clembed" |
Michalis Spyrou | d7e8281 | 2017-06-20 15:00:14 +0100 | [diff] [blame] | 721 | }, |
Giorgio Arena | 1f9ca1d | 2018-03-01 11:13:45 +0000 | [diff] [blame] | 722 | { |
| 723 | "winograd.cl", |
| 724 | #include "./cl_kernels/winograd.clembed" |
| 725 | }, |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 726 | #endif /* EMBEDDED_KERNELS */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 727 | }; |
| 728 | |
| 729 | CLKernelLibrary::CLKernelLibrary() |
Abel Bernabeu | 5a6e053 | 2017-09-28 09:53:45 +0100 | [diff] [blame] | 730 | : _context(), _device(), _kernel_path("."), _programs_map(), _built_programs_map() |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 731 | { |
Anthony Barbier | ecb1c62 | 2018-04-17 11:45:10 +0100 | [diff] [blame] | 732 | opencl_is_available(); // Make sure the OpenCL symbols are initialised *before* the CLKernelLibrary is built |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | CLKernelLibrary &CLKernelLibrary::get() |
| 736 | { |
| 737 | static CLKernelLibrary _kernel_library; |
| 738 | return _kernel_library; |
| 739 | } |
| 740 | |
| 741 | Kernel CLKernelLibrary::create_kernel(const std::string &kernel_name, const StringSet &build_options_set) const |
| 742 | { |
| 743 | // Find which program contains the kernel |
| 744 | auto kernel_program_it = _kernel_program_map.find(kernel_name); |
| 745 | |
| 746 | if(_kernel_program_map.end() == kernel_program_it) |
| 747 | { |
| 748 | ARM_COMPUTE_ERROR("Kernel %s not found in the CLKernelLibrary", kernel_name.c_str()); |
| 749 | } |
steniu01 | 3470247 | 2017-07-11 09:22:58 +0100 | [diff] [blame] | 750 | std::string concat_str; |
| 751 | |
Georgios Pinitas | df473ea | 2018-05-31 18:53:52 +0100 | [diff] [blame] | 752 | #if defined(ARM_COMPUTE_DEBUG_ENABLED) |
| 753 | // Enable debug properties in CL kernels |
| 754 | concat_str += " -DARM_COMPUTE_DEBUG_ENABLED"; |
| 755 | #endif // defined(ARM_COMPUTE_DEBUG_ENABLED) |
| 756 | |
Vidhya Sudhan Loganathan | f1f4906 | 2018-05-25 13:21:26 +0100 | [diff] [blame] | 757 | if(fp16_supported()) |
Matthew Bentham | 6f31f8c | 2017-10-27 11:50:06 +0100 | [diff] [blame] | 758 | { |
| 759 | concat_str += " -DARM_COMPUTE_OPENCL_FP16_ENABLED=1 "; |
| 760 | } |
| 761 | |
Michalis Spyrou | e03342e | 2018-01-15 14:39:13 +0000 | [diff] [blame] | 762 | if(dot8_supported(_device)) |
| 763 | { |
| 764 | concat_str += " -DARM_COMPUTE_OPENCL_DOT8_ENABLED=1 "; |
| 765 | } |
| 766 | |
Pablo Tello | e86a09f | 2018-01-11 15:44:48 +0000 | [diff] [blame] | 767 | if(get_cl_version(_device) == CLVersion::CL20) |
steniu01 | 3470247 | 2017-07-11 09:22:58 +0100 | [diff] [blame] | 768 | { |
| 769 | concat_str += " -cl-std=CL2.0 "; |
| 770 | } |
Anthony Barbier | d727e85 | 2018-04-20 11:05:29 +0100 | [diff] [blame] | 771 | else if(arm_non_uniform_workgroup_supported(_device)) |
Pablo Tello | e86a09f | 2018-01-11 15:44:48 +0000 | [diff] [blame] | 772 | { |
| 773 | concat_str += " -cl-arm-non-uniform-work-group-size "; |
| 774 | } |
steniu01 | 3470247 | 2017-07-11 09:22:58 +0100 | [diff] [blame] | 775 | else |
| 776 | { |
| 777 | ARM_COMPUTE_ERROR("Non uniform workgroup size is not supported!!"); |
| 778 | } |
| 779 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 780 | // Check if the program has been built before with same build options. |
steniu01 | 3470247 | 2017-07-11 09:22:58 +0100 | [diff] [blame] | 781 | const std::string program_name = kernel_program_it->second; |
| 782 | const std::string build_options = stringify_set(build_options_set) + concat_str; |
| 783 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 784 | const std::string built_program_name = program_name + "_" + build_options; |
| 785 | auto built_program_it = _built_programs_map.find(built_program_name); |
| 786 | |
| 787 | cl::Program cl_program; |
| 788 | |
| 789 | if(_built_programs_map.end() != built_program_it) |
| 790 | { |
| 791 | // If program has been built, retrieve to create kernel from it |
| 792 | cl_program = built_program_it->second; |
| 793 | } |
| 794 | else |
| 795 | { |
| 796 | // Get program |
| 797 | Program program = load_program(program_name); |
| 798 | |
| 799 | // Build program |
| 800 | cl_program = program.build(build_options); |
| 801 | |
| 802 | // Add built program to internal map |
| 803 | _built_programs_map.emplace(built_program_name, cl_program); |
| 804 | } |
| 805 | |
| 806 | // Create and return kernel |
| 807 | return Kernel(kernel_name, cl_program); |
| 808 | } |
| 809 | |
Anthony Barbier | 7da55aa | 2018-04-13 16:58:43 +0100 | [diff] [blame] | 810 | void CLKernelLibrary::add_built_program(const std::string &built_program_name, cl::Program program) |
| 811 | { |
| 812 | _built_programs_map.emplace(built_program_name, program); |
| 813 | } |
| 814 | |
Vidhya Sudhan Loganathan | f1f4906 | 2018-05-25 13:21:26 +0100 | [diff] [blame] | 815 | bool CLKernelLibrary::fp16_supported() const |
| 816 | { |
| 817 | return ::fp16_supported(_device); |
| 818 | } |
| 819 | |
Vidhya Sudhan Loganathan | 76c8564 | 2018-05-25 13:53:02 +0100 | [diff] [blame] | 820 | bool CLKernelLibrary::int64_base_atomics_supported() const |
| 821 | { |
| 822 | return device_supports_extension(_device, "cl_khr_int64_base_atomics"); |
| 823 | } |
| 824 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 825 | const Program &CLKernelLibrary::load_program(const std::string &program_name) const |
| 826 | { |
| 827 | const auto program_it = _programs_map.find(program_name); |
| 828 | |
| 829 | if(program_it != _programs_map.end()) |
| 830 | { |
| 831 | return program_it->second; |
| 832 | } |
| 833 | |
| 834 | Program program; |
| 835 | |
| 836 | #ifdef EMBEDDED_KERNELS |
| 837 | const auto program_source_it = _program_source_map.find(program_name); |
| 838 | |
| 839 | if(_program_source_map.end() == program_source_it) |
| 840 | { |
| 841 | ARM_COMPUTE_ERROR("Embedded program for %s does not exist.", program_name.c_str()); |
| 842 | } |
| 843 | |
| 844 | program = Program(_context, program_name, program_source_it->second); |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 845 | #else /* EMBEDDED_KERNELS */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 846 | // Check for binary |
| 847 | std::string source_name = _kernel_path + program_name; |
| 848 | std::string binary_name = source_name + "bin"; |
| 849 | |
| 850 | if(std::ifstream(binary_name).is_open()) |
| 851 | { |
| 852 | const std::string program_binary = read_file(binary_name, true); |
| 853 | program = Program(_context, _device, program_name, std::vector<unsigned char>(program_binary.begin(), program_binary.end())); |
| 854 | } |
| 855 | else if(std::ifstream(source_name).is_open()) |
| 856 | { |
| 857 | program = Program(_context, program_name, read_file(source_name, false)); |
| 858 | } |
| 859 | else |
| 860 | { |
| 861 | ARM_COMPUTE_ERROR("Kernel file %s does not exist.", source_name.c_str()); |
| 862 | } |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 863 | #endif /* EMBEDDED_KERNELS */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 864 | |
| 865 | // Insert program to program map |
| 866 | const auto new_program = _programs_map.emplace(program_name, std::move(program)); |
| 867 | |
| 868 | return new_program.first->second; |
| 869 | } |
| 870 | |
| 871 | std::string CLKernelLibrary::stringify_set(const StringSet &s) const |
| 872 | { |
steniu01 | 3470247 | 2017-07-11 09:22:58 +0100 | [diff] [blame] | 873 | std::string concat_set; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 874 | |
| 875 | #ifndef EMBEDDED_KERNELS |
| 876 | concat_set += "-I" + _kernel_path + " "; |
| 877 | #endif /* EMBEDDED_KERNELS */ |
| 878 | |
| 879 | // Concatenate set |
| 880 | for(const auto &el : s) |
| 881 | { |
| 882 | concat_set += " " + el; |
| 883 | } |
| 884 | |
| 885 | return concat_set; |
| 886 | } |
Michalis Spyrou | d7e8281 | 2017-06-20 15:00:14 +0100 | [diff] [blame] | 887 | |
| 888 | std::string CLKernelLibrary::get_program_source(const std::string &program_name) |
| 889 | { |
| 890 | const auto program_source_it = _program_source_map.find(program_name); |
| 891 | |
| 892 | if(program_source_it == _program_source_map.end()) |
| 893 | { |
| 894 | ARM_COMPUTE_ERROR("Embedded program for %s does not exist.", program_name.c_str()); |
| 895 | } |
| 896 | |
| 897 | return program_source_it->second; |
| 898 | } |
steniu01 | 5f91072 | 2017-08-23 10:15:22 +0100 | [diff] [blame] | 899 | |
Abel Bernabeu | 5a6e053 | 2017-09-28 09:53:45 +0100 | [diff] [blame] | 900 | size_t CLKernelLibrary::max_local_workgroup_size(const cl::Kernel &kernel) const |
steniu01 | 5f91072 | 2017-08-23 10:15:22 +0100 | [diff] [blame] | 901 | { |
Abel Bernabeu | 5a6e053 | 2017-09-28 09:53:45 +0100 | [diff] [blame] | 902 | size_t result; |
steniu01 | 5f91072 | 2017-08-23 10:15:22 +0100 | [diff] [blame] | 903 | |
Abel Bernabeu | 5a6e053 | 2017-09-28 09:53:45 +0100 | [diff] [blame] | 904 | size_t err = kernel.getWorkGroupInfo(_device, CL_KERNEL_WORK_GROUP_SIZE, &result); |
| 905 | ARM_COMPUTE_ERROR_ON_MSG(err != 0, "clGetKernelWorkGroupInfo failed to return the maximum workgroup size for the kernel"); |
| 906 | ARM_COMPUTE_UNUSED(err); |
| 907 | |
| 908 | return result; |
steniu01 | 5f91072 | 2017-08-23 10:15:22 +0100 | [diff] [blame] | 909 | } |
| 910 | |
Abel Bernabeu | 5a6e053 | 2017-09-28 09:53:45 +0100 | [diff] [blame] | 911 | cl::NDRange CLKernelLibrary::default_ndrange() const |
steniu01 | 5f91072 | 2017-08-23 10:15:22 +0100 | [diff] [blame] | 912 | { |
Michalis Spyrou | a967611 | 2018-02-22 18:07:43 +0000 | [diff] [blame] | 913 | cl::Device device = cl::Device::getDefault(); |
| 914 | GPUTarget _target = get_target_from_device(device); |
| 915 | cl::NDRange default_range; |
| 916 | |
| 917 | switch(_target) |
| 918 | { |
| 919 | case GPUTarget::MIDGARD: |
| 920 | case GPUTarget::T600: |
| 921 | case GPUTarget::T700: |
| 922 | case GPUTarget::T800: |
| 923 | default_range = cl::NDRange(128u, 1); |
| 924 | break; |
| 925 | default: |
| 926 | default_range = cl::NullRange; |
| 927 | } |
| 928 | |
| 929 | return default_range; |
steniu01 | 5f91072 | 2017-08-23 10:15:22 +0100 | [diff] [blame] | 930 | } |
Anthony Barbier | 847864d | 2018-03-07 11:35:53 +0000 | [diff] [blame] | 931 | |
| 932 | std::string CLKernelLibrary::get_device_version() |
| 933 | { |
| 934 | return _device.getInfo<CL_DEVICE_VERSION>(); |
| 935 | } |