diff options
author | Gunes Bayir <gunes.bayir@arm.com> | 2022-12-26 16:24:04 +0000 |
---|---|---|
committer | Gunes Bayir <gunes.bayir@arm.com> | 2022-12-29 17:27:33 +0000 |
commit | b7e8626717b2ef81b0d03284c8f6ffdbe9cd2245 (patch) | |
tree | 8fb8197a4f69fb5024a5330e031d3d5c0b26bdad /src/gpu/cl/kernels/ClScaleKernel.cpp | |
parent | a5cb79f18685292bf5b63a0c484a58945320823d (diff) | |
download | ComputeLibrary-b7e8626717b2ef81b0d03284c8f6ffdbe9cd2245.tar.gz |
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 <gunes.bayir@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8888
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/gpu/cl/kernels/ClScaleKernel.cpp')
-rw-r--r-- | src/gpu/cl/kernels/ClScaleKernel.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
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(); |