aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsabella Gottardi <isabella.gottardi@arm.com>2018-09-03 12:17:47 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:54:54 +0000
commit553b999ccc4233b163377e0a55e2377614899a3e (patch)
tree77ab94ad2acac7d484555007a40a11a252b53d56
parentaa6a04a56f21ab8de23b24c5f9ee7cafeaef8320 (diff)
downloadComputeLibrary-553b999ccc4233b163377e0a55e2377614899a3e.tar.gz
COMPMID-1517 - Add validate method to CLScale
Change-Id: I36b119f27c87e2ce3d82a46089a29e298509772c Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/146625 Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Giorgio Arena <giorgio.arena@arm.com>
-rw-r--r--arm_compute/runtime/CL/functions/CLScale.h17
-rw-r--r--src/runtime/CL/functions/CLScale.cpp6
-rw-r--r--tests/validation/CL/Scale.cpp51
3 files changed, 73 insertions, 1 deletions
diff --git a/arm_compute/runtime/CL/functions/CLScale.h b/arm_compute/runtime/CL/functions/CLScale.h
index 68d64a9e21..c4b8a2aada 100644
--- a/arm_compute/runtime/CL/functions/CLScale.h
+++ b/arm_compute/runtime/CL/functions/CLScale.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017 ARM Limited.
+ * Copyright (c) 2016-2018 ARM Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -49,6 +49,21 @@ public:
*/
void configure(ICLTensor *input, ICLTensor *output, InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value = PixelValue(),
SamplingPolicy sampling_policy = SamplingPolicy::CENTER);
+
+ /** Static function to check if given info will lead to a valid configuration of @ref CLScale
+ *
+ * @param[in] input Source tensor info. Data types supported: U8/S16/F16/F32.
+ * @param[in] output Output tensor info. Data type supported: Same as @p input
+ * All but the lowest two dimensions must be the same size as in the input tensor, i.e. scaling is only performed within the XY-plane.
+ * @param[in] policy The interpolation type.
+ * @param[in] border_mode Strategy to use for borders.
+ * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT.
+ * @param[in] sampling_policy (Optional) Sampling policy used by the interpolation. Defaults to @ref SamplingPolicy::CENTER
+ *
+ * @return a status
+ */
+ static Status validate(const ITensorInfo *input, const ITensorInfo *output, InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value = PixelValue(),
+ SamplingPolicy sampling_policy = SamplingPolicy::CENTER);
};
}
#endif /*__ARM_COMPUTE_CLSCALE_H__ */
diff --git a/src/runtime/CL/functions/CLScale.cpp b/src/runtime/CL/functions/CLScale.cpp
index 4ff9763397..f204e644a6 100644
--- a/src/runtime/CL/functions/CLScale.cpp
+++ b/src/runtime/CL/functions/CLScale.cpp
@@ -50,3 +50,9 @@ void CLScale::configure(ICLTensor *input, ICLTensor *output, InterpolationPolicy
}
_border_handler.configure(input, _kernel->border_size(), border_mode, constant_border_value);
}
+
+Status CLScale::validate(const ITensorInfo *input, const ITensorInfo *output, InterpolationPolicy policy, BorderMode border_mode, PixelValue constant_border_value, SamplingPolicy sampling_policy)
+{
+ ARM_COMPUTE_UNUSED(constant_border_value);
+ return CLScaleKernel::validate(input, output, policy, border_mode, sampling_policy);
+}
diff --git a/tests/validation/CL/Scale.cpp b/tests/validation/CL/Scale.cpp
index ddc93d045f..92d4f96c6a 100644
--- a/tests/validation/CL/Scale.cpp
+++ b/tests/validation/CL/Scale.cpp
@@ -69,6 +69,57 @@ constexpr float tolerance_num_f32(0.01f);
TEST_SUITE(CL)
TEST_SUITE(Scale)
+// *INDENT-OFF*
+// clang-format off
+
+DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
+ framework::dataset::make("InputInfo",{ TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F16),
+ TensorInfo(TensorShape(28U, 32U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(36U, 36U, 2U, 4U), 1, DataType::U8),
+ TensorInfo(TensorShape(40U, 35U, 2U, 4U), 1, DataType::S16),
+ TensorInfo(TensorShape(37U, 37U, 2U), 1, DataType::F32), // window shrink
+ TensorInfo(TensorShape(128U, 64U, 1U, 3U), 1, DataType::QASYMM8), // not supported
+ TensorInfo(TensorShape(37U, 37U, 3U, 4U), 1, DataType::F32), // mismatching datatype
+ TensorInfo(TensorShape(28U, 33U, 2U), 1, DataType::F32), // policy area, scale factor not correct
+ }),
+ framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 68U, 2U), 1, DataType::F16),
+ TensorInfo(TensorShape(40U, 56U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(40U, 76U, 2U, 4U), 1, DataType::U8),
+ TensorInfo(TensorShape(28U, 32U, 2U, 4U), 1, DataType::S16),
+ TensorInfo(TensorShape(39U, 55U, 2U), 1, DataType::F32), // window shrink
+ TensorInfo(TensorShape(137U, 134U, 1U, 3U), 1, DataType::QASYMM8), // not supported
+ TensorInfo(TensorShape(39U, 77U, 3U, 4U), 1, DataType::F16), // mismatching datatype
+ TensorInfo(TensorShape(26U, 21U, 2U), 1, DataType::F32), // policy area, scale factor not correct
+ })),
+ framework::dataset::make("Policy",{ InterpolationPolicy::BILINEAR,
+ InterpolationPolicy::BILINEAR,
+ InterpolationPolicy::NEAREST_NEIGHBOR,
+ InterpolationPolicy::NEAREST_NEIGHBOR,
+ InterpolationPolicy::NEAREST_NEIGHBOR,
+ InterpolationPolicy::BILINEAR,
+ InterpolationPolicy::BILINEAR,
+ InterpolationPolicy::AREA,
+ })),
+ framework::dataset::make("BorderMode",{ BorderMode::UNDEFINED,
+ BorderMode::UNDEFINED,
+ BorderMode::UNDEFINED,
+ BorderMode::UNDEFINED,
+ BorderMode::UNDEFINED,
+ BorderMode::UNDEFINED,
+ BorderMode::UNDEFINED,
+ BorderMode::UNDEFINED,
+ })),
+ framework::dataset::make("Expected", { true, true, true, true, false, false, false, false })),
+input_info, output_info, policy, border_mode, expected)
+{
+ Status status = CLScale::validate(&input_info.clone()->set_is_resizable(false),
+ &output_info.clone()->set_is_resizable(false), policy, border_mode);
+ ARM_COMPUTE_EXPECT(bool(status) == expected, framework::LogLevel::ERRORS);
+}
+
+// clang-format on
+// *INDENT-ON*
+
DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(combine(concat(datasets::MediumShapes(), datasets::LargeShapes()), ScaleDataTypes),
framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })),
datasets::BorderModes()),