From ccd94966cc58ef5148577e71ba1a4ff5aae1f3bb Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Tue, 9 Jun 2020 12:09:24 +0100 Subject: COMPMID-3364: use ScaleKernelInfo for Scale on OpenCL and GLES - Make Scale and ScaleKernel (on CL and GLES) use ScaleKernelInfo - Deprecate previous configure/validate functions on NEON, CL and GLES - Make adjustments required by deprecation Change-Id: I7e81f4ee9ae919392137b92f91e9bc002b7ae277 Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3317 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio --- src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/core/GLES_COMPUTE/kernels') diff --git a/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp b/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp index a85a0e7e98..8c268ca374 100644 --- a/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp +++ b/src/core/GLES_COMPUTE/kernels/GCScaleKernel.cpp @@ -45,13 +45,13 @@ BorderSize GCScaleKernel::border_size() const return BorderSize(1); } -void GCScaleKernel::configure(const IGCTensor *input, IGCTensor *output, InterpolationPolicy policy, bool border_undefined, SamplingPolicy sampling_policy) +void GCScaleKernel::configure(const IGCTensor *input, IGCTensor *output, const ScaleKernelInfo &info) { ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F16); ARM_COMPUTE_ERROR_ON_NULLPTR(output); ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); ARM_COMPUTE_ERROR_ON(output == input); - ARM_COMPUTE_ERROR_ON(policy != InterpolationPolicy::NEAREST_NEIGHBOR); + ARM_COMPUTE_ERROR_ON(info.interpolation_policy != InterpolationPolicy::NEAREST_NEIGHBOR); _input = input; _output = output; @@ -61,16 +61,18 @@ void GCScaleKernel::configure(const IGCTensor *input, IGCTensor *output, Interpo const auto hr = static_cast(input->info()->dimension(1)) / static_cast(output->info()->dimension(1)); // Compute actual border size - BorderSize border = border_undefined ? BorderSize(0) : border_size(); + const bool border_undefined = info.border_mode == BorderMode::UNDEFINED; + 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) + auto interpolation_policy_to_use = info.interpolation_policy; + if(interpolation_policy_to_use == InterpolationPolicy::AREA && wr <= 1.f && hr <= 1.f) { - policy = InterpolationPolicy::NEAREST_NEIGHBOR; + interpolation_policy_to_use = InterpolationPolicy::NEAREST_NEIGHBOR; } else { - ARM_COMPUTE_ERROR_ON(policy == InterpolationPolicy::AREA); + ARM_COMPUTE_ERROR_ON(interpolation_policy_to_use == InterpolationPolicy::AREA); } // Create kernel @@ -81,7 +83,7 @@ void GCScaleKernel::configure(const IGCTensor *input, IGCTensor *output, Interpo build_opts.emplace("#define DATA_TYPE_FP16"); build_opts.emplace("#define BORDER_SIZE " + support::cpp11::to_string(border.right)); - if(sampling_policy == SamplingPolicy::TOP_LEFT) + if(info.sampling_policy == SamplingPolicy::TOP_LEFT) { build_opts.emplace("#define SAMPLING_POLICY_TOP_LEFT"); } @@ -106,7 +108,7 @@ void GCScaleKernel::configure(const IGCTensor *input, IGCTensor *output, Interpo build_opts.emplace("#define SCALE_NEAREST_GENERIC"); } - std::string interpolation_name = string_from_interpolation_policy(policy); // NOLINT + std::string interpolation_name = string_from_interpolation_policy(interpolation_policy_to_use); // NOLINT std::transform(interpolation_name.begin(), interpolation_name.end(), interpolation_name.begin(), ::tolower); std::string kernel_name = "scale_" + interpolation_name; _kernel = GCKernelLibrary::get().create_kernel(kernel_name, build_opts); @@ -130,8 +132,8 @@ void GCScaleKernel::configure(const IGCTensor *input, IGCTensor *output, Interpo output_access.set_valid_region(win, calculate_valid_region_scale(*(input->info()), output->info()->tensor_shape(), - policy, - sampling_policy, + info.interpolation_policy, + info.sampling_policy, border_undefined)); IGCKernel::configure(win); -- cgit v1.2.1