Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 | #include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" |
| 26 | #include "arm_compute/runtime/Tensor.h" |
| 27 | #include "arm_compute/runtime/TensorAllocator.h" |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 28 | #include "tests/NEON/Accessor.h" |
| 29 | #include "tests/PaddingCalculator.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 30 | #include "tests/datasets/PoolingTypesDataset.h" |
| 31 | #include "tests/datasets/ShapeDatasets.h" |
| 32 | #include "tests/framework/Asserts.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/PoolingLayerFixture.h" |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 37 | |
| 38 | namespace arm_compute |
| 39 | { |
| 40 | namespace test |
| 41 | { |
| 42 | namespace validation |
| 43 | { |
| 44 | namespace |
| 45 | { |
| 46 | /** Input data set for float data types */ |
Georgios Pinitas | adaae7e | 2017-10-30 15:56:32 +0000 | [diff] [blame] | 47 | const auto PoolingLayerDatasetFP = combine(combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3, 7, 9 })), |
| 48 | framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })), |
| 49 | framework::dataset::make("ExcludePadding", { true, false })); |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 50 | |
| 51 | /** Input data set for quantized data types */ |
Georgios Pinitas | adaae7e | 2017-10-30 15:56:32 +0000 | [diff] [blame] | 52 | const auto PoolingLayerDatasetQS = combine(combine(combine(framework::dataset::make("PoolingType", { PoolingType::MAX, PoolingType::AVG }), framework::dataset::make("PoolingSize", { 2, 3 })), |
| 53 | framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })), |
| 54 | framework::dataset::make("ExcludePadding", { false })); |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 55 | |
| 56 | constexpr AbsoluteTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 57 | #ifdef ARM_COMPUTE_AARCH64_V8_2 |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 58 | constexpr AbsoluteTolerance<float> tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 59 | #endif /* ARM_COMPUTE_AARCH64_V8_2 */ |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 60 | constexpr AbsoluteTolerance<float> tolerance_qs8(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ |
| 61 | constexpr AbsoluteTolerance<float> tolerance_qs16(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ |
| 62 | } // namespace |
| 63 | |
| 64 | TEST_SUITE(NEON) |
| 65 | TEST_SUITE(PoolingLayer) |
| 66 | |
| 67 | //TODO(COMPMID-415): Configuration tests? |
| 68 | |
| 69 | template <typename T> |
| 70 | using NEPoolingLayerFixture = PoolingLayerValidationFixture<Tensor, Accessor, NEPoolingLayer, T>; |
| 71 | |
| 72 | TEST_SUITE(Float) |
| 73 | TEST_SUITE(FP32) |
| 74 | FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture<float>, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", |
| 75 | DataType::F32)))) |
| 76 | { |
| 77 | // Validate output |
| 78 | validate(Accessor(_target), _reference, tolerance_f32); |
| 79 | } |
| 80 | FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", |
| 81 | DataType::F32)))) |
| 82 | { |
| 83 | // Validate output |
| 84 | validate(Accessor(_target), _reference, tolerance_f32); |
| 85 | } |
| 86 | TEST_SUITE_END() |
| 87 | |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 88 | #ifdef ARM_COMPUTE_AARCH64_V8_2 |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 89 | TEST_SUITE(FP16) |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 90 | FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture<half>, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, |
| 91 | framework::dataset::make("DataType", DataType::F16)))) |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 92 | { |
| 93 | // Validate output |
| 94 | validate(Accessor(_target), _reference, tolerance_f16); |
| 95 | } |
Georgios Pinitas | 583137c | 2017-08-31 18:12:42 +0100 | [diff] [blame] | 96 | FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, |
| 97 | framework::dataset::make("DataType", DataType::F16)))) |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 98 | { |
| 99 | // Validate output |
| 100 | validate(Accessor(_target), _reference, tolerance_f16); |
| 101 | } |
| 102 | TEST_SUITE_END() |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 103 | #endif /* ARM_COMPUTE_AARCH64_V8_2 */ |
Georgios Pinitas | dc460f1 | 2017-08-24 19:02:44 +0100 | [diff] [blame] | 104 | TEST_SUITE_END() |
| 105 | |
| 106 | template <typename T> |
| 107 | using NEPoolingLayerFixedPointFixture = PoolingLayerValidationFixedPointFixture<Tensor, Accessor, NEPoolingLayer, T>; |
| 108 | |
| 109 | TEST_SUITE(Quantized) |
| 110 | TEST_SUITE(QS8) |
| 111 | FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture<int8_t>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, |
| 112 | framework::dataset::make("DataType", DataType::QS8))), |
| 113 | framework::dataset::make("FractionalBits", 1, 5))) |
| 114 | { |
| 115 | // Validate output |
| 116 | validate(Accessor(_target), _reference, tolerance_qs8); |
| 117 | } |
| 118 | FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, |
| 119 | framework::dataset::make("DataType", DataType::QS8))), |
| 120 | framework::dataset::make("FractionalBits", 1, 5))) |
| 121 | { |
| 122 | // Validate output |
| 123 | validate(Accessor(_target), _reference, tolerance_qs8); |
| 124 | } |
| 125 | TEST_SUITE_END() |
| 126 | |
| 127 | TEST_SUITE(QS16) |
| 128 | FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture<int16_t>, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, |
| 129 | framework::dataset::make("DataType", DataType::QS16))), |
| 130 | framework::dataset::make("FractionalBits", 1, 13))) |
| 131 | { |
| 132 | // Validate output |
| 133 | validate(Accessor(_target), _reference, tolerance_qs16); |
| 134 | } |
| 135 | FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, |
| 136 | framework::dataset::make("DataType", DataType::QS16))), |
| 137 | framework::dataset::make("FractionalBits", 1, 13))) |
| 138 | { |
| 139 | // Validate output |
| 140 | validate(Accessor(_target), _reference, tolerance_qs16); |
| 141 | } |
| 142 | TEST_SUITE_END() |
| 143 | TEST_SUITE_END() |
| 144 | |
| 145 | TEST_SUITE_END() |
| 146 | TEST_SUITE_END() |
| 147 | } // namespace validation |
| 148 | } // namespace test |
| 149 | } // namespace arm_compute |