aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/NEON/functions/NEScale.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2018-05-14 16:05:23 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:52:35 +0000
commit20b4313365ea2ed31f59fd757f68f791f076e6bc (patch)
tree5e283e2a50da5a2ea0ec0b822d2617290cdac520 /src/runtime/NEON/functions/NEScale.cpp
parent4d1e8a2083a9b82514019b58bebd1f0cb15aa3df (diff)
downloadComputeLibrary-20b4313365ea2ed31f59fd757f68f791f076e6bc.tar.gz
COMPMID-814: Add validate method to scale.
Change-Id: I5004c79ac7b10f988f25e14847f1ea2be01629da Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/131143 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/runtime/NEON/functions/NEScale.cpp')
-rw-r--r--src/runtime/NEON/functions/NEScale.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/src/runtime/NEON/functions/NEScale.cpp b/src/runtime/NEON/functions/NEScale.cpp
index 43ef6199ba..9407273c1f 100644
--- a/src/runtime/NEON/functions/NEScale.cpp
+++ b/src/runtime/NEON/functions/NEScale.cpp
@@ -45,7 +45,6 @@ namespace
void precompute_dx_dy_offsets(ITensor *dx, ITensor *dy, ITensor *offsets, float wr, float hr, size_t input_element_size, SamplingPolicy sampling_policy)
{
ARM_COMPUTE_ERROR_ON(nullptr == offsets);
- ARM_COMPUTE_ERROR_ON(sampling_policy != SamplingPolicy::CENTER);
ARM_COMPUTE_UNUSED(sampling_policy);
Window win;
@@ -99,8 +98,8 @@ NEScale::NEScale() // NOLINT
void NEScale::configure(ITensor *input, ITensor *output, InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value, SamplingPolicy sampling_policy)
{
- ARM_COMPUTE_ERROR_ON(nullptr == input);
- ARM_COMPUTE_ERROR_ON(nullptr == output);
+ ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
+ ARM_COMPUTE_ERROR_THROW_ON(NEScale::validate(input->info(), output->info(), policy, border_mode, constant_border_value, sampling_policy));
// Get data layout and width/height indices
const DataLayout data_layout = input->info()->data_layout();
@@ -171,6 +170,48 @@ void NEScale::configure(ITensor *input, ITensor *output, InterpolationPolicy pol
_border_handler.configure(input, _scale_kernel.border_size(), border_mode, PixelValue(constant_border_value));
}
+Status NEScale::validate(const ITensorInfo *input, const ITensorInfo *output, InterpolationPolicy policy,
+ BorderMode border_mode, PixelValue constant_border_value, SamplingPolicy sampling_policy)
+{
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON(sampling_policy != SamplingPolicy::CENTER);
+ ARM_COMPUTE_UNUSED(border_mode, constant_border_value);
+
+ ITensorInfo *offsets = nullptr;
+ ITensorInfo *dx = nullptr;
+ ITensorInfo *dy = nullptr;
+
+ // Get data layout and width/height indices
+ const DataLayout data_layout = input->data_layout();
+ const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
+ const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
+
+ // Get the tensor shape of auxilary buffers
+ const TensorShape shape(output->dimension(idx_width), output->dimension(idx_height));
+
+ TensorInfo tensor_info_offsets(shape, Format::S32);
+ TensorInfo tensor_info_dx(shape, Format::F32);
+ TensorInfo tensor_info_dy(shape, Format::F32);
+
+ switch(policy)
+ {
+ case InterpolationPolicy::NEAREST_NEIGHBOR:
+ offsets = &tensor_info_offsets;
+ break;
+ case InterpolationPolicy::BILINEAR:
+ offsets = &tensor_info_offsets;
+ dx = &tensor_info_dx;
+ dy = &tensor_info_dy;
+ break;
+ default:
+ break;
+ }
+
+ ARM_COMPUTE_RETURN_ON_ERROR(NEScaleKernel::validate(input->clone().get(), dx, dy, offsets, output->clone().get(),
+ policy, border_mode, sampling_policy));
+ return Status{};
+}
+
void NEScale::run()
{
NEScheduler::get().schedule(&_border_handler, Window::DimZ);