Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2019 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/kernels/CLConvolutionKernel.h" |
| 25 | |
| 26 | #include "arm_compute/core/CL/CLHelpers.h" |
| 27 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
| 28 | #include "arm_compute/core/CL/ICLKernel.h" |
| 29 | #include "arm_compute/core/CL/ICLTensor.h" |
| 30 | #include "arm_compute/core/CL/OpenCL.h" |
| 31 | #include "arm_compute/core/Error.h" |
| 32 | #include "arm_compute/core/Helpers.h" |
| 33 | #include "arm_compute/core/TensorInfo.h" |
| 34 | #include "arm_compute/core/Types.h" |
| 35 | #include "arm_compute/core/Utils.h" |
| 36 | #include "arm_compute/core/Validate.h" |
| 37 | |
| 38 | #include <set> |
| 39 | #include <sstream> |
| 40 | #include <string> |
| 41 | |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 42 | namespace arm_compute |
| 43 | { |
| 44 | namespace |
| 45 | { |
| 46 | constexpr unsigned int max_matrix_size = 81; |
| 47 | } // namespace |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 48 | |
| 49 | /****************************************************************************************\ |
| 50 | * Square Convolution * |
| 51 | \****************************************************************************************/ |
| 52 | |
| 53 | template <unsigned int matrix_size> |
| 54 | BorderSize CLConvolutionKernel<matrix_size>::border_size() const |
| 55 | { |
| 56 | return BorderSize(matrix_size / 2); |
| 57 | } |
| 58 | |
| 59 | template <unsigned int matrix_size> |
| 60 | void CLConvolutionKernel<matrix_size>::configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t scale, bool border_undefined) |
| 61 | { |
| 62 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); |
| 63 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::S16); |
| 64 | ARM_COMPUTE_ERROR_ON(conv == nullptr); |
| 65 | |
| 66 | _input = input; |
| 67 | _output = output; |
| 68 | |
Georgios Pinitas | e9146ed | 2018-02-07 16:05:47 +0000 | [diff] [blame] | 69 | std::stringstream kernel_name; |
| 70 | CLBuildOptions build_opts; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 71 | kernel_name << "convolution" << matrix_size << "x" << matrix_size << "_static"; |
| 72 | |
| 73 | if(scale == 0) |
| 74 | { |
| 75 | scale = calculate_matrix_scale(conv, matrix_size); |
| 76 | } |
| 77 | |
| 78 | for(unsigned int i = 0; i < matrix_size * matrix_size; i++) |
| 79 | { |
| 80 | std::stringstream mat_str; |
| 81 | mat_str << "-DMAT" << i << "=" << conv[i]; |
Georgios Pinitas | e9146ed | 2018-02-07 16:05:47 +0000 | [diff] [blame] | 82 | build_opts.add_option(mat_str.str()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 83 | } |
| 84 | |
Georgios Pinitas | e9146ed | 2018-02-07 16:05:47 +0000 | [diff] [blame] | 85 | build_opts.add_option("-DSCALE=" + support::cpp11::to_string(scale)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 86 | |
| 87 | DataType data_type = data_type_for_convolution_matrix(conv, matrix_size * matrix_size); |
Georgios Pinitas | e9146ed | 2018-02-07 16:05:47 +0000 | [diff] [blame] | 88 | build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 89 | |
| 90 | std::stringstream out_type; |
| 91 | out_type << "-DDATA_TYPE_OUT=" << get_cl_type_from_data_type(output->info()->data_type()); |
Georgios Pinitas | e9146ed | 2018-02-07 16:05:47 +0000 | [diff] [blame] | 92 | build_opts.add_option(out_type.str()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 93 | |
Georgios Pinitas | e9146ed | 2018-02-07 16:05:47 +0000 | [diff] [blame] | 94 | _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name.str(), build_opts.options())); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 95 | |
| 96 | // Configure kernel window |
| 97 | constexpr unsigned int num_elems_processed_per_iteration = 8; |
| 98 | constexpr unsigned int num_elems_written_per_iteration = 8; |
| 99 | constexpr unsigned int num_elems_read_per_iteration = 16; |
| 100 | constexpr unsigned int num_rows_read_per_iteration = matrix_size; |
| 101 | |
| 102 | Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size()); |
| 103 | |
| 104 | AccessWindowRectangle input_access(input->info(), -border_size().left, -border_size().top, num_elems_read_per_iteration, num_rows_read_per_iteration); |
| 105 | AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration); |
| 106 | |
| 107 | update_window_and_padding(win, input_access, output_access); |
| 108 | |
| 109 | output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size()); |
| 110 | |
Anthony Barbier | b6eb353 | 2018-08-08 13:20:04 +0100 | [diff] [blame] | 111 | ICLKernel::configure_internal(win); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | /****************************************************************************************\ |
| 115 | * Separable Convolution * |
| 116 | \****************************************************************************************/ |
| 117 | template <unsigned int matrix_size> |
| 118 | CLSeparableConvolutionHorKernel<matrix_size>::CLSeparableConvolutionHorKernel() |
| 119 | : _border_size(0) |
| 120 | { |
| 121 | } |
| 122 | |
| 123 | template <unsigned int matrix_size> |
| 124 | BorderSize CLSeparableConvolutionHorKernel<matrix_size>::border_size() const |
| 125 | { |
| 126 | return _border_size; |
| 127 | } |
| 128 | |
| 129 | template <unsigned int matrix_size> |
| 130 | void CLSeparableConvolutionHorKernel<matrix_size>::configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, bool border_undefined) |
| 131 | { |
| 132 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); |
| 133 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U16, DataType::S16, DataType::S32); |
| 134 | |
| 135 | ARM_COMPUTE_ERROR_ON((matrix_size != 5) && (matrix_size != 7) && (matrix_size != 9)); |
| 136 | |
| 137 | _input = input; |
| 138 | _output = output; |
| 139 | _border_size = BorderSize(border_undefined ? 0 : matrix_size / 2, matrix_size / 2); |
| 140 | |
| 141 | // Set build options |
| 142 | std::set<std::string> build_opts; |
| 143 | |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 144 | std::array<int16_t, matrix_size *matrix_size> mat = { 0 }; |
| 145 | memcpy(mat.data(), conv, matrix_size * sizeof(int16_t)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 146 | |
| 147 | for(unsigned int j = 0; j < matrix_size * matrix_size; j++) |
| 148 | { |
Moritz Pflanzer | 05da6dd | 2017-07-04 12:08:41 +0100 | [diff] [blame] | 149 | build_opts.insert("-DMAT" + support::cpp11::to_string(j) + "=" + support::cpp11::to_string(mat[j])); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | build_opts.insert("-DSCALE=0"); |
| 153 | |
| 154 | build_opts.insert("-DDATA_TYPE=" + get_cl_type_from_data_type(output->info()->data_type())); |
| 155 | |
| 156 | // Create kernel |
Gary Antcliffe | fffbdbc | 2019-05-28 11:40:21 +0100 | [diff] [blame] | 157 | const std::string kernel_name = "convolution_separable1x" + support::cpp11::to_string(matrix_size) + "_static"; |
| 158 | _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 159 | |
| 160 | // Configure kernel window |
| 161 | constexpr unsigned int num_elems_processed_per_iteration = 8; |
| 162 | constexpr unsigned int num_elems_read_per_iteration = 16; |
| 163 | constexpr unsigned int num_elems_written_per_iteration = 8; |
| 164 | |
| 165 | Window win = calculate_max_window_horizontal(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size()); |
| 166 | |
| 167 | AccessWindowHorizontal input_access(input->info(), -border_size().left, num_elems_read_per_iteration); |
| 168 | AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration); |
| 169 | |
| 170 | update_window_and_padding(win, input_access, output_access); |
| 171 | |
| 172 | output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size()); |
| 173 | |
Anthony Barbier | b6eb353 | 2018-08-08 13:20:04 +0100 | [diff] [blame] | 174 | ICLKernel::configure_internal(win); |
Gary Antcliffe | fffbdbc | 2019-05-28 11:40:21 +0100 | [diff] [blame] | 175 | |
| 176 | // Set config_id for enabling LWS tuning |
| 177 | _config_id = kernel_name; |
| 178 | _config_id += "_"; |
| 179 | _config_id += lower_string(string_from_data_type(input->info()->data_type())); |
| 180 | _config_id += "_"; |
| 181 | _config_id += support::cpp11::to_string(input->info()->dimension(0)); |
| 182 | _config_id += "_"; |
| 183 | _config_id += support::cpp11::to_string(input->info()->dimension(1)); |
| 184 | _config_id += "_"; |
| 185 | _config_id += support::cpp11::to_string(output->info()->dimension(0)); |
| 186 | _config_id += "_"; |
| 187 | _config_id += support::cpp11::to_string(output->info()->dimension(1)); |
| 188 | _config_id += "_"; |
| 189 | _config_id += support::cpp11::to_string(border_undefined); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | template <unsigned int matrix_size> |
| 193 | BorderSize CLSeparableConvolutionVertKernel<matrix_size>::border_size() const |
| 194 | { |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 195 | return BorderSize{ matrix_size / 2, 0 }; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | template <unsigned int matrix_size> |
| 199 | void CLSeparableConvolutionVertKernel<matrix_size>::configure(const ICLTensor *input, ICLTensor *output, |
| 200 | const int16_t *conv, uint32_t scale, bool border_undefined, DataType data_type) |
| 201 | { |
| 202 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U16, DataType::S16, DataType::S32); |
| 203 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::S16); |
| 204 | ARM_COMPUTE_ERROR_ON((matrix_size != 5) && (matrix_size != 7) && (matrix_size != 9)); |
| 205 | ARM_COMPUTE_ERROR_ON(scale == 0); |
| 206 | |
| 207 | _input = input; |
| 208 | _output = output; |
| 209 | |
| 210 | std::set<std::string> build_opts; |
| 211 | |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 212 | std::array<int16_t, matrix_size *matrix_size> mat = { 0 }; |
| 213 | memcpy(mat.data() + matrix_size, conv, matrix_size * sizeof(int16_t)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 214 | |
| 215 | for(unsigned int j = 0; j < matrix_size * matrix_size; j++) |
| 216 | { |
Moritz Pflanzer | 05da6dd | 2017-07-04 12:08:41 +0100 | [diff] [blame] | 217 | build_opts.insert("-DMAT" + support::cpp11::to_string(j) + "=" + support::cpp11::to_string(mat[j])); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 218 | } |
| 219 | |
Moritz Pflanzer | 05da6dd | 2017-07-04 12:08:41 +0100 | [diff] [blame] | 220 | build_opts.insert("-DSCALE=" + support::cpp11::to_string(scale)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 221 | |
| 222 | build_opts.insert("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type())); |
| 223 | |
| 224 | build_opts.insert("-DCOMPUTE_TYPE=" + get_cl_type_from_data_type(data_type)); |
| 225 | |
| 226 | std::stringstream out_type; |
| 227 | out_type << "-DDATA_TYPE_OUT=" << get_cl_type_from_data_type(output->info()->data_type()); |
| 228 | build_opts.insert(out_type.str()); |
| 229 | |
| 230 | // Create kernel |
Gary Antcliffe | fffbdbc | 2019-05-28 11:40:21 +0100 | [diff] [blame] | 231 | const std::string kernel_name = "convolution_separable" + support::cpp11::to_string(matrix_size) + "x1_static"; |
| 232 | _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 233 | |
| 234 | // Configure kernel window |
| 235 | constexpr unsigned int num_elems_processed_per_iteration = 8; |
| 236 | constexpr unsigned int num_elems_written_per_iteration = 8; |
| 237 | constexpr unsigned int num_elems_read_per_iteration = 8; |
| 238 | constexpr unsigned int num_rows_read_per_iteration = matrix_size; |
| 239 | |
| 240 | Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size()); |
| 241 | |
| 242 | AccessWindowRectangle input_access(input->info(), 0, -border_size().top, num_elems_read_per_iteration, num_rows_read_per_iteration); |
| 243 | AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration); |
| 244 | |
| 245 | update_window_and_padding(win, input_access, output_access); |
| 246 | |
| 247 | output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size()); |
| 248 | |
Anthony Barbier | b6eb353 | 2018-08-08 13:20:04 +0100 | [diff] [blame] | 249 | ICLKernel::configure_internal(win); |
Gary Antcliffe | fffbdbc | 2019-05-28 11:40:21 +0100 | [diff] [blame] | 250 | |
| 251 | // Set config_id for enabling LWS tuning |
| 252 | _config_id = kernel_name; |
| 253 | _config_id += "_"; |
| 254 | _config_id += lower_string(string_from_data_type(data_type)); |
| 255 | _config_id += "_"; |
| 256 | _config_id += support::cpp11::to_string(input->info()->dimension(0)); |
| 257 | _config_id += "_"; |
| 258 | _config_id += support::cpp11::to_string(input->info()->dimension(1)); |
| 259 | _config_id += "_"; |
| 260 | _config_id += support::cpp11::to_string(output->info()->dimension(0)); |
| 261 | _config_id += "_"; |
| 262 | _config_id += support::cpp11::to_string(output->info()->dimension(1)); |
| 263 | _config_id += "_"; |
| 264 | _config_id += support::cpp11::to_string(border_undefined); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | /****************************************************************************************\ |
| 268 | * Rectangle Convolution * |
| 269 | \****************************************************************************************/ |
| 270 | |
| 271 | CLConvolutionRectangleKernel::CLConvolutionRectangleKernel() |
| 272 | : _border_size(0), _input(nullptr), _output(nullptr) |
| 273 | { |
| 274 | } |
| 275 | |
| 276 | BorderSize CLConvolutionRectangleKernel::border_size() const |
| 277 | { |
| 278 | return _border_size; |
| 279 | } |
| 280 | |
| 281 | void CLConvolutionRectangleKernel::configure(const ICLTensor *input, ICLTensor *output, const int16_t *conv, uint32_t width, uint32_t height, uint32_t scale, bool border_undefined) |
| 282 | { |
| 283 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8); |
| 284 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::S16); |
| 285 | ARM_COMPUTE_ERROR_ON(nullptr == conv); |
| 286 | ARM_COMPUTE_ERROR_ON(3 != width && 5 != width && 7 != width && 9 != width); |
| 287 | ARM_COMPUTE_ERROR_ON(3 != height && 5 != height && 7 != height && 9 != height); |
| 288 | ARM_COMPUTE_ERROR_ON(0 == scale); |
| 289 | |
| 290 | _input = input; |
| 291 | _output = output; |
| 292 | _border_size = BorderSize(height / 2, width / 2); |
| 293 | |
| 294 | std::set<std::string> options; |
| 295 | |
| 296 | std::stringstream output_type; |
| 297 | output_type << "-DDATA_TYPE_OUT=" << get_cl_type_from_data_type(output->info()->data_type()); |
| 298 | options.insert(output_type.str()); |
| 299 | |
| 300 | uint32_t matrix_size = width * height; |
| 301 | |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 302 | std::array<int16_t, max_matrix_size> mat = { 0 }; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 303 | |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 304 | memcpy(mat.data(), conv, matrix_size * sizeof(int16_t)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 305 | |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 306 | for(unsigned int j = 0; j < max_matrix_size; j++) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 307 | { |
Moritz Pflanzer | 05da6dd | 2017-07-04 12:08:41 +0100 | [diff] [blame] | 308 | options.insert("-DMAT" + support::cpp11::to_string(j) + "=" + support::cpp11::to_string(mat[j])); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 309 | } |
| 310 | |
Moritz Pflanzer | 05da6dd | 2017-07-04 12:08:41 +0100 | [diff] [blame] | 311 | options.insert("-DSCALE=" + support::cpp11::to_string(scale)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 312 | |
| 313 | DataType data_type = data_type_for_convolution_matrix(conv, matrix_size); |
| 314 | options.insert("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type)); |
| 315 | |
Moritz Pflanzer | 05da6dd | 2017-07-04 12:08:41 +0100 | [diff] [blame] | 316 | options.insert("-DMATRIX_WIDTH=" + support::cpp11::to_string(width)); |
| 317 | options.insert("-DMATRIX_HEIGHT=" + support::cpp11::to_string(height)); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 318 | |
| 319 | _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("convolution_rectangle", options)); |
| 320 | |
| 321 | // Configure kernel window |
| 322 | constexpr unsigned int num_elems_processed_per_iteration = 8; |
| 323 | constexpr unsigned int num_elems_read_per_iteration = 16; |
| 324 | constexpr unsigned int num_elems_written_per_iteration = 8; |
| 325 | const unsigned int num_rows_read_per_iteration = height; |
| 326 | |
| 327 | Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration), border_undefined, border_size()); |
| 328 | |
| 329 | AccessWindowRectangle input_access(input->info(), -border_size().left, -border_size().top, num_elems_read_per_iteration, num_rows_read_per_iteration); |
| 330 | AccessWindowHorizontal output_access(output->info(), 0, num_elems_written_per_iteration); |
| 331 | |
| 332 | update_window_and_padding(win, input_access, output_access); |
| 333 | |
| 334 | output_access.set_valid_region(win, input->info()->valid_region(), border_undefined, border_size()); |
| 335 | |
Anthony Barbier | b6eb353 | 2018-08-08 13:20:04 +0100 | [diff] [blame] | 336 | ICLKernel::configure_internal(win); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | void CLConvolutionRectangleKernel::run(const Window &window, cl::CommandQueue &queue) |
| 340 | { |
| 341 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 342 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window); |
| 343 | |
| 344 | Window slice = window.first_slice_window_2D(); |
| 345 | |
| 346 | do |
| 347 | { |
| 348 | unsigned int idx = 0; |
| 349 | add_2D_tensor_argument(idx, _input, slice); |
| 350 | add_2D_tensor_argument(idx, _output, slice); |
Michele Di Giorgio | 6b9f388 | 2019-07-01 16:37:04 +0100 | [diff] [blame] | 351 | enqueue(queue, *this, slice, lws_hint()); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 352 | } |
| 353 | while(window.slide_window_slice_2D(slice)); |
| 354 | } |
| 355 | |
| 356 | template class arm_compute::CLConvolutionKernel<3>; |
| 357 | template class arm_compute::CLConvolutionKernel<5>; |
| 358 | template class arm_compute::CLConvolutionKernel<7>; |
| 359 | template class arm_compute::CLConvolutionKernel<9>; |
| 360 | template class arm_compute::CLSeparableConvolutionVertKernel<5>; |
| 361 | template class arm_compute::CLSeparableConvolutionVertKernel<7>; |
| 362 | template class arm_compute::CLSeparableConvolutionVertKernel<9>; |
| 363 | template class arm_compute::CLSeparableConvolutionHorKernel<5>; |
| 364 | template class arm_compute::CLSeparableConvolutionHorKernel<7>; |
| 365 | template class arm_compute::CLSeparableConvolutionHorKernel<9>; |
Michalis Spyrou | 299fdd3 | 2019-05-01 13:03:59 +0100 | [diff] [blame] | 366 | } // namespace arm_compute |