blob: 3e3c8320c13131bfaa3b83da5d82a4faa9879258 [file] [log] [blame]
Stephen Lie855c232018-01-04 14:13:22 +08001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2020 Arm Limited.
Stephen Lie855c232018-01-04 14:13:22 +08003 *
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 Iodice1e6c9152019-08-20 11:27:20 +010021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Stephen Lie855c232018-01-04 14:13:22 +080022 * 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
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
45namespace
46{
47RelativeTolerance<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 Giorgiofc1d1e22018-04-10 14:24:35 +010048RelativeTolerance<float> tolerance_f32(0.00001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */
Stephen Lie855c232018-01-04 14:13:22 +080049constexpr float tolerance_num = 0.07f; /**< Tolerance number */
50
51/** CNN data types */
52const auto CNNDataTypes = framework::dataset::make("DataType",
53{
54 DataType::F16,
Michele Di Giorgiofc1d1e22018-04-10 14:24:35 +010055 DataType::F32,
Stephen Lie855c232018-01-04 14:13:22 +080056});
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000057const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo",
58{
59 ActivationLayerInfo(),
60 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU),
61 ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 0.5f)
62});
Stephen Lie855c232018-01-04 14:13:22 +080063} // namespace
64
65TEST_SUITE(GC)
66TEST_SUITE(ConvolutionLayer)
67
Stephen Lie855c232018-01-04 14:13:22 +080068template <typename T>
69using GCConvolutionLayerFixture = ConvolutionValidationFixture<GCTensor, GCAccessor, GCConvolutionLayer, T>;
70
71TEST_SUITE(Float)
72TEST_SUITE(FP16)
Gian Marco Iodice3139f032018-11-05 14:26:32 +000073FIXTURE_DATA_TEST_CASE(RunSmall, GCConvolutionLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallConvolutionLayerReducedDataset(),
Michele Di Giorgio164b65d2018-04-13 14:28:08 +010074 framework::dataset::make("ReshapeWeights", { true })),
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000075 framework::dataset::make("DataType",
76 DataType::F16)),
Michalis Spyroue2503892018-04-23 15:17:31 +010077 framework::dataset::make("DataLayout",
78 DataLayout::NCHW)),
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000079 ActivationFunctionsDataset))
Stephen Lie855c232018-01-04 14:13:22 +080080{
81 // Validate output
82 validate(GCAccessor(_target), _reference, tolerance_f16, tolerance_num);
83}
Michalis Spyroue2503892018-04-23 15:17:31 +010084FIXTURE_DATA_TEST_CASE(RunLarge, GCConvolutionLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeConvolutionLayerDataset(),
Michele Di Giorgio164b65d2018-04-13 14:28:08 +010085 framework::dataset::make("ReshapeWeights", { true })),
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000086 framework::dataset::make("DataType",
87 DataType::F16)),
Michalis Spyroue2503892018-04-23 15:17:31 +010088 framework::dataset::make("DataLayout",
89 DataLayout::NCHW)),
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000090 ActivationFunctionsDataset))
Stephen Lie855c232018-01-04 14:13:22 +080091{
92 // Validate output
93 validate(GCAccessor(_target), _reference, tolerance_f16, tolerance_num);
94}
95TEST_SUITE_END()
Michele Di Giorgiofc1d1e22018-04-10 14:24:35 +010096
97TEST_SUITE(FP32)
Gian Marco Iodice3139f032018-11-05 14:26:32 +000098FIXTURE_DATA_TEST_CASE(RunSmall, GCConvolutionLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallConvolutionLayerReducedDataset(),
Michele Di Giorgio164b65d2018-04-13 14:28:08 +010099 framework::dataset::make("ReshapeWeights", { true })),
Michele Di Giorgiofc1d1e22018-04-10 14:24:35 +0100100 framework::dataset::make("DataType", DataType::F32)),
Michalis Spyroue2503892018-04-23 15:17:31 +0100101 framework::dataset::make("DataLayout",
102 DataLayout::NCHW)),
Michele Di Giorgiofc1d1e22018-04-10 14:24:35 +0100103 ActivationFunctionsDataset))
104{
105 // Validate output
106 validate(GCAccessor(_target), _reference, tolerance_f32, tolerance_num);
107}
Michalis Spyroue2503892018-04-23 15:17:31 +0100108FIXTURE_DATA_TEST_CASE(RunLarge, GCConvolutionLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(datasets::LargeConvolutionLayerDataset(),
Michele Di Giorgio164b65d2018-04-13 14:28:08 +0100109 framework::dataset::make("ReshapeWeights", { true })),
Michele Di Giorgiofc1d1e22018-04-10 14:24:35 +0100110 framework::dataset::make("DataType", DataType::F32)),
Michalis Spyroue2503892018-04-23 15:17:31 +0100111 framework::dataset::make("DataLayout",
112 DataLayout::NCHW)),
Michele Di Giorgiofc1d1e22018-04-10 14:24:35 +0100113 ActivationFunctionsDataset))
114{
115 // Validate output
116 validate(GCAccessor(_target), _reference, tolerance_f32, tolerance_num);
117}
118TEST_SUITE_END()
Anthony Barbier51b074a2018-02-20 12:09:07 +0000119TEST_SUITE_END()
Stephen Lie855c232018-01-04 14:13:22 +0800120
121TEST_SUITE_END()
122TEST_SUITE_END()
Stephen Lie855c232018-01-04 14:13:22 +0800123} // namespace validation
124} // namespace test
125} // namespace arm_compute