giuros01 | 1887081 | 2018-09-13 09:31:40 +0100 | [diff] [blame] | 1 | /* |
| 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" |
| 27 | #include "tests/CL/CLArrayAccessor.h" |
| 28 | #include "tests/Globals.h" |
| 29 | #include "tests/datasets/ROIPoolingLayerDataset.h" |
| 30 | #include "tests/datasets/ShapeDatasets.h" |
| 31 | #include "tests/framework/Macros.h" |
| 32 | #include "tests/framework/datasets/Datasets.h" |
| 33 | #include "tests/validation/Validation.h" |
| 34 | #include "tests/validation/fixtures/ROIAlignLayerFixture.h" |
| 35 | #include "utils/TypePrinter.h" |
| 36 | |
| 37 | namespace arm_compute |
| 38 | { |
| 39 | namespace test |
| 40 | { |
| 41 | namespace validation |
| 42 | { |
| 43 | namespace |
| 44 | { |
| 45 | RelativeTolerance<float> relative_tolerance_f32(0.01f); |
| 46 | RelativeTolerance<float> absolute_tolerance_f32(0.001f); |
| 47 | } // namespace |
| 48 | |
| 49 | TEST_SUITE(CL) |
| 50 | TEST_SUITE(RoiAlign) |
| 51 | |
| 52 | // *INDENT-OFF* |
| 53 | // clang-format off |
| 54 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip( |
| 55 | framework::dataset::make("InputInfo", { TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), |
| 56 | TensorInfo(TensorShape(250U, 128U, 3U), 1, DataType::F32), // Mismatching data type input/output |
| 57 | TensorInfo(TensorShape(250U, 128U, 2U), 1, DataType::F32), // Mismatching depth size input/output |
| 58 | TensorInfo(TensorShape(250U, 128U, 2U), 1, DataType::F32), // Mismatching number of rois and output batch size |
| 59 | TensorInfo(TensorShape(250U, 128U, 2U), 1, DataType::F32), // Mismatching height and width input/output |
| 60 | |
| 61 | }), |
| 62 | framework::dataset::make("NumRois", { 3U, 3U, 4U, 10U, 4U})), |
| 63 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(7U, 7U, 3U, 3U), 1, DataType::F32), |
| 64 | TensorInfo(TensorShape(7U, 7U, 3U, 3U), 1, DataType::F16), |
| 65 | TensorInfo(TensorShape(7U, 7U, 4U, 3U), 1, DataType::F32), |
| 66 | TensorInfo(TensorShape(7U, 7U, 2U, 3U), 1, DataType::F32), |
| 67 | TensorInfo(TensorShape(5U, 5U, 2U, 4U), 1, DataType::F32), |
| 68 | })), |
| 69 | framework::dataset::make("PoolInfo", { ROIPoolingLayerInfo(7U, 7U, 1./8), |
| 70 | ROIPoolingLayerInfo(7U, 7U, 1./8), |
| 71 | ROIPoolingLayerInfo(7U, 7U, 1./8), |
| 72 | ROIPoolingLayerInfo(7U, 7U, 1./8), |
| 73 | ROIPoolingLayerInfo(7U, 7U, 1./8), |
| 74 | })), |
| 75 | framework::dataset::make("Expected", { true, false, false, false, false })), |
| 76 | input_info, num_rois, output_info, pool_info, expected) |
| 77 | { |
| 78 | ARM_COMPUTE_EXPECT(bool(CLROIAlignLayer::validate(&input_info.clone()->set_is_resizable(true), num_rois, &output_info.clone()->set_is_resizable(true), pool_info)) == expected, framework::LogLevel::ERRORS); |
| 79 | } |
| 80 | // clang-format on |
| 81 | // *INDENT-ON* |
| 82 | |
| 83 | template <typename T> |
| 84 | using CLROIAlignLayerFixture = ROIAlignLayerFixture<CLTensor, CLAccessor, CLROIAlignLayer, CLArray<ROI>, CLArrayAccessor<ROI>, T>; |
| 85 | |
| 86 | TEST_SUITE(Float) |
| 87 | TEST_SUITE(FP32) |
| 88 | FIXTURE_DATA_TEST_CASE(SmallROIAlignLayer, CLROIAlignLayerFixture<float>, framework::DatasetMode::ALL, |
| 89 | framework::dataset::combine(framework::dataset::combine(datasets::SmallROIPoolingLayerDataset(), |
| 90 | framework::dataset::make("DataType", { DataType::F32 })), |
| 91 | framework::dataset::make("Batches", { 1, 4, 8 }))) |
| 92 | { |
| 93 | // Validate output |
giuros01 | eddff5a | 2018-10-05 14:48:58 +0100 | [diff] [blame] | 94 | validate(CLAccessor(_target), _reference, relative_tolerance_f32, .02f, absolute_tolerance_f32); |
giuros01 | 1887081 | 2018-09-13 09:31:40 +0100 | [diff] [blame] | 95 | } |
| 96 | TEST_SUITE_END() // FP32 |
| 97 | |
| 98 | TEST_SUITE_END() // Float |
| 99 | |
| 100 | TEST_SUITE_END() // RoiAlign |
| 101 | TEST_SUITE_END() // CL |
| 102 | } // namespace validation |
| 103 | } // namespace test |
| 104 | } // namespace arm_compute |