giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 1 | /* |
Georgios Pinitas | d57891a | 2019-02-19 18:10:03 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 ARM Limited. |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 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 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace test |
| 38 | { |
| 39 | namespace validation |
| 40 | { |
| 41 | namespace |
| 42 | { |
| 43 | RelativeTolerance<float> relative_tolerance_f32(0.01f); |
| 44 | AbsoluteTolerance<float> absolute_tolerance_f32(0.001f); |
| 45 | |
| 46 | RelativeTolerance<half> relative_tolerance_f16(half(0.2)); |
| 47 | AbsoluteTolerance<float> absolute_tolerance_f16(half(0.02f)); |
| 48 | |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 49 | constexpr AbsoluteTolerance<uint16_t> tolerance_qasymm16(1); |
| 50 | |
Georgios Pinitas | d57891a | 2019-02-19 18:10:03 +0000 | [diff] [blame] | 51 | // *INDENT-OFF* |
| 52 | // clang-format off |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 53 | const auto BboxInfoDataset = framework::dataset::make("BboxInfo", { BoundingBoxTransformInfo(20U, 20U, 2U, true), |
| 54 | BoundingBoxTransformInfo(128U, 128U, 4U, true), |
| 55 | BoundingBoxTransformInfo(800U, 600U, 1U, false), |
Georgios Pinitas | d57891a | 2019-02-19 18:10:03 +0000 | [diff] [blame] | 56 | BoundingBoxTransformInfo(800U, 600U, 2U, true, { { 1.0, 0.5, 1.5, 2.0 } }), |
| 57 | BoundingBoxTransformInfo(800U, 600U, 4U, false, { { 1.0, 0.5, 1.5, 2.0 } }), |
| 58 | BoundingBoxTransformInfo(800U, 600U, 4U, false, { { 1.0, 0.5, 1.5, 2.0 } }, true) |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 59 | }); |
| 60 | |
giuros01 | a6bc82f | 2018-10-25 12:28:26 +0100 | [diff] [blame] | 61 | const auto DeltaDataset = framework::dataset::make("DeltasShape", { TensorShape(36U, 1U), |
| 62 | TensorShape(36U, 2U), |
| 63 | TensorShape(36U, 2U), |
| 64 | TensorShape(40U, 1U), |
| 65 | TensorShape(40U, 20U), |
| 66 | TensorShape(40U, 100U), |
| 67 | TensorShape(40U, 200U) |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 68 | }); |
Georgios Pinitas | d57891a | 2019-02-19 18:10:03 +0000 | [diff] [blame] | 69 | // clang-format on |
| 70 | // *INDENT-ON* |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 71 | } // namespace |
| 72 | |
| 73 | TEST_SUITE(CL) |
| 74 | TEST_SUITE(BBoxTransform) |
| 75 | |
| 76 | // *INDENT-OFF* |
| 77 | // clang-format off |
| 78 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( |
| 79 | framework::dataset::make("BoxesInfo", { TensorInfo(TensorShape(4U, 128U), 1, DataType::F32), |
| 80 | TensorInfo(TensorShape(5U, 128U), 1, DataType::F32), // Wrong number of box fields |
| 81 | TensorInfo(TensorShape(4U, 128U), 1, DataType::F16), // Wrong data type |
| 82 | TensorInfo(TensorShape(4U, 128U), 1, DataType::F32), // Wrong number of classes |
giuros01 | d696cb6 | 2018-11-16 10:39:59 +0000 | [diff] [blame] | 83 | TensorInfo(TensorShape(4U, 128U), 1, DataType::F32), // Deltas and predicted boxes have different dimensions |
| 84 | TensorInfo(TensorShape(4U, 128U), 1, DataType::F32)}), // Scaling is zero |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 85 | framework::dataset::make("PredBoxesInfo",{ TensorInfo(TensorShape(128U, 128U), 1, DataType::F32), |
| 86 | TensorInfo(TensorShape(128U, 128U), 1, DataType::F32), |
| 87 | TensorInfo(TensorShape(127U, 128U), 1, DataType::F32), |
| 88 | TensorInfo(TensorShape(128U, 100U), 1, DataType::F32), |
giuros01 | d696cb6 | 2018-11-16 10:39:59 +0000 | [diff] [blame] | 89 | TensorInfo(TensorShape(128U, 100U), 1, DataType::F32), |
| 90 | TensorInfo(TensorShape(128U, 128U), 1, DataType::F32)})), |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 91 | framework::dataset::make("DeltasInfo", { TensorInfo(TensorShape(128U, 128U), 1, DataType::F32), |
| 92 | TensorInfo(TensorShape(128U, 128U), 1, DataType::F32), |
| 93 | TensorInfo(TensorShape(127U, 128U), 1, DataType::F32), |
| 94 | TensorInfo(TensorShape(128U, 100U), 1, DataType::F32), |
giuros01 | d696cb6 | 2018-11-16 10:39:59 +0000 | [diff] [blame] | 95 | TensorInfo(TensorShape(128U, 128U), 1, DataType::F32), |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 96 | TensorInfo(TensorShape(128U, 128U), 1, DataType::F32)})), |
| 97 | framework::dataset::make("BoundingBoxTransofmInfo", { BoundingBoxTransformInfo(800.f, 600.f, 1.f), |
| 98 | BoundingBoxTransformInfo(800.f, 600.f, 1.f), |
| 99 | BoundingBoxTransformInfo(800.f, 600.f, 1.f), |
giuros01 | d696cb6 | 2018-11-16 10:39:59 +0000 | [diff] [blame] | 100 | BoundingBoxTransformInfo(800.f, 600.f, 1.f), |
| 101 | BoundingBoxTransformInfo(800.f, 600.f, 0.f)})), |
| 102 | framework::dataset::make("Expected", { true, false, false, false, false, false})), |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 103 | boxes_info, pred_boxes_info, deltas_info, bbox_info, expected) |
| 104 | { |
| 105 | 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); |
| 106 | } |
| 107 | // clang-format on |
| 108 | // *INDENT-ON* |
| 109 | |
| 110 | template <typename T> |
| 111 | using CLBoundingBoxTransformFixture = BoundingBoxTransformFixture<CLTensor, CLAccessor, CLBoundingBoxTransform, T>; |
| 112 | |
| 113 | TEST_SUITE(Float) |
| 114 | TEST_SUITE(FP32) |
| 115 | FIXTURE_DATA_TEST_CASE(BoundingBox, CLBoundingBoxTransformFixture<float>, framework::DatasetMode::ALL, |
| 116 | combine(combine(DeltaDataset, BboxInfoDataset), framework::dataset::make("DataType", { DataType::F32 }))) |
| 117 | { |
| 118 | // Validate output |
| 119 | validate(CLAccessor(_target), _reference, relative_tolerance_f32, 0.f, absolute_tolerance_f32); |
| 120 | } |
| 121 | TEST_SUITE_END() // FP32 |
| 122 | |
| 123 | TEST_SUITE(FP16) |
| 124 | FIXTURE_DATA_TEST_CASE(BoundingBox, CLBoundingBoxTransformFixture<half>, framework::DatasetMode::ALL, |
| 125 | combine(combine(DeltaDataset, BboxInfoDataset), framework::dataset::make("DataType", { DataType::F16 }))) |
| 126 | { |
| 127 | // Validate output |
Michele Di Giorgio | dd2619a | 2018-11-05 16:46:09 +0000 | [diff] [blame] | 128 | validate(CLAccessor(_target), _reference, relative_tolerance_f16, 0.03f, absolute_tolerance_f16); |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 129 | } |
| 130 | TEST_SUITE_END() // FP16 |
| 131 | TEST_SUITE_END() // Float |
| 132 | |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 133 | template <typename T> |
| 134 | using CLBoundingBoxTransformQuantizedFixture = BoundingBoxTransformQuantizedFixture<CLTensor, CLAccessor, CLBoundingBoxTransform, T>; |
| 135 | |
| 136 | TEST_SUITE(Quantized) |
| 137 | TEST_SUITE(QASYMM16) |
| 138 | FIXTURE_DATA_TEST_CASE(BoundingBox, CLBoundingBoxTransformQuantizedFixture<uint16_t>, framework::DatasetMode::ALL, |
| 139 | combine(combine(combine(DeltaDataset, BboxInfoDataset), framework::dataset::make("DataType", { DataType::QASYMM16 })), |
| 140 | framework::dataset::make("DeltasQuantInfo", { QuantizationInfo(1.f / 255.f, 127) }))) |
| 141 | { |
| 142 | // Validate output |
| 143 | validate(CLAccessor(_target), _reference, tolerance_qasymm16); |
| 144 | } |
| 145 | TEST_SUITE_END() // QASYMM16 |
| 146 | TEST_SUITE_END() // Quantized |
| 147 | |
giuros01 | c04a0e8 | 2018-10-03 12:44:35 +0100 | [diff] [blame] | 148 | TEST_SUITE_END() // BBoxTransform |
| 149 | TEST_SUITE_END() // CL |
| 150 | } // namespace validation |
| 151 | } // namespace test |
| 152 | } // namespace arm_compute |