Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 1 | /* |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [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 CONCLCTION 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/CL/CLTensor.h" |
| 26 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
| 27 | #include "arm_compute/runtime/CL/functions/CLDepthwiseConvolutionLayer.h" |
| 28 | #include "tests/CL/CLAccessor.h" |
| 29 | #include "tests/PaddingCalculator.h" |
| 30 | #include "tests/datasets/DepthwiseConvolutionLayerDataset.h" |
| 31 | #include "tests/framework/Asserts.h" |
| 32 | #include "tests/framework/Macros.h" |
| 33 | #include "tests/framework/datasets/Datasets.h" |
| 34 | #include "tests/validation/Validation.h" |
| 35 | #include "tests/validation/fixtures/DepthwiseConvolutionLayerFixture.h" |
| 36 | |
| 37 | namespace arm_compute |
| 38 | { |
| 39 | namespace test |
| 40 | { |
| 41 | namespace validation |
| 42 | { |
| 43 | namespace |
| 44 | { |
Michele Di Giorgio | 933fe86 | 2018-02-19 15:42:12 +0000 | [diff] [blame] | 45 | RelativeTolerance<half_float::half> tolerance_f16(half_float::half(0.001)); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ |
| 46 | constexpr RelativeTolerance<float> tolerance_f32(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ |
| 47 | constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1); /**< Tolerance value for comparing reference's output against implementation's output for DataType::QASYMM8 */ |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 48 | } // namespace |
| 49 | |
| 50 | TEST_SUITE(CL) |
| 51 | TEST_SUITE(DepthwiseConvolutionLayer) |
| 52 | |
| 53 | template <typename T> |
| 54 | using CLDepthwiseConvolutionLayerFixture = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T>; |
| 55 | |
| 56 | TEST_SUITE(Generic) |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 57 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(), |
| 58 | framework::dataset::make("DataType", |
| 59 | DataType::F32)), |
| 60 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 61 | { |
| 62 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 63 | } |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 64 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(), |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 65 | framework::dataset::make("DataType", |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 66 | DataType::F32)), |
| 67 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 68 | { |
| 69 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 70 | } |
| 71 | TEST_SUITE_END() |
| 72 | |
| 73 | template <typename T> |
| 74 | using CLDepthwiseConvolutionLayerFixture3x3 = DepthwiseConvolutionLayerValidationFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer3x3, T>; |
| 75 | |
| 76 | TEST_SUITE(Float) |
Michele Di Giorgio | 933fe86 | 2018-02-19 15:42:12 +0000 | [diff] [blame] | 77 | TEST_SUITE(F16) |
| 78 | TEST_SUITE(W3x3) |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 79 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture3x3<half>, framework::DatasetMode::ALL, combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(), |
Michele Di Giorgio | 933fe86 | 2018-02-19 15:42:12 +0000 | [diff] [blame] | 80 | framework::dataset::make("DataType", |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 81 | DataType::F16)), |
| 82 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
Michele Di Giorgio | 933fe86 | 2018-02-19 15:42:12 +0000 | [diff] [blame] | 83 | { |
| 84 | validate(CLAccessor(_target), _reference, tolerance_f16); |
| 85 | } |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 86 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture3x3<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(), |
Michele Di Giorgio | 933fe86 | 2018-02-19 15:42:12 +0000 | [diff] [blame] | 87 | framework::dataset::make("DataType", |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 88 | DataType::F16)), |
| 89 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
Michele Di Giorgio | 933fe86 | 2018-02-19 15:42:12 +0000 | [diff] [blame] | 90 | { |
| 91 | validate(CLAccessor(_target), _reference, tolerance_f16); |
| 92 | } |
| 93 | TEST_SUITE_END() |
| 94 | TEST_SUITE_END() |
| 95 | |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 96 | TEST_SUITE(FP32) |
| 97 | TEST_SUITE(W3x3) |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 98 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerFixture3x3<float>, framework::DatasetMode::ALL, combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(), |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 99 | framework::dataset::make("DataType", |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 100 | DataType::F32)), |
| 101 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 102 | { |
| 103 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 104 | } |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 105 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerFixture3x3<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(), |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 106 | framework::dataset::make("DataType", |
Giorgio Arena | 1ed1fc6 | 2018-03-26 16:20:05 +0100 | [diff] [blame^] | 107 | DataType::F32)), |
| 108 | framework::dataset::make("DataLayout", DataLayout::NCHW))) |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 109 | { |
| 110 | validate(CLAccessor(_target), _reference, tolerance_f32); |
| 111 | } |
| 112 | TEST_SUITE_END() |
| 113 | TEST_SUITE_END() |
| 114 | TEST_SUITE_END() |
| 115 | |
| 116 | template <typename T> |
Georgios Pinitas | de5a1cc | 2018-02-02 12:52:07 +0000 | [diff] [blame] | 117 | using CLDepthwiseConvolutionLayerQuantizedFixture = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer, T>; |
| 118 | template <typename T> |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 119 | using CLDepthwiseConvolutionLayerQuantizedFixture3x3 = DepthwiseConvolutionLayerValidationQuantizedFixture<CLTensor, CLAccessor, CLDepthwiseConvolutionLayer3x3, T>; |
| 120 | |
| 121 | TEST_SUITE(Quantized) |
| 122 | TEST_SUITE(QASYMM8) |
Georgios Pinitas | de5a1cc | 2018-02-02 12:52:07 +0000 | [diff] [blame] | 123 | TEST_SUITE(Generic) |
| 124 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset(), |
| 125 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 126 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) }))) |
| 127 | { |
| 128 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 129 | } |
Georgios Pinitas | 1a03d76 | 2018-02-21 14:47:09 +0000 | [diff] [blame] | 130 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset(), |
Georgios Pinitas | de5a1cc | 2018-02-02 12:52:07 +0000 | [diff] [blame] | 131 | framework::dataset::make("DataType", DataType::QASYMM8)), |
| 132 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) }))) |
| 133 | { |
| 134 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 135 | } |
| 136 | TEST_SUITE_END() |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 137 | TEST_SUITE(W3x3) |
| 138 | FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallDepthwiseConvolutionLayerDataset3x3(), |
| 139 | framework::dataset::make("DataType", DataType::QASYMM8)), |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 140 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) }))) |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 141 | { |
| 142 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 143 | } |
| 144 | FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionLayerQuantizedFixture3x3<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthwiseConvolutionLayerDataset3x3(), |
| 145 | framework::dataset::make("DataType", DataType::QASYMM8)), |
Georgios Pinitas | f72f936 | 2018-01-12 16:29:45 +0000 | [diff] [blame] | 146 | framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) }))) |
Giorgio Arena | 04a8f8c | 2017-11-23 11:45:24 +0000 | [diff] [blame] | 147 | { |
| 148 | validate(CLAccessor(_target), _reference, tolerance_qasymm8); |
| 149 | } |
| 150 | TEST_SUITE_END() |
| 151 | TEST_SUITE_END() |
| 152 | TEST_SUITE_END() |
| 153 | |
| 154 | TEST_SUITE_END() |
| 155 | TEST_SUITE_END() |
| 156 | } // namespace validation |
| 157 | } // namespace test |
| 158 | } // namespace arm_compute |