| 404 | } // namespace |
| 405 | |
| 406 | void CpuScaleKernel::configure(const ITensorInfo *src, |
| 407 | const ITensorInfo *dx, |
| 408 | const ITensorInfo *dy, |
| 409 | const ITensorInfo *offsets, |
| 410 | ITensorInfo *dst, |
| 411 | const ScaleKernelInfo &info) |
| 412 | { |
| 413 | ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "CpuScaleKernel::configure"); |
| 414 | ARM_COMPUTE_UNUSED(dx, dy, offsets); |
| 415 | ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst); |
| 416 | // Perform validation step |
| 417 | ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dx, dy, offsets, dst, info)); |
| 418 | |
| 419 | const auto *uk = CpuScaleKernel::get_implementation( |
| 420 | ScaleKernelDataTypeISASelectorData{src->data_type(), CPUInfo::get().get_isa(), info.interpolation_policy}); |
| 421 | ARM_COMPUTE_ERROR_ON_NULLPTR(uk); |
| 422 | |
| 423 | _run_method = uk->ukernel; |
| 424 | _name = std::string("CpuScaleKernel") |
| 425 | .append("/") |
| 426 | .append(uk->name) |
| 427 | .append("_") |
| 428 | .append(string_from_interpolation_policy(info.interpolation_policy)); |
| 429 | |
| 430 | // Get data layout and width/height indices |
| 431 | _data_layout = info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : info.data_layout; |
| 432 | const int idx_width = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH); |
| 433 | const int idx_height = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT); |
| 434 | |
| 435 | _policy = info.interpolation_policy; |
| 436 | _border_mode = info.border_mode; |
| 437 | _constant_border_value = info.constant_border_value; |
| 438 | _align_corners = info.align_corners; |
| 439 | |
| 440 | if (info.sampling_policy == SamplingPolicy::CENTER) |
| 441 | { |
| 442 | _sampling_offset = 0.5f; |
| 443 | } |
| 444 | |
| 445 | // Compute the ratio between source width/height and destination width/height |
| 446 | const auto wr = |
| 447 | scale_utils::calculate_resize_ratio(src->dimension(idx_width), dst->dimension(idx_width), _align_corners); |
| 448 | const auto hr = |
| 449 | scale_utils::calculate_resize_ratio(src->dimension(idx_height), dst->dimension(idx_height), _align_corners); |
| 450 | |
| 451 | // Area interpolation behaves as Nearest Neighbour in case of up-sampling |
| 452 | _policy = (_policy == InterpolationPolicy::AREA && wr <= 1.f && hr <= 1.f) ? InterpolationPolicy::NEAREST_NEIGHBOR |
| 453 | : _policy; |
| 454 | |
| 455 | if (_border_mode == BorderMode::UNDEFINED) |
| 456 | { |
| 457 | _border_mode = BorderMode::CONSTANT; |
| 458 | _constant_border_value = PixelValue(); |
| 459 | } |
| 460 | |
| 461 | #ifdef ENABLE_NCHW_KERNELS |
| 462 | // Configure scale function to run |
| 463 | if (_data_layout == DataLayout::NCHW) |
nothing calls this directly
no test coverage detected