blob: 92d63c0c3dfb2a8f44b03ec49eb16c06af513343 [file] [log] [blame]
Gian Marco Iodice761c8d02019-06-10 14:46:49 +01001/*
2 * Copyright (c) 2019 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/functions/CLFuseBatchNormalization.h"
25#include "tests/CL/CLAccessor.h"
26#include "tests/Globals.h"
27#include "tests/datasets/ShapeDatasets.h"
28#include "tests/framework/Macros.h"
29#include "tests/framework/datasets/Datasets.h"
30#include "tests/validation/Validation.h"
31#include "tests/validation/fixtures/FuseBatchNormalizationFixture.h"
32
33namespace arm_compute
34{
35namespace test
36{
37namespace validation
38{
39namespace
40{
41AbsoluteTolerance<float> absolute_tolerance_f32(0.001f);
42AbsoluteTolerance<float> absolute_tolerance_f16(0.2f);
43} // namespace
44
45template <typename T>
46using CLFuseBatchNormalizationConvFixture = FuseBatchNormalizationFixture<CLTensor, CLAccessor, CLFuseBatchNormalization, 4, T>;
47
48// *INDENT-OFF*
49// clang-format off
50
51/** Shapes to test - Precommit */
52const auto shape_conv_values_precommit = concat(datasets::Small4DShapes(), datasets::Small3DShapes());
53
54/** Shapes to test - Nightly */
55const auto shape_conv_values_nightly = concat(datasets::Large4DShapes(), datasets::Large3DShapes());
56
57/** Data layout to test */
58const auto data_layout_values = framework::dataset::make("DataLayout", { DataLayout::NHWC, DataLayout::NCHW });
59
60/** In-place flags to test */
61const auto in_place_values = framework::dataset::make("InPlace", { true, false });
62
63/** With bias flags to test */
64const auto with_bias_values = framework::dataset::make("WithBias", { true, false });
65
66/** With gamma flags to test */
67const auto with_gamma_values = framework::dataset::make("WithGamma", { true, false });
68
69/** With beta flags to test */
70const auto with_beta_values = framework::dataset::make("WithBeta", { true, false });
71
72TEST_SUITE(CL)
73TEST_SUITE(FuseBatchNormalization)
74TEST_SUITE(Convolution)
75TEST_SUITE(Float)
76TEST_SUITE(FP32)
77FIXTURE_DATA_TEST_CASE(RunSmall, CLFuseBatchNormalizationConvFixture<float>, framework::DatasetMode::PRECOMMIT,
78 combine(combine(combine(combine(combine(combine(
79 shape_conv_values_precommit,
80 framework::dataset::make("DataType", { DataType::F32 })),
81 data_layout_values),
82 in_place_values),
83 with_bias_values),
84 with_gamma_values),
85 with_beta_values))
86{
87 // Validate outputs
88 validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f32);
89 validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f32);
90}
91
92FIXTURE_DATA_TEST_CASE(RunLarge, CLFuseBatchNormalizationConvFixture<float>, framework::DatasetMode::NIGHTLY,
93 combine(combine(combine(combine(combine(combine(
94 shape_conv_values_nightly,
95 framework::dataset::make("DataType", { DataType::F32 })),
96 data_layout_values),
97 in_place_values),
98 with_bias_values),
99 with_gamma_values),
100 with_beta_values))
101{
102 // Validate outputs
103 validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f32);
104 validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f32);
105}
106
107TEST_SUITE_END() // FP32
108
109TEST_SUITE(FP16)
110FIXTURE_DATA_TEST_CASE(RunSmall, CLFuseBatchNormalizationConvFixture<half>, framework::DatasetMode::PRECOMMIT,
111 combine(combine(combine(combine(combine(combine(
112 shape_conv_values_precommit,
113 framework::dataset::make("DataType", { DataType::F16 })),
114 data_layout_values),
115 in_place_values),
116 with_bias_values),
117 with_gamma_values),
118 with_beta_values))
119{
120 // Validate outputs
121 validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f16);
122 validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f16);
123}
124
125FIXTURE_DATA_TEST_CASE(RunLarge, CLFuseBatchNormalizationConvFixture<half>, framework::DatasetMode::NIGHTLY,
126 combine(combine(combine(combine(combine(combine(
127 shape_conv_values_nightly,
128 framework::dataset::make("DataType", { DataType::F16 })),
129 data_layout_values),
130 in_place_values),
131 with_bias_values),
132 with_gamma_values),
133 with_beta_values))
134{
135 // Validate outputs
136 validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f16);
137 validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f16);
138}
139
140TEST_SUITE_END() // FP16
141TEST_SUITE_END() // Float
142TEST_SUITE_END() // Convolution
143TEST_SUITE_END() // FuseBatchNormalization
144TEST_SUITE_END() // CL
145} // namespace validation
146} // namespace test
147} // namespace arm_compute