From b7e8626717b2ef81b0d03284c8f6ffdbe9cd2245 Mon Sep 17 00:00:00 2001 From: Gunes Bayir Date: Mon, 26 Dec 2022 16:24:04 +0000 Subject: Optimize CL Scale/Resize Quantized by removing (de)quant. code This patch removes the quant/dequant code in CLScale and the Resize operator in dynamic fusion. We don't support different quantization information for input and output and in this case the quantization and dequantization is not necessary. The very same optimization was delivered for cpu. It also moves the SCALE_X and SCALE_Y arguments to look-up table from build options in the template writer of Resize. Change-Id: Icd043c8671220c8feea935dd4b24a5b17c6c4ea4 Signed-off-by: Gunes Bayir Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8888 Benchmark: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Viet-Hoa Do Reviewed-by: Gian Marco Iodice Comments-Addressed: Arm Jenkins --- src/gpu/cl/kernels/ClScaleKernel.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/gpu/cl') diff --git a/src/gpu/cl/kernels/ClScaleKernel.cpp b/src/gpu/cl/kernels/ClScaleKernel.cpp index 6f16adc657..7f24aa2eb6 100644 --- a/src/gpu/cl/kernels/ClScaleKernel.cpp +++ b/src/gpu/cl/kernels/ClScaleKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021 Arm Limited. + * Copyright (c) 2016-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -102,7 +102,6 @@ void ClScaleKernel::configure(const CLCompileContext &compile_context, ITensorIn float scale_x = 0.f; float scale_y = 0.f; std::tie(scale_x, scale_y) = calculate_scale_factors(src, dst, _data_layout, info.align_corners); - const bool is_qasymm_bilinear = is_data_type_quantized_asymmetric(src->data_type()) && info.interpolation_policy == InterpolationPolicy::BILINEAR; // Area interpolation behaves as Nearest Neighbour in case of up-sampling auto interpolation_policy_to_use = info.interpolation_policy; @@ -141,17 +140,6 @@ void ClScaleKernel::configure(const CLCompileContext &compile_context, ITensorIn build_opts.add_option_if(info.align_corners, "-DALIGN_CORNERS"); build_opts.add_option_if(is_data_type_float(src->data_type()), "-DIS_FLOATING_POINT"); build_opts.add_option_if_else(info.sampling_policy == SamplingPolicy::CENTER, "-DSAMPLING_POLICY_CENTER", "-DSAMPLING_POLICY_TOP_LEFT"); - if(is_qasymm_bilinear) - { - const UniformQuantizationInfo qinfo = src->quantization_info().uniform(); - build_opts.add_option("-DSCALE=" + support::cpp11::to_string(qinfo.scale)); - build_opts.add_option("-DOFFSET=" + support::cpp11::to_string(qinfo.offset)); - } - else - { - build_opts.add_option("-DSCALE=" + support::cpp11::to_string(1)); - build_opts.add_option("-DOFFSET=" + support::cpp11::to_string(0)); - } } else if(_data_layout == DataLayout::NCHW) { @@ -169,6 +157,8 @@ void ClScaleKernel::configure(const CLCompileContext &compile_context, ITensorIn build_opts.add_option_if(info.border_mode == BorderMode::CONSTANT, "-DBORDER_MODE_CONSTANT"); build_opts.add_option_if(info.align_corners, "-DALIGN_CORNERS"); build_opts.add_option_if_else(info.sampling_policy == SamplingPolicy::CENTER, "-DSAMPLING_POLICY_CENTER", "-DSAMPLING_POLICY_TOP_LEFT"); + + const bool is_qasymm_bilinear = is_data_type_quantized_asymmetric(src->data_type()) && info.interpolation_policy == InterpolationPolicy::BILINEAR; if(is_qasymm_bilinear) { const UniformQuantizationInfo qinfo = src->quantization_info().uniform(); -- cgit v1.2.1