blob: 47cb975527ca6d12bae7e3925a16d9564ecab063 [file] [log] [blame]
Giorgio Arenac6aa49b2018-08-07 11:53:30 +01001/*
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +00002 * Copyright (c) 2018-2019 ARM Limited.
Giorgio Arenac6aa49b2018-08-07 11:53:30 +01003 *
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(
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +000050 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32), // Mismatching data type
Giorgio Arenac6aa49b2018-08-07 11:53:30 +010051 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::QASYMM8), // Bias not supported with QASYMM8
52 TensorInfo(TensorShape(3U, 3U, 2U, 4U), 1, DataType::F32),
53 }),
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +000054 framework::dataset::make("BiasesInfo", { TensorInfo(TensorShape(4U), 1, DataType::F16),
Giorgio Arenac6aa49b2018-08-07 11:53:30 +010055 TensorInfo(TensorShape(4U), 1, DataType::QASYMM8),
56 TensorInfo(TensorShape(4U), 1, DataType::F32),
57 })),
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +000058 framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(4U, 19U), 1, DataType::F16),
Giorgio Arenac6aa49b2018-08-07 11:53:30 +010059 TensorInfo(TensorShape(4U, 19U), 1, DataType::QASYMM8),
60 TensorInfo(TensorShape(4U, 19U), 1, DataType::F32),
61 })),
Vidhya Sudhan Loganathan951b8a42019-11-04 14:42:08 +000062 framework::dataset::make("Expected", { false, false, true })),
Giorgio Arenac6aa49b2018-08-07 11:53:30 +010063 input_info, biases_info, output_info, expected)
64{
65 bool status = bool(CLWeightsReshape::validate(&input_info, &biases_info, &output_info));
66 ARM_COMPUTE_EXPECT(status == expected, framework::LogLevel::ERRORS);
67}
68// clang-format on
69// *INDENT-ON*
70
71template <typename T>
72using CLWeightsReshapeFixture = WeightsReshapeValidationFixture<CLTensor, CLAccessor, CLWeightsReshape, T>;
73
74TEST_SUITE(Float)
75TEST_SUITE(FP32)
76FIXTURE_DATA_TEST_CASE(RunSmall, CLWeightsReshapeFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(datasets::GroupedWeightsSmallShapes(), framework::dataset::make("DataType",
77 DataType::F32)),
78 framework::dataset::make("HasBias", { true, false })),
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +010079 framework::dataset::make("NumGroups", { 1, 2, 3, 4 })))
Giorgio Arenac6aa49b2018-08-07 11:53:30 +010080{
81 // Validate output
82 validate(CLAccessor(_target), _reference);
83}
84FIXTURE_DATA_TEST_CASE(RunLarge, CLWeightsReshapeFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::GroupedWeightsLargeShapes(), framework::dataset::make("DataType",
85 DataType::F32)),
86 framework::dataset::make("HasBias", { true, false })),
Gian Marco Iodice916d1bc2018-08-13 11:20:41 +010087 framework::dataset::make("NumGroups", { 1, 2, 3, 4 })))
Giorgio Arenac6aa49b2018-08-07 11:53:30 +010088{
89 // Validate output
90 validate(CLAccessor(_target), _reference);
91}
92TEST_SUITE_END()
93
94TEST_SUITE(FP16)
95FIXTURE_DATA_TEST_CASE(RunSmall, CLWeightsReshapeFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(datasets::GroupedWeightsSmallShapes(), framework::dataset::make("DataType",
96 DataType::F16)),
97 framework::dataset::make("HasBias", { true, false })),
98 framework::dataset::make("NumGroups", { 1, 2, 3 })))
99{
100 // Validate output
101 validate(CLAccessor(_target), _reference);
102}
103FIXTURE_DATA_TEST_CASE(RunLarge, CLWeightsReshapeFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::GroupedWeightsLargeShapes(), framework::dataset::make("DataType",
104 DataType::F16)),
105 framework::dataset::make("HasBias", { true, false })),
106 framework::dataset::make("NumGroups", { 1, 2, 3 })))
107{
108 // Validate output
109 validate(CLAccessor(_target), _reference);
110}
111TEST_SUITE_END()
112
113TEST_SUITE_END()
114
115TEST_SUITE(QASYMM8)
116FIXTURE_DATA_TEST_CASE(RunSmall, CLWeightsReshapeFixture<uint8_t>, framework::DatasetMode::ALL, combine(combine(combine(datasets::GroupedWeightsSmallShapes(), framework::dataset::make("DataType",
117 DataType::QASYMM8)),
118 framework::dataset::make("HasBias", { false })),
119 framework::dataset::make("NumGroups", { 1, 2, 3 })))
120{
121 // Validate output
122 validate(CLAccessor(_target), _reference);
123}
124FIXTURE_DATA_TEST_CASE(RunLarge, CLWeightsReshapeFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::GroupedWeightsLargeShapes(), framework::dataset::make("DataType",
125 DataType::QASYMM8)),
126 framework::dataset::make("HasBias", { false })),
127 framework::dataset::make("NumGroups", { 1, 2, 3 })))
128{
129 // Validate output
130 validate(CLAccessor(_target), _reference);
131}
132TEST_SUITE_END()
133
134TEST_SUITE_END()
135TEST_SUITE_END()
136} // namespace validation
137} // namespace test
138} // namespace arm_compute