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/core/utils | |
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/core/utils')
-rw-r--r-- | src/core/utils/ScaleUtils.cpp | 18 | ||||
-rw-r--r-- | src/core/utils/ScaleUtils.h | 13 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/core/utils/ScaleUtils.cpp b/src/core/utils/ScaleUtils.cpp index d46ca0ea8e..82c6405e89 100644 --- a/src/core/utils/ScaleUtils.cpp +++ b/src/core/utils/ScaleUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020, 2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -21,8 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + #include "src/core/utils/ScaleUtils.h" -#include "arm_compute/core/Helpers.h" +#include "src/common/cpuinfo/CpuIsaInfo.h" + +#include "arm_compute/core/CPP/CPPTypes.h" +#include "arm_compute/core/TensorInfo.h" float arm_compute::scale_utils::calculate_resize_ratio(size_t input_size, size_t output_size, bool align_corners) { @@ -34,4 +38,14 @@ float arm_compute::scale_utils::calculate_resize_ratio(size_t input_size, size_t ARM_COMPUTE_ERROR_ON(out == 0); return static_cast<float>(in) / static_cast<float>(out); +} + +bool arm_compute::scale_utils::is_precomputation_required(DataLayout data_layout, DataType data_type, InterpolationPolicy policy) +{ + // whether to precompute indices & weights + // The Neon™ kernels (which are preferred over SVE when policy is BILINEAR) do not use + // precomputed index and weights when data type is FP32/16. + // If policy is nearest_neighbor for SVE, then precompute because it's being used + // To be revised in COMPMID-5453/5454 + return data_layout != DataLayout::NHWC || (data_type != DataType::F32 && data_type != DataType::F16) || (CPUInfo::get().get_isa().sve == true && policy == InterpolationPolicy::NEAREST_NEIGHBOR); }
\ No newline at end of file diff --git a/src/core/utils/ScaleUtils.h b/src/core/utils/ScaleUtils.h index 3cc986b1db..c09509253c 100644 --- a/src/core/utils/ScaleUtils.h +++ b/src/core/utils/ScaleUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020, 2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -53,6 +53,17 @@ inline bool is_align_corners_allowed_sampling_policy(SamplingPolicy sampling_pol { return sampling_policy != SamplingPolicy::CENTER; } + +/** Returns if precomputation of indices and/or weights is required or/not + * + * @param[in] data_layout Data layout + * @param[in] data_type Data type + * @param[in] policy Interpolation policy + * + * @return True if precomputation is required + */ +bool is_precomputation_required(DataLayout data_layout, DataType data_type, InterpolationPolicy policy); + } // namespace scale_utils } // namespace arm_compute #endif /* UTILS_CORE_SCALEUTILS_H */
\ No newline at end of file |