diff options
author | Gunes Bayir <gunes.bayir@arm.com> | 2022-09-04 21:00:10 +0100 |
---|---|---|
committer | Gunes Bayir <gunes.bayir@arm.com> | 2022-09-09 09:29:43 +0000 |
commit | 0eed305680ade0c48d07f592c4c4a8aaaad077b7 (patch) | |
tree | ec4aa5c2e66135d377b5a34f5cf03f97462424c0 /src/cpu/operators | |
parent | d11de9861e6c32fa389f503e037098f50ffed156 (diff) | |
download | ComputeLibrary-0eed305680ade0c48d07f592c4c4a8aaaad077b7.tar.gz |
Optimize FP32/16 Bilinear Scale Kernel for Neon™
This patch removes index and weight pre-computations where it's not used and reduces some calculations inside the inner-most loop of Scale.
Resolves: COMPMID-5452
Change-Id: Ie149b1b76a90a8cb659ada0f97aef78caf69932f
Signed-off-by: Gunes Bayir <gunes.bayir@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8220
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/cpu/operators')
-rw-r--r-- | src/cpu/operators/CpuScale.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/cpu/operators/CpuScale.cpp b/src/cpu/operators/CpuScale.cpp index 27da238c16..fdb52e5ede 100644 --- a/src/cpu/operators/CpuScale.cpp +++ b/src/cpu/operators/CpuScale.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Arm Limited. + * Copyright (c) 2021-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -23,9 +23,6 @@ */ #include "src/cpu/operators/CpuScale.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/Validate.h" #include "arm_compute/runtime/NEON/NEScheduler.h" #include "src/common/utils/Log.h" #include "src/core/utils/ScaleUtils.h" @@ -218,26 +215,38 @@ void CpuScale::prepare(ITensorPack &tensors) _scale_info.interpolation_policy; const SamplingPolicy sampling_policy = _scale_info.sampling_policy; - switch(policy_to_use) + bool precompute_indices_weights = arm_compute::scale_utils::is_precomputation_required(_data_layout, src->info()->data_type(), policy_to_use); + + if(precompute_indices_weights == true) { - case InterpolationPolicy::NEAREST_NEIGHBOR: - { - // Pre-compute offsets for nearest interpolation - precompute_dx_dy_offsets(nullptr, nullptr, offsets, wr, hr, sampling_policy, is_align_corners_used); - break; - } - case InterpolationPolicy::BILINEAR: + switch(policy_to_use) { - // Pre-compute dx, dy and offsets for bilinear interpolation - precompute_dx_dy_offsets(dx, dy, offsets, wr, hr, sampling_policy, is_align_corners_used); - break; + case InterpolationPolicy::NEAREST_NEIGHBOR: + { + // Pre-compute offsets for nearest interpolation + precompute_dx_dy_offsets(nullptr, nullptr, offsets, wr, hr, sampling_policy, is_align_corners_used); + break; + } + case InterpolationPolicy::BILINEAR: + { + // Pre-compute dx, dy and offsets for bilinear interpolation + precompute_dx_dy_offsets(dx, dy, offsets, wr, hr, sampling_policy, is_align_corners_used); + break; + } + case InterpolationPolicy::AREA: + { + break; + } + default: + ARM_COMPUTE_ERROR("Unsupported interpolation mode"); } - case InterpolationPolicy::AREA: + } + else + { + if(policy_to_use != InterpolationPolicy::NEAREST_NEIGHBOR && policy_to_use != InterpolationPolicy::BILINEAR && policy_to_use != InterpolationPolicy::AREA) { - break; - } - default: ARM_COMPUTE_ERROR("Unsupported interpolation mode"); + } } } } |