diff options
author | Gunes Bayir <gunes.bayir@arm.com> | 2022-09-11 15:59:19 +0100 |
---|---|---|
committer | Gunes Bayir <gunes.bayir@arm.com> | 2022-09-16 12:38:59 +0000 |
commit | c4f2743951473f8d97f5a43767fdbb31a4df967c (patch) | |
tree | 26c49b1af8113bb169931f3af5e502904d455a25 /src/core/utils | |
parent | 0d05b6690fe69c57f63ca43d59b551f074613062 (diff) | |
download | ComputeLibrary-c4f2743951473f8d97f5a43767fdbb31a4df967c.tar.gz |
Optimize Quantized/Integer Bilinear Scale for Neon™
This patch introduces several performance optimizations regarding the Bilinear Scale operator with REPLICATE Border mode. Changes apply only to NHWC.
This patch
- Reduces the memory footprint by disabling precomputation of indices and weights when they're not used
- Rewrites the kernels for QASYMM8/QASYMM8_SIGNED/U8(Uint8)
- Adds S8(Int8) Bilinear Scale for Border mode REPLICATE
- Removes Bilinear Scale SVE kernels for Quantized and Integer types and adjust the heuristics to choose the Neon™ implementation
- Adds new test cases where the input and output of the Bilinear Scale operator have different quantization scale and offset
Resolves: COMPMID-5453, COMPMID-5454
Change-Id: I3d251e76e0c6978fd5a0a1795ec62ab536bec93c
Signed-off-by: Gunes Bayir <gunes.bayir@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8250
Reviewed-by: SiCong Li <sicong.li@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/utils')
-rw-r--r-- | src/core/utils/ScaleUtils.cpp | 28 | ||||
-rw-r--r-- | src/core/utils/ScaleUtils.h | 6 |
2 files changed, 23 insertions, 11 deletions
diff --git a/src/core/utils/ScaleUtils.cpp b/src/core/utils/ScaleUtils.cpp index 82c6405e89..ee57a8e7a7 100644 --- a/src/core/utils/ScaleUtils.cpp +++ b/src/core/utils/ScaleUtils.cpp @@ -40,12 +40,26 @@ float arm_compute::scale_utils::calculate_resize_ratio(size_t input_size, size_t 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) +bool arm_compute::scale_utils::is_precomputation_required(DataLayout data_layout, DataType data_type, + InterpolationPolicy policy, BorderMode border_mode) { - // 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); + // Do not calculate precomputed weights and indices if kernel code doesn't use them + if(data_layout == DataLayout::NHWC) + { + switch(data_type) + { + case DataType::F32: + case DataType::F16: + return (CPUInfo::get().get_isa().sve == true && policy == InterpolationPolicy::NEAREST_NEIGHBOR); + case DataType::U8: + case DataType::S8: + case DataType::QASYMM8: + case DataType::QASYMM8_SIGNED: + return (border_mode != BorderMode::REPLICATE) || (policy == InterpolationPolicy::NEAREST_NEIGHBOR); + default: + return true; + } + } + + return true; }
\ No newline at end of file diff --git a/src/core/utils/ScaleUtils.h b/src/core/utils/ScaleUtils.h index c09509253c..1484824a7f 100644 --- a/src/core/utils/ScaleUtils.h +++ b/src/core/utils/ScaleUtils.h @@ -26,9 +26,6 @@ #include "arm_compute/core/Types.h" -#include <cstdint> -#include <cstdlib> - namespace arm_compute { namespace scale_utils @@ -59,10 +56,11 @@ inline bool is_align_corners_allowed_sampling_policy(SamplingPolicy sampling_pol * @param[in] data_layout Data layout * @param[in] data_type Data type * @param[in] policy Interpolation policy + * @param[in] border_mode Border Mode * * @return True if precomputation is required */ -bool is_precomputation_required(DataLayout data_layout, DataType data_type, InterpolationPolicy policy); +bool is_precomputation_required(DataLayout data_layout, DataType data_type, InterpolationPolicy policy, BorderMode border_mode); } // namespace scale_utils } // namespace arm_compute |