blob: f3fc3818f22f59f93e9c31820da59fffb820eccb [file] [log] [blame]
giuros0118870812018-09-13 09:31:40 +01001/*
2 * Copyright (c) 2018 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/runtime/CL/CLScheduler.h"
25#include "arm_compute/runtime/CL/functions/CLROIAlignLayer.h"
26#include "tests/CL/CLAccessor.h"
giuros0118870812018-09-13 09:31:40 +010027#include "tests/Globals.h"
Manuel Bottini60f0a412018-10-24 17:27:02 +010028#include "tests/datasets/ROIAlignLayerDataset.h"
giuros0118870812018-09-13 09:31:40 +010029#include "tests/datasets/ShapeDatasets.h"
30#include "tests/framework/Macros.h"
31#include "tests/framework/datasets/Datasets.h"
32#include "tests/validation/Validation.h"
33#include "tests/validation/fixtures/ROIAlignLayerFixture.h"
34#include "utils/TypePrinter.h"
35
36namespace arm_compute
37{
38namespace test
39{
40namespace validation
41{
42namespace
43{
44RelativeTolerance<float> relative_tolerance_f32(0.01f);
Manuel Bottini60f0a412018-10-24 17:27:02 +010045AbsoluteTolerance<float> absolute_tolerance_f32(0.001f);
46
47RelativeTolerance<float> relative_tolerance_f16(0.01f);
48AbsoluteTolerance<float> absolute_tolerance_f16(0.001f);
giuros0118870812018-09-13 09:31:40 +010049} // namespace
50
51TEST_SUITE(CL)
52TEST_SUITE(RoiAlign)
53
54// *INDENT-OFF*
55// clang-format off
56DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
57 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32),
Manuel Bottini60f0a412018-10-24 17:27:02 +010058 TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching data type input/rois
giuros0118870812018-09-13 09:31:40 +010059 TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching data type input/output
60 TensorInfo(TensorShape(250U, 128U, 2U), 1, DataType::F32), // Mismatching depth size input/output
61 TensorInfo(TensorShape(250U, 128U, 2U), 1, DataType::F32), // Mismatching number of rois and output batch size
Manuel Bottini60f0a412018-10-24 17:27:02 +010062 TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Invalid number of values per ROIS
giuros0118870812018-09-13 09:31:40 +010063 TensorInfo(TensorShape(250U, 128U, 2U), 1, DataType::F32), // Mismatching height and width input/output
64
65 }),
Manuel Bottini60f0a412018-10-24 17:27:02 +010066 framework::dataset::make("RoisInfo", { TensorInfo(TensorShape(5, 3U), 1, DataType::F32),
67 TensorInfo(TensorShape(5, 3U), 1, DataType::F16),
68 TensorInfo(TensorShape(5, 3U), 1, DataType::F32),
69 TensorInfo(TensorShape(5, 4U), 1, DataType::F32),
70 TensorInfo(TensorShape(5, 10U), 1, DataType::F32),
71 TensorInfo(TensorShape(4, 3U), 1, DataType::F32),
72 TensorInfo(TensorShape(5, 4U), 1, DataType::F32),
73 })),
giuros0118870812018-09-13 09:31:40 +010074 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(7U, 7U, 3U, 3U), 1, DataType::F32),
Manuel Bottini60f0a412018-10-24 17:27:02 +010075 TensorInfo(TensorShape(7U, 7U, 3U, 3U), 1, DataType::F32),
giuros0118870812018-09-13 09:31:40 +010076 TensorInfo(TensorShape(7U, 7U, 3U, 3U), 1, DataType::F16),
77 TensorInfo(TensorShape(7U, 7U, 4U, 3U), 1, DataType::F32),
78 TensorInfo(TensorShape(7U, 7U, 2U, 3U), 1, DataType::F32),
Manuel Bottini60f0a412018-10-24 17:27:02 +010079 TensorInfo(TensorShape(7U, 7U, 3U, 3U), 1, DataType::F32),
giuros0118870812018-09-13 09:31:40 +010080 TensorInfo(TensorShape(5U, 5U, 2U, 4U), 1, DataType::F32),
81 })),
82 framework::dataset::make("PoolInfo", { ROIPoolingLayerInfo(7U, 7U, 1./8),
83 ROIPoolingLayerInfo(7U, 7U, 1./8),
84 ROIPoolingLayerInfo(7U, 7U, 1./8),
85 ROIPoolingLayerInfo(7U, 7U, 1./8),
86 ROIPoolingLayerInfo(7U, 7U, 1./8),
Manuel Bottini60f0a412018-10-24 17:27:02 +010087 ROIPoolingLayerInfo(7U, 7U, 1./8),
88 ROIPoolingLayerInfo(7U, 7U, 1./8),
giuros0118870812018-09-13 09:31:40 +010089 })),
Manuel Bottini60f0a412018-10-24 17:27:02 +010090 framework::dataset::make("Expected", { true, false, false, false, false, false, false })),
91 input_info, rois_info, output_info, pool_info, expected)
giuros0118870812018-09-13 09:31:40 +010092{
Manuel Bottini60f0a412018-10-24 17:27:02 +010093 ARM_COMPUTE_EXPECT(bool(CLROIAlignLayer::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);
giuros0118870812018-09-13 09:31:40 +010094}
95// clang-format on
96// *INDENT-ON*
97
98template <typename T>
Manuel Bottini60f0a412018-10-24 17:27:02 +010099using CLROIAlignLayerFixture = ROIAlignLayerFixture<CLTensor, CLAccessor, CLROIAlignLayer, T>;
giuros0118870812018-09-13 09:31:40 +0100100
101TEST_SUITE(Float)
Manuel Bottini60f0a412018-10-24 17:27:02 +0100102FIXTURE_DATA_TEST_CASE(SmallROIAlignLayerFloat, CLROIAlignLayerFixture<float>, framework::DatasetMode::ALL,
103 framework::dataset::combine(datasets::SmallROIAlignLayerDataset(),
104 framework::dataset::make("DataType", { DataType::F32 })))
giuros0118870812018-09-13 09:31:40 +0100105{
106 // Validate output
giuros01eddff5a2018-10-05 14:48:58 +0100107 validate(CLAccessor(_target), _reference, relative_tolerance_f32, .02f, absolute_tolerance_f32);
giuros0118870812018-09-13 09:31:40 +0100108}
Manuel Bottini60f0a412018-10-24 17:27:02 +0100109FIXTURE_DATA_TEST_CASE(SmallROIAlignLayerHalf, CLROIAlignLayerFixture<half>, framework::DatasetMode::ALL,
110 framework::dataset::combine(datasets::SmallROIAlignLayerDataset(),
111 framework::dataset::make("DataType", { DataType::F16 })))
112{
113 // Validate output
114 validate(CLAccessor(_target), _reference, relative_tolerance_f16, .02f, absolute_tolerance_f16);
115}
giuros0118870812018-09-13 09:31:40 +0100116TEST_SUITE_END() // Float
117
118TEST_SUITE_END() // RoiAlign
119TEST_SUITE_END() // CL
120} // namespace validation
121} // namespace test
122} // namespace arm_compute