aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/NEON/functions
diff options
context:
space:
mode:
authorGunes Bayir <gunes.bayir@arm.com>2022-09-04 21:00:10 +0100
committerGunes Bayir <gunes.bayir@arm.com>2022-09-09 09:29:43 +0000
commit0eed305680ade0c48d07f592c4c4a8aaaad077b7 (patch)
treeec4aa5c2e66135d377b5a34f5cf03f97462424c0 /src/runtime/NEON/functions
parentd11de9861e6c32fa389f503e037098f50ffed156 (diff)
downloadComputeLibrary-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/runtime/NEON/functions')
-rw-r--r--src/runtime/NEON/functions/NEScale.cpp58
1 files changed, 35 insertions, 23 deletions
diff --git a/src/runtime/NEON/functions/NEScale.cpp b/src/runtime/NEON/functions/NEScale.cpp
index 9f48e78a5a..74ab860d91 100644
--- a/src/runtime/NEON/functions/NEScale.cpp
+++ b/src/runtime/NEON/functions/NEScale.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016-2021 Arm Limited.
+ * Copyright (c) 2016-2022 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -75,34 +75,46 @@ void NEScale::configure(ITensor *input, ITensor *output, const ScaleKernelInfo &
TensorShape shape(output->info()->dimension(idx_width));
shape.set(1, output->info()->dimension(idx_height), false);
- const TensorInfo tensor_info_dxdy(shape, Format::F32);
- const TensorInfo tensor_info_offsets(shape, Format::S32);
+ bool precompute_indices_weights = arm_compute::scale_utils::is_precomputation_required(data_layout, input->info()->data_type(), policy_to_use);
- _impl->dx.allocator()->init(tensor_info_dxdy);
- _impl->dy.allocator()->init(tensor_info_dxdy);
- _impl->offsets.allocator()->init(tensor_info_offsets);
- switch(policy_to_use)
+ if(precompute_indices_weights == true)
{
- case InterpolationPolicy::NEAREST_NEIGHBOR:
- {
- // Allocate once the configure methods have been called
- _impl->offsets.allocator()->allocate();
- break;
- }
- case InterpolationPolicy::BILINEAR:
+ const TensorInfo tensor_info_dxdy(shape, Format::F32);
+ const TensorInfo tensor_info_offsets(shape, Format::S32);
+
+ _impl->dx.allocator()->init(tensor_info_dxdy);
+ _impl->dy.allocator()->init(tensor_info_dxdy);
+ _impl->offsets.allocator()->init(tensor_info_offsets);
+ switch(policy_to_use)
{
- // Allocate once the configure methods have been called
- _impl->dx.allocator()->allocate();
- _impl->dy.allocator()->allocate();
- _impl->offsets.allocator()->allocate();
- break;
+ case InterpolationPolicy::NEAREST_NEIGHBOR:
+ {
+ // Allocate once the configure methods have been called
+ _impl->offsets.allocator()->allocate();
+ break;
+ }
+ case InterpolationPolicy::BILINEAR:
+ {
+ // Allocate once the configure methods have been called
+ _impl->dx.allocator()->allocate();
+ _impl->dy.allocator()->allocate();
+ _impl->offsets.allocator()->allocate();
+ 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");
+ }
}
}