Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 Arm Limited. |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [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, |
Gian Marco Iodice | 1e6c915 | 2019-08-20 11:27:20 +0100 | [diff] [blame] | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 22 | * SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include "arm_compute/core/Types.h" |
| 26 | #include "arm_compute/runtime/GLES_COMPUTE/GCTensor.h" |
| 27 | #include "arm_compute/runtime/GLES_COMPUTE/GCTensorAllocator.h" |
| 28 | #include "arm_compute/runtime/GLES_COMPUTE/functions/GCConvolutionLayer.h" |
| 29 | #include "tests/GLES_COMPUTE/GCAccessor.h" |
| 30 | #include "tests/PaddingCalculator.h" |
| 31 | #include "tests/datasets/LargeConvolutionLayerDataset.h" |
| 32 | #include "tests/datasets/SmallConvolutionLayerDataset.h" |
| 33 | #include "tests/framework/Asserts.h" |
| 34 | #include "tests/framework/Macros.h" |
| 35 | #include "tests/framework/datasets/Datasets.h" |
| 36 | #include "tests/validation/Validation.h" |
| 37 | #include "tests/validation/fixtures/ConvolutionLayerFixture.h" |
| 38 | |
| 39 | namespace arm_compute |
| 40 | { |
| 41 | namespace test |
| 42 | { |
| 43 | namespace validation |
| 44 | { |
| 45 | namespace |
| 46 | { |
| 47 | RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.2)); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ |
Michele Di Giorgio | fc1d1e2 | 2018-04-10 14:24:35 +0100 | [diff] [blame] | 48 | RelativeTolerance<float> tolerance_f32(0.00001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 49 | constexpr float tolerance_num = 0.07f; /**< Tolerance number */ |
| 50 | |
| 51 | /** CNN data types */ |
| 52 | const auto CNNDataTypes = framework::dataset::make("DataType", |
| 53 | { |
| 54 | DataType::F16, |
Michele Di Giorgio | fc1d1e2 | 2018-04-10 14:24:35 +0100 | [diff] [blame] | 55 | DataType::F32, |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 56 | }); |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 57 | const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo", |
| 58 | { |
| 59 | ActivationLayerInfo(), |
| 60 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), |
| 61 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f) |
| 62 | }); |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 63 | } // namespace |
| 64 | |
| 65 | TEST_SUITE(GC) |
| 66 | TEST_SUITE(ConvolutionLayer) |
| 67 | |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 68 | template <typename T> |
| 69 | using GCConvolutionLayerFixture = ConvolutionValidationFixture<GCTensor, GCAccessor, GCConvolutionLayer, T>; |
| 70 | |
| 71 | TEST_SUITE(Float) |
| 72 | TEST_SUITE(FP16) |
Gian Marco Iodice | 3139f03 | 2018-11-05 14:26:32 +0000 | [diff] [blame] | 73 | FIXTURE_DATA_TEST_CASE(RunSmall, GCConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallConvolutionLayerReducedDataset(), |
Michele Di Giorgio | 164b65d | 2018-04-13 14:28:08 +0100 | [diff] [blame] | 74 | framework::dataset::make("ReshapeWeights", { true })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 75 | framework::dataset::make("DataType", |
| 76 | DataType::F16)), |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 77 | framework::dataset::make("DataLayout", |
| 78 | DataLayout::NCHW)), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 79 | ActivationFunctionsDataset)) |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 80 | { |
| 81 | // Validate output |
| 82 | validate(GCAccessor(_target), _reference, tolerance_f16, tolerance_num); |
| 83 | } |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 84 | FIXTURE_DATA_TEST_CASE(RunLarge, GCConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeConvolutionLayerDataset(), |
Michele Di Giorgio | 164b65d | 2018-04-13 14:28:08 +0100 | [diff] [blame] | 85 | framework::dataset::make("ReshapeWeights", { true })), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 86 | framework::dataset::make("DataType", |
| 87 | DataType::F16)), |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 88 | framework::dataset::make("DataLayout", |
| 89 | DataLayout::NCHW)), |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 90 | ActivationFunctionsDataset)) |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 91 | { |
| 92 | // Validate output |
| 93 | validate(GCAccessor(_target), _reference, tolerance_f16, tolerance_num); |
| 94 | } |
| 95 | TEST_SUITE_END() |
Michele Di Giorgio | fc1d1e2 | 2018-04-10 14:24:35 +0100 | [diff] [blame] | 96 | |
| 97 | TEST_SUITE(FP32) |
Gian Marco Iodice | 3139f03 | 2018-11-05 14:26:32 +0000 | [diff] [blame] | 98 | FIXTURE_DATA_TEST_CASE(RunSmall, GCConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallConvolutionLayerReducedDataset(), |
Michele Di Giorgio | 164b65d | 2018-04-13 14:28:08 +0100 | [diff] [blame] | 99 | framework::dataset::make("ReshapeWeights", { true })), |
Michele Di Giorgio | fc1d1e2 | 2018-04-10 14:24:35 +0100 | [diff] [blame] | 100 | framework::dataset::make("DataType", DataType::F32)), |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 101 | framework::dataset::make("DataLayout", |
| 102 | DataLayout::NCHW)), |
Michele Di Giorgio | fc1d1e2 | 2018-04-10 14:24:35 +0100 | [diff] [blame] | 103 | ActivationFunctionsDataset)) |
| 104 | { |
| 105 | // Validate output |
| 106 | validate(GCAccessor(_target), _reference, tolerance_f32, tolerance_num); |
| 107 | } |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 108 | FIXTURE_DATA_TEST_CASE(RunLarge, GCConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeConvolutionLayerDataset(), |
Michele Di Giorgio | 164b65d | 2018-04-13 14:28:08 +0100 | [diff] [blame] | 109 | framework::dataset::make("ReshapeWeights", { true })), |
Michele Di Giorgio | fc1d1e2 | 2018-04-10 14:24:35 +0100 | [diff] [blame] | 110 | framework::dataset::make("DataType", DataType::F32)), |
Michalis Spyrou | e250389 | 2018-04-23 15:17:31 +0100 | [diff] [blame] | 111 | framework::dataset::make("DataLayout", |
| 112 | DataLayout::NCHW)), |
Michele Di Giorgio | fc1d1e2 | 2018-04-10 14:24:35 +0100 | [diff] [blame] | 113 | ActivationFunctionsDataset)) |
| 114 | { |
| 115 | // Validate output |
| 116 | validate(GCAccessor(_target), _reference, tolerance_f32, tolerance_num); |
| 117 | } |
| 118 | TEST_SUITE_END() |
Anthony Barbier | 51b074a | 2018-02-20 12:09:07 +0000 | [diff] [blame] | 119 | TEST_SUITE_END() |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 120 | |
| 121 | TEST_SUITE_END() |
| 122 | TEST_SUITE_END() |
Stephen Li | e855c23 | 2018-01-04 14:13:22 +0800 | [diff] [blame] | 123 | } // namespace validation |
| 124 | } // namespace test |
| 125 | } // namespace arm_compute |