| 341 | } |
| 342 | |
| 343 | void ClIm2ColKernel::configure(const ClCompileContext &compile_context, |
| 344 | ITensorInfo *src, |
| 345 | ITensorInfo *dst, |
| 346 | const Size2D &kernel_dims, |
| 347 | const PadStrideInfo &conv_info, |
| 348 | bool has_bias, |
| 349 | const Size2D &dilation, |
| 350 | unsigned int num_groups) |
| 351 | { |
| 352 | ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst); |
| 353 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst, kernel_dims, conv_info, has_bias, dilation, num_groups)); |
| 354 | |
| 355 | auto padding_info = get_padding_info({src, dst}); |
| 356 | _data_layout = src->data_layout(); |
| 357 | |
| 358 | const unsigned int width_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH); |
| 359 | const unsigned int height_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT); |
| 360 | const unsigned int input_width = src->dimension(width_idx); |
| 361 | const unsigned int input_height = src->dimension(height_idx); |
| 362 | |
| 363 | // Select and configure the optimal OpenCL kernel to run. |
| 364 | // This function returns the OpenCL kernel's name, the arguments to pass at compile time, the number of elements processed per iteration |
| 365 | // and the padding requirement flag |
| 366 | Im2ColConfiguration im2col_config = |
| 367 | configure_opencl_kernel(src, kernel_dims, conv_info, has_bias, dilation, num_groups); |
| 368 | |
| 369 | // Create kernel |
| 370 | _kernel = create_kernel(compile_context, im2col_config.kernel_name, im2col_config.build_options); |
| 371 | |
| 372 | _convolved_dims = |
| 373 | scaled_dimensions(input_width, input_height, kernel_dims.width, kernel_dims.height, conv_info, dilation); |
| 374 | _num_elems_processed_per_iteration = im2col_config.num_elems_processed_per_iteration; |
| 375 | _kernel_dims = kernel_dims; // Only needed by the Tuner |
| 376 | _conv_info = conv_info; // Only needed by the Tuner |
| 377 | _num_groups = num_groups; |
| 378 | |
| 379 | // Configure kernel window |
| 380 | auto win_config = validate_and_configure_window(src, dst, kernel_dims, conv_info, has_bias, dilation, |
| 381 | im2col_config.num_elems_processed_per_iteration, |
| 382 | im2col_config.is_padding_required_nchw, num_groups); |
| 383 | ARM_COMPUTE_ERROR_THROW_ON(win_config.first); |
| 384 | IClKernel::configure_internal(win_config.second); |
| 385 | |
| 386 | // Set config_id for enabling LWS tuning |
| 387 | _config_id = im2col_config.kernel_name; |
| 388 | _config_id += "_"; |
| 389 | _config_id += lower_string(string_from_data_type(src->data_type())); |
| 390 | _config_id += "_"; |
| 391 | _config_id += support::cpp11::to_string(num_groups); |
| 392 | _config_id += "_"; |
| 393 | _config_id += support::cpp11::to_string(dst->dimension(0)); |
| 394 | _config_id += "_"; |
| 395 | _config_id += support::cpp11::to_string(dst->dimension(1)); |
| 396 | _config_id += "_"; |
| 397 | _config_id += lower_string(string_from_data_layout(_data_layout)); |
| 398 | |
| 399 | ARM_COMPUTE_ERROR_ON(src->data_layout() == DataLayout::NHWC && has_padding_changed(padding_info)); |
| 400 | } |
nothing calls this directly
no test coverage detected