diff options
author | Daniil Efremov <daniil.efremov@xored.com> | 2017-11-14 21:25:34 +0700 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 7a49c7993a8b2c670f7caa90e3fbe8a5f1c03078 (patch) | |
tree | e043cff3fe7d9f9d014ecc5c2c2348d03f9dcaa4 /src/core/CL/kernels | |
parent | 50fbc6f0a1e781d4f9f83d1e4ea2588390facea2 (diff) | |
download | ComputeLibrary-7a49c7993a8b2c670f7caa90e3fbe8a5f1c03078.tar.gz |
COMPMID-661: issue# 23 Scale border fix (#26)
Changes in CL and reference in terms of border handling.
Change-Id: I5bed95b1f4c308629d7113455dc8a55d74500bcd
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/95742
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'src/core/CL/kernels')
-rw-r--r-- | src/core/CL/kernels/CLScaleKernel.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/core/CL/kernels/CLScaleKernel.cpp b/src/core/CL/kernels/CLScaleKernel.cpp index 82ebe644ea..6a5d24c943 100644 --- a/src/core/CL/kernels/CLScaleKernel.cpp +++ b/src/core/CL/kernels/CLScaleKernel.cpp @@ -54,11 +54,14 @@ void CLScaleKernel::configure(const ICLTensor *input, ICLTensor *output, Interpo _input = input; _output = output; - /* Compute the ratio between source width/height and destination width/height */ + // Compute the ratio between source width/height and destination width/height const auto wr = static_cast<float>(input->info()->dimension(0)) / static_cast<float>(output->info()->dimension(0)); const auto hr = static_cast<float>(input->info()->dimension(1)) / static_cast<float>(output->info()->dimension(1)); - /* Area interpolation behaves as Nearest Neighbour in case of up-sampling */ + // Compute actual border size + BorderSize border = border_undefined ? BorderSize(0) : border_size(); + + // Area interpolation behaves as Nearest Neighbour in case of up-sampling if(policy == InterpolationPolicy::AREA && wr <= 1.f && hr <= 1.f) { policy = InterpolationPolicy::NEAREST_NEIGHBOR; @@ -69,11 +72,14 @@ void CLScaleKernel::configure(const ICLTensor *input, ICLTensor *output, Interpo } // Create kernel - std::set<std::string> build_opts = { ("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type())) }; - std::string interpolation_name = string_from_interpolation_policy(policy); + CLBuildOptions build_opts; + build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type())); + build_opts.add_option("-DBORDER_SIZE=" + support::cpp11::to_string(border.right)); + + std::string interpolation_name = string_from_interpolation_policy(policy); std::transform(interpolation_name.begin(), interpolation_name.end(), interpolation_name.begin(), ::tolower); std::string kernel_name = "scale_" + interpolation_name; - _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts)); + _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options())); // Configure kernel window constexpr unsigned int num_elems_processed_per_iteration = 4; @@ -84,15 +90,18 @@ void CLScaleKernel::configure(const ICLTensor *input, ICLTensor *output, Interpo // Reads can occur within the valid region of the input AccessWindowStatic input_access(input->info(), - input_valid_region.anchor[0] - border_size().left, input_valid_region.anchor[1] - border_size().top, - input_valid_region.anchor[0] + input_valid_region.shape[0] + border_size().right, - input_valid_region.anchor[1] + input_valid_region.shape[1] + border_size().bottom); + input_valid_region.anchor[0] - border.left, input_valid_region.anchor[1] - border.top, + input_valid_region.anchor[0] + input_valid_region.shape[0] + border.right, + input_valid_region.anchor[1] + input_valid_region.shape[1] + border.bottom); AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration); update_window_and_padding(win, input_access, output_access); - output_access.set_valid_region(win, calculate_valid_region_scale(*(input->info()), output->info()->tensor_shape(), policy, border_size(), + output_access.set_valid_region(win, calculate_valid_region_scale(*(input->info()), + output->info()->tensor_shape(), + policy, + border, border_undefined)); ICLKernel::configure(win); |