blob: 853ef6558d9594e8441dbda7985d0c2fc52e0291 [file] [log] [blame]
Pablo Tellod75f9e92019-08-23 16:26:26 +01001/*
2 * Copyright (c) 2019 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/Types.h"
25
26#include "arm_compute/runtime/NEON/functions/NEROIAlignLayer.h"
27#include "arm_compute/runtime/Tensor.h"
28#include "arm_compute/runtime/TensorAllocator.h"
29#include "tests/Globals.h"
30#include "tests/NEON/Accessor.h"
31#include "tests/datasets/ROIDataset.h"
32#include "tests/datasets/ShapeDatasets.h"
33#include "tests/framework/Macros.h"
34#include "tests/framework/datasets/Datasets.h"
35#include "tests/validation/Validation.h"
36#include "tests/validation/fixtures/ROIAlignLayerFixture.h"
37#include "utils/TypePrinter.h"
38
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
45namespace
46{
47RelativeTolerance<float> relative_tolerance_f32(0.01f);
48AbsoluteTolerance<float> absolute_tolerance_f32(0.001f);
49
50#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
51RelativeTolerance<float> relative_tolerance_f16(0.01f);
52AbsoluteTolerance<float> absolute_tolerance_f16(0.001f);
53#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
54
55} // namespace
56
57TEST_SUITE(NEON)
58TEST_SUITE(RoiAlign)
59
60// *INDENT-OFF*
61// clang-format off
62DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
63 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32),
64 TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching data type input/rois
65 TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching data type input/output
66 TensorInfo(TensorShape(250U, 128U, 2U), 1, DataType::F32), // Mismatching depth size input/output
67 TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching number of rois and output batch size
68 TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Invalid number of values per ROIS
69 TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching height and width input/output
70
71 }),
72 framework::dataset::make("RoisInfo", { TensorInfo(TensorShape(5, 4U), 1, DataType::F32),
73 TensorInfo(TensorShape(5, 4U), 1, DataType::F16),
74 TensorInfo(TensorShape(5, 4U), 1, DataType::F32),
75 TensorInfo(TensorShape(5, 4U), 1, DataType::F32),
76 TensorInfo(TensorShape(5, 10U), 1, DataType::F32),
77 TensorInfo(TensorShape(4, 4U), 1, DataType::F32),
78 TensorInfo(TensorShape(5, 4U), 1, DataType::F32),
79 })),
80 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F32),
81 TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F32),
82 TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F16),
83 TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F32),
84 TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F32),
85 TensorInfo(TensorShape(7U, 7U, 3U, 4U), 1, DataType::F32),
86 TensorInfo(TensorShape(5U, 5U, 3U, 4U), 1, DataType::F32),
87 })),
88 framework::dataset::make("PoolInfo", { ROIPoolingLayerInfo(7U, 7U, 1./8),
89 ROIPoolingLayerInfo(7U, 7U, 1./8),
90 ROIPoolingLayerInfo(7U, 7U, 1./8),
91 ROIPoolingLayerInfo(7U, 7U, 1./8),
92 ROIPoolingLayerInfo(7U, 7U, 1./8),
93 ROIPoolingLayerInfo(7U, 7U, 1./8),
94 ROIPoolingLayerInfo(7U, 7U, 1./8),
95 })),
96 framework::dataset::make("Expected", { true, false, false, false, false, false, false })),
97 input_info, rois_info, output_info, pool_info, expected)
98{
99 ARM_COMPUTE_EXPECT(bool(NEROIAlignLayer::validate(&input_info.clone()->set_is_resizable(true), &rois_info.clone()->set_is_resizable(true), &output_info.clone()->set_is_resizable(true), pool_info)) == expected, framework::LogLevel::ERRORS);
100}
101
102// clang-format on
103// *INDENT-ON*
104
105template <typename T>
106using NEROIAlignLayerFixture = ROIAlignLayerFixture<Tensor, Accessor, NEROIAlignLayer, T>;
107
108TEST_SUITE(Float)
109FIXTURE_DATA_TEST_CASE(SmallROIAlignLayerFloat, NEROIAlignLayerFixture<float>, framework::DatasetMode::ALL,
110 framework::dataset::combine(framework::dataset::combine(datasets::SmallROIDataset(),
111 framework::dataset::make("DataType", { DataType::F32 })),
112 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
113{
114 // Validate output
115 validate(Accessor(_target), _reference, relative_tolerance_f32, .02f, absolute_tolerance_f32);
116}
117#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
118FIXTURE_DATA_TEST_CASE(SmallROIAlignLayerHalf, NEROIAlignLayerFixture<half>, framework::DatasetMode::ALL,
119 framework::dataset::combine(framework::dataset::combine(datasets::SmallROIDataset(),
120 framework::dataset::make("DataType", { DataType::F16 })),
121 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
122{
123 // Validate output
124 validate(Accessor(_target), _reference, relative_tolerance_f16, .02f, absolute_tolerance_f16);
125}
126#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
127
128TEST_SUITE_END() // Float
129
130TEST_SUITE_END() // RoiAlign
131TEST_SUITE_END() // NEON
132} // namespace validation
133} // namespace test
134} // namespace arm_compute