blob: c5856cae3d04ce8bcdfacfad45dbfbaa39103604 [file] [log] [blame]
giuros01c04a0e82018-10-03 12:44:35 +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/CLBoundingBoxTransform.h"
26#include "tests/CL/CLAccessor.h"
27#include "tests/CL/CLArrayAccessor.h"
28#include "tests/Globals.h"
29#include "tests/framework/Macros.h"
30#include "tests/framework/datasets/Datasets.h"
31#include "tests/validation/Validation.h"
32#include "tests/validation/fixtures/BoundingBoxTransformFixture.h"
33#include "utils/TypePrinter.h"
34
35namespace arm_compute
36{
37namespace test
38{
39namespace validation
40{
41namespace
42{
43RelativeTolerance<float> relative_tolerance_f32(0.01f);
44AbsoluteTolerance<float> absolute_tolerance_f32(0.001f);
45
46RelativeTolerance<half> relative_tolerance_f16(half(0.2));
47AbsoluteTolerance<float> absolute_tolerance_f16(half(0.02f));
48
49const auto BboxInfoDataset = framework::dataset::make("BboxInfo", { BoundingBoxTransformInfo(20U, 20U, 2U, true),
50 BoundingBoxTransformInfo(128U, 128U, 4U, true),
51 BoundingBoxTransformInfo(800U, 600U, 1U, false),
52 BoundingBoxTransformInfo(800U, 600U, 2U, true, { 1.0, 0.5, 1.5, 2.0 }),
giuros01d696cb62018-11-16 10:39:59 +000053 BoundingBoxTransformInfo(800U, 600U, 4U, false, { 1.0, 0.5, 1.5, 2.0 }),
54 BoundingBoxTransformInfo(800U, 600U, 4U, false, { 1.0, 0.5, 1.5, 2.0 }, true)
giuros01c04a0e82018-10-03 12:44:35 +010055 });
56
giuros01a6bc82f2018-10-25 12:28:26 +010057const auto DeltaDataset = framework::dataset::make("DeltasShape", { TensorShape(36U, 1U),
58 TensorShape(36U, 2U),
59 TensorShape(36U, 2U),
60 TensorShape(40U, 1U),
61 TensorShape(40U, 20U),
62 TensorShape(40U, 100U),
63 TensorShape(40U, 200U)
giuros01c04a0e82018-10-03 12:44:35 +010064 });
65
66} // namespace
67
68TEST_SUITE(CL)
69TEST_SUITE(BBoxTransform)
70
71// *INDENT-OFF*
72// clang-format off
73DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
74 framework::dataset::make("BoxesInfo", { TensorInfo(TensorShape(4U, 128U), 1, DataType::F32),
75 TensorInfo(TensorShape(5U, 128U), 1, DataType::F32), // Wrong number of box fields
76 TensorInfo(TensorShape(4U, 128U), 1, DataType::F16), // Wrong data type
77 TensorInfo(TensorShape(4U, 128U), 1, DataType::F32), // Wrong number of classes
giuros01d696cb62018-11-16 10:39:59 +000078 TensorInfo(TensorShape(4U, 128U), 1, DataType::F32), // Deltas and predicted boxes have different dimensions
79 TensorInfo(TensorShape(4U, 128U), 1, DataType::F32)}), // Scaling is zero
giuros01c04a0e82018-10-03 12:44:35 +010080 framework::dataset::make("PredBoxesInfo",{ TensorInfo(TensorShape(128U, 128U), 1, DataType::F32),
81 TensorInfo(TensorShape(128U, 128U), 1, DataType::F32),
82 TensorInfo(TensorShape(127U, 128U), 1, DataType::F32),
83 TensorInfo(TensorShape(128U, 100U), 1, DataType::F32),
giuros01d696cb62018-11-16 10:39:59 +000084 TensorInfo(TensorShape(128U, 100U), 1, DataType::F32),
85 TensorInfo(TensorShape(128U, 128U), 1, DataType::F32)})),
giuros01c04a0e82018-10-03 12:44:35 +010086 framework::dataset::make("DeltasInfo", { TensorInfo(TensorShape(128U, 128U), 1, DataType::F32),
87 TensorInfo(TensorShape(128U, 128U), 1, DataType::F32),
88 TensorInfo(TensorShape(127U, 128U), 1, DataType::F32),
89 TensorInfo(TensorShape(128U, 100U), 1, DataType::F32),
giuros01d696cb62018-11-16 10:39:59 +000090 TensorInfo(TensorShape(128U, 128U), 1, DataType::F32),
giuros01c04a0e82018-10-03 12:44:35 +010091 TensorInfo(TensorShape(128U, 128U), 1, DataType::F32)})),
92 framework::dataset::make("BoundingBoxTransofmInfo", { BoundingBoxTransformInfo(800.f, 600.f, 1.f),
93 BoundingBoxTransformInfo(800.f, 600.f, 1.f),
94 BoundingBoxTransformInfo(800.f, 600.f, 1.f),
giuros01d696cb62018-11-16 10:39:59 +000095 BoundingBoxTransformInfo(800.f, 600.f, 1.f),
96 BoundingBoxTransformInfo(800.f, 600.f, 0.f)})),
97 framework::dataset::make("Expected", { true, false, false, false, false, false})),
giuros01c04a0e82018-10-03 12:44:35 +010098 boxes_info, pred_boxes_info, deltas_info, bbox_info, expected)
99{
100 ARM_COMPUTE_EXPECT(bool(CLBoundingBoxTransform::validate(&boxes_info.clone()->set_is_resizable(true), &pred_boxes_info.clone()->set_is_resizable(true), &deltas_info.clone()->set_is_resizable(true), bbox_info)) == expected, framework::LogLevel::ERRORS);
101}
102// clang-format on
103// *INDENT-ON*
104
105template <typename T>
106using CLBoundingBoxTransformFixture = BoundingBoxTransformFixture<CLTensor, CLAccessor, CLBoundingBoxTransform, T>;
107
108TEST_SUITE(Float)
109TEST_SUITE(FP32)
110FIXTURE_DATA_TEST_CASE(BoundingBox, CLBoundingBoxTransformFixture<float>, framework::DatasetMode::ALL,
111 combine(combine(DeltaDataset, BboxInfoDataset), framework::dataset::make("DataType", { DataType::F32 })))
112{
113 // Validate output
114 validate(CLAccessor(_target), _reference, relative_tolerance_f32, 0.f, absolute_tolerance_f32);
115}
116TEST_SUITE_END() // FP32
117
118TEST_SUITE(FP16)
119FIXTURE_DATA_TEST_CASE(BoundingBox, CLBoundingBoxTransformFixture<half>, framework::DatasetMode::ALL,
120 combine(combine(DeltaDataset, BboxInfoDataset), framework::dataset::make("DataType", { DataType::F16 })))
121{
122 // Validate output
Michele Di Giorgiodd2619a2018-11-05 16:46:09 +0000123 validate(CLAccessor(_target), _reference, relative_tolerance_f16, 0.03f, absolute_tolerance_f16);
giuros01c04a0e82018-10-03 12:44:35 +0100124}
125TEST_SUITE_END() // FP16
126TEST_SUITE_END() // Float
127
128TEST_SUITE_END() // BBoxTransform
129TEST_SUITE_END() // CL
130} // namespace validation
131} // namespace test
132} // namespace arm_compute