blob: 30c231d499cb84adf5d93e9599aaacb12291cb13 [file] [log] [blame]
Giorgio Arenac6aa49b2018-08-07 11:53:30 +01001/*
2 * Copyright (c) 2018 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/CL/kernels/CLWeightsReshapeKernel.h"
25#include "arm_compute/core/Types.h"
26#include "tests/CL/Helper.h"
27
28#include "tests/CL/CLAccessor.h"
29#include "tests/datasets/ShapeDatasets.h"
30#include "tests/framework/Asserts.h"
31#include "tests/framework/Macros.h"
32#include "tests/framework/datasets/Datasets.h"
33#include "tests/validation/Validation.h"
34#include "tests/validation/fixtures/WeightsReshapeFixture.h"
35
36namespace arm_compute
37{
38namespace test
39{
40namespace validation
41{
42TEST_SUITE(CL)
43TEST_SUITE(WeightsReshape)
44
45using CLWeightsReshape = CLSynthetizeFunction<CLWeightsReshapeKernel>;
46
47// *INDENT-OFF*
48// clang-format off
49DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
50 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::U8), // Unsupported data type
51 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), // Mismatching data type
52 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::QASYMM8), // Bias not supported with QASYMM8
53 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
54 }),
55 framework::dataset::make("BiasesInfo", { TensorInfo(TensorShape(4U), 1, DataType::U8),
56 TensorInfo(TensorShape(4U), 1, DataType::F16),
57 TensorInfo(TensorShape(4U), 1, DataType::QASYMM8),
58 TensorInfo(TensorShape(4U), 1, DataType::F32),
59 })),
60 framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(4U, 19U), 1, DataType::U8),
61 TensorInfo(TensorShape(4U, 19U), 1, DataType::F16),
62 TensorInfo(TensorShape(4U, 19U), 1, DataType::QASYMM8),
63 TensorInfo(TensorShape(4U, 19U), 1, DataType::F32),
64 })),
65 framework::dataset::make("Expected", { false, false, false, true })),
66 input_info, biases_info, output_info, expected)
67{
68 bool status = bool(CLWeightsReshape::validate(&input_info, &biases_info, &output_info));
69 ARM_COMPUTE_EXPECT(status == expected, framework::LogLevel::ERRORS);
70}
71// clang-format on
72// *INDENT-ON*
73
74template <typename T>
75using CLWeightsReshapeFixture = WeightsReshapeValidationFixture<CLTensor, CLAccessor, CLWeightsReshape, T>;
76
77TEST_SUITE(Float)
78TEST_SUITE(FP32)
79FIXTURE_DATA_TEST_CASE(RunSmall, CLWeightsReshapeFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(datasets::GroupedWeightsSmallShapes(), framework::dataset::make("DataType",
80 DataType::F32)),
81 framework::dataset::make("HasBias", { true, false })),
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +010082 framework::dataset::make("NumGroups", { 1, 2, 3, 4 })))
Giorgio Arenac6aa49b2018-08-07 11:53:30 +010083{
84 // Validate output
85 validate(CLAccessor(_target), _reference);
86}
87FIXTURE_DATA_TEST_CASE(RunLarge, CLWeightsReshapeFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::GroupedWeightsLargeShapes(), framework::dataset::make("DataType",
88 DataType::F32)),
89 framework::dataset::make("HasBias", { true, false })),
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +010090 framework::dataset::make("NumGroups", { 1, 2, 3, 4 })))
Giorgio Arenac6aa49b2018-08-07 11:53:30 +010091{
92 // Validate output
93 validate(CLAccessor(_target), _reference);
94}
95TEST_SUITE_END()
96
97TEST_SUITE(FP16)
98FIXTURE_DATA_TEST_CASE(RunSmall, CLWeightsReshapeFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(datasets::GroupedWeightsSmallShapes(), framework::dataset::make("DataType",
99 DataType::F16)),
100 framework::dataset::make("HasBias", { true, false })),
101 framework::dataset::make("NumGroups", { 1, 2, 3 })))
102{
103 // Validate output
104 validate(CLAccessor(_target), _reference);
105}
106FIXTURE_DATA_TEST_CASE(RunLarge, CLWeightsReshapeFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::GroupedWeightsLargeShapes(), framework::dataset::make("DataType",
107 DataType::F16)),
108 framework::dataset::make("HasBias", { true, false })),
109 framework::dataset::make("NumGroups", { 1, 2, 3 })))
110{
111 // Validate output
112 validate(CLAccessor(_target), _reference);
113}
114TEST_SUITE_END()
115
116TEST_SUITE_END()
117
118TEST_SUITE(QASYMM8)
119FIXTURE_DATA_TEST_CASE(RunSmall, CLWeightsReshapeFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(datasets::GroupedWeightsSmallShapes(), framework::dataset::make("DataType",
120 DataType::QASYMM8)),
121 framework::dataset::make("HasBias", { false })),
122 framework::dataset::make("NumGroups", { 1, 2, 3 })))
123{
124 // Validate output
125 validate(CLAccessor(_target), _reference);
126}
127FIXTURE_DATA_TEST_CASE(RunLarge, CLWeightsReshapeFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::GroupedWeightsLargeShapes(), framework::dataset::make("DataType",
128 DataType::QASYMM8)),
129 framework::dataset::make("HasBias", { false })),
130 framework::dataset::make("NumGroups", { 1, 2, 3 })))
131{
132 // Validate output
133 validate(CLAccessor(_target), _reference);
134}
135TEST_SUITE_END()
136
137TEST_SUITE_END()
138TEST_SUITE_END()
139} // namespace validation
140} // namespace test
141} // namespace arm_compute