aboutsummaryrefslogtreecommitdiff
path: root/tests/validation
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2018-09-20 17:40:04 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:55:19 +0000
commit7c9541ccd4c98d7e9a456ee67c3ceecce8531ffb (patch)
treeceddf6e932cc08b78d850a6d6f27ef695560afc5 /tests/validation
parentebf6b8a00b77ea796d877bc1d0e6850c055318a6 (diff)
downloadComputeLibrary-7c9541ccd4c98d7e9a456ee67c3ceecce8531ffb.tar.gz
COMPMID-1596 Create UpsampleLayer for NEON
Change-Id: I82d95c4f1c5fed13b213a2591cc2b4e0d0e02a54 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/149676 Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Reviewed-by: Pablo Tello <pablo.tello@arm.com> Tested-by: bsgcomp <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r--tests/validation/NEON/Upsample.cpp156
-rw-r--r--tests/validation/fixtures/UpsampleLayerFixture.h14
-rw-r--r--tests/validation/reference/UpsampleLayer.cpp12
-rw-r--r--tests/validation/reference/UpsampleLayer.h2
4 files changed, 171 insertions, 13 deletions
diff --git a/tests/validation/NEON/Upsample.cpp b/tests/validation/NEON/Upsample.cpp
new file mode 100644
index 0000000000..39b69ee1e3
--- /dev/null
+++ b/tests/validation/NEON/Upsample.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "arm_compute/core/Types.h"
+#include "arm_compute/runtime/NEON/functions/NEUpsampleLayer.h"
+#include "tests/NEON/Accessor.h"
+#include "tests/PaddingCalculator.h"
+#include "tests/datasets/ShapeDatasets.h"
+#include "tests/framework/Asserts.h"
+#include "tests/framework/Macros.h"
+#include "tests/framework/datasets/Datasets.h"
+#include "tests/validation/Validation.h"
+#include "tests/validation/fixtures/UpsampleLayerFixture.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+TEST_SUITE(NEON)
+TEST_SUITE(UpsampleLayer)
+
+DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, (combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))),
+ input_shape, data_type)
+{
+ InterpolationPolicy policy = InterpolationPolicy::NEAREST_NEIGHBOR;
+ Size2D info = Size2D(2, 2);
+
+ // Create tensors
+ Tensor src = create_tensor<Tensor>(input_shape, data_type, 1);
+ Tensor dst;
+
+ ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
+
+ // Create and configure function
+ NEUpsampleLayer upsample;
+ upsample.configure(&src, &dst, info, policy);
+
+ // Validate valid region
+ const ValidRegion src_valid_region = shape_to_valid_region(src.info()->tensor_shape());
+ const ValidRegion dst_valid_region = shape_to_valid_region(dst.info()->tensor_shape());
+
+ validate(src.info()->valid_region(), src_valid_region);
+ validate(dst.info()->valid_region(), dst_valid_region);
+}
+
+// *INDENT-OFF*
+// clang-format off
+DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
+ framework::dataset::make("InputInfo", { TensorInfo(TensorShape(10U, 10U, 2U), 1, DataType::F32), // Mismatching data type
+ TensorInfo(TensorShape(10U, 10U, 2U), 1, DataType::F32), // Invalid output shape
+ TensorInfo(TensorShape(10U, 10U, 2U), 1, DataType::F32), // Invalid stride
+ TensorInfo(TensorShape(10U, 10U, 2U), 1, DataType::F32), // Invalid policy
+ TensorInfo(TensorShape(32U, 32U), 1, DataType::F32),
+ }),
+ framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(20U, 20U, 2U), 1, DataType::F16),
+ TensorInfo(TensorShape(20U, 10U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(20U, 20U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(20U, 20U, 2U), 1, DataType::F32),
+ TensorInfo(TensorShape(64U, 64U), 1, DataType::F32),
+ })),
+ framework::dataset::make("PadInfo", { Size2D(2, 2),
+ Size2D(2, 2),
+ Size2D(1, 1),
+ Size2D(2, 2),
+ Size2D(2, 2),
+ })),
+ framework::dataset::make("UpsamplingPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR,
+ InterpolationPolicy::NEAREST_NEIGHBOR,
+ InterpolationPolicy::NEAREST_NEIGHBOR,
+ InterpolationPolicy::BILINEAR,
+ InterpolationPolicy::NEAREST_NEIGHBOR,
+ })),
+ framework::dataset::make("Expected", { false, false, false, false, true })),
+ input_info, output_info, pad_info, policy, expected)
+{
+ bool is_valid = bool(NEUpsampleLayer::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), pad_info, policy));
+ ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS);
+}
+// clang-format on
+// *INDENT-ON*
+
+template <typename T>
+using NEUpsampleLayerFixture = UpsampleLayerFixture<Tensor, Accessor, NEUpsampleLayer, T>;
+
+TEST_SUITE(Float)
+TEST_SUITE(FP32)
+FIXTURE_DATA_TEST_CASE(RunSmall, NEUpsampleLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
+ framework::dataset::make("DataType", DataType::F32)),
+ framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
+ framework::dataset::make("PadInfo", { Size2D(2, 2) })),
+ framework::dataset::make("UpsamplingPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR })))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+TEST_SUITE_END() // FP32
+
+#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
+TEST_SUITE(FP16)
+FIXTURE_DATA_TEST_CASE(RunSmall, NEUpsampleLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
+ framework::dataset::make("DataType",
+ DataType::F16)),
+ framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
+ framework::dataset::make("PadInfo", { Size2D(2, 2) })),
+ framework::dataset::make("UpsamplingPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR })))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+TEST_SUITE_END() // FP16
+#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
+TEST_SUITE_END() // Float
+
+TEST_SUITE(Quantized)
+TEST_SUITE(QASYMM8)
+FIXTURE_DATA_TEST_CASE(RunSmall, NEUpsampleLayerFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
+ framework::dataset::make("DataType", DataType::QASYMM8)),
+ framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })),
+ framework::dataset::make("PadInfo", { Size2D(2, 2) })),
+ framework::dataset::make("UpsamplingPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR })))
+{
+ // Validate output
+ validate(Accessor(_target), _reference);
+}
+TEST_SUITE_END() // Quantized
+TEST_SUITE_END() // QASYMM8
+
+TEST_SUITE_END() // UpsampleLayer
+TEST_SUITE_END() // NEON
+
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
diff --git a/tests/validation/fixtures/UpsampleLayerFixture.h b/tests/validation/fixtures/UpsampleLayerFixture.h
index 8fc3565e18..40229e2866 100644
--- a/tests/validation/fixtures/UpsampleLayerFixture.h
+++ b/tests/validation/fixtures/UpsampleLayerFixture.h
@@ -45,12 +45,12 @@ class UpsampleLayerFixture : public framework::Fixture
public:
template <typename...>
void setup(TensorShape input_shape, DataType data_type, DataLayout data_layout,
- Size2D info, const InterpolationPolicy &upsampling_policy)
+ Size2D info, const InterpolationPolicy &policy)
{
_data_type = data_type;
- _target = compute_target(input_shape, info, upsampling_policy, data_type, data_layout);
- _reference = compute_reference(input_shape, info, upsampling_policy, data_type);
+ _target = compute_target(input_shape, info, policy, data_type, data_layout);
+ _reference = compute_reference(input_shape, info, policy, data_type);
}
protected:
@@ -61,7 +61,7 @@ protected:
}
TensorType compute_target(TensorShape input_shape,
- const Size2D &info, const InterpolationPolicy &upsampling_policy, DataType data_type, DataLayout data_layout)
+ const Size2D &info, const InterpolationPolicy &policy, DataType data_type, DataLayout data_layout)
{
if(data_layout == DataLayout::NHWC)
{
@@ -74,7 +74,7 @@ protected:
// Create and configure function
FunctionType upsample;
- upsample.configure(&src, &dst, info, upsampling_policy);
+ upsample.configure(&src, &dst, info, policy);
ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
@@ -96,7 +96,7 @@ protected:
}
SimpleTensor<T> compute_reference(const TensorShape &input_shape,
- const Size2D &info, const InterpolationPolicy &upsampling_policy, DataType data_type)
+ const Size2D &info, const InterpolationPolicy &policy, DataType data_type)
{
// Create reference
SimpleTensor<T> src{ input_shape, data_type };
@@ -104,7 +104,7 @@ protected:
// Fill reference
fill(src, 0);
- return reference::upsample_layer<T>(src, info, upsampling_policy);
+ return reference::upsample_layer<T>(src, info, policy);
}
TensorType _target{};
diff --git a/tests/validation/reference/UpsampleLayer.cpp b/tests/validation/reference/UpsampleLayer.cpp
index 3a340d0905..876f6d794a 100644
--- a/tests/validation/reference/UpsampleLayer.cpp
+++ b/tests/validation/reference/UpsampleLayer.cpp
@@ -35,10 +35,10 @@ namespace reference
{
template <typename T>
SimpleTensor<T> upsample_layer(const SimpleTensor<T> &src,
- const Size2D &info, const InterpolationPolicy upsampling_policy)
+ const Size2D &info, const InterpolationPolicy policy)
{
- ARM_COMPUTE_ERROR_ON(upsampling_policy != InterpolationPolicy::NEAREST_NEIGHBOR);
- ARM_COMPUTE_UNUSED(upsampling_policy);
+ ARM_COMPUTE_ERROR_ON(policy != InterpolationPolicy::NEAREST_NEIGHBOR);
+ ARM_COMPUTE_UNUSED(policy);
TensorShape output_shape = src.shape();
output_shape.set(0, src.shape().x() * info.x());
@@ -77,9 +77,11 @@ SimpleTensor<T> upsample_layer(const SimpleTensor<T> &src,
}
template SimpleTensor<float> upsample_layer(const SimpleTensor<float> &src,
- const Size2D &info, const InterpolationPolicy upsampling_policy);
+ const Size2D &info, const InterpolationPolicy policy);
template SimpleTensor<half> upsample_layer(const SimpleTensor<half> &src,
- const Size2D &info, const InterpolationPolicy upsampling_policy);
+ const Size2D &info, const InterpolationPolicy policy);
+template SimpleTensor<uint8_t> upsample_layer(const SimpleTensor<uint8_t> &src,
+ const Size2D &info, const InterpolationPolicy policy);
} // namespace reference
} // namespace validation
} // namespace test
diff --git a/tests/validation/reference/UpsampleLayer.h b/tests/validation/reference/UpsampleLayer.h
index fc1da39186..ecb458a0c6 100644
--- a/tests/validation/reference/UpsampleLayer.h
+++ b/tests/validation/reference/UpsampleLayer.h
@@ -37,7 +37,7 @@ namespace reference
{
template <typename T>
SimpleTensor<T> upsample_layer(const SimpleTensor<T> &src,
- const Size2D &info, const InterpolationPolicy upsampling_policy);
+ const Size2D &info, const InterpolationPolicy policy);
} // namespace reference
} // namespace validation
} // namespace test