blob: 60b92bd03079c9aa79c5d6165fa8c7265b6920b3 [file] [log] [blame]
Gian Marco Iodicedb63b9c2019-01-17 09:47:04 +00001/*
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/core/CL/kernels/CLGEMMLowpMatrixMultiplyReshapedKernel.h"
25#include "arm_compute/core/CL/kernels/CLGEMMReshapeLHSMatrixKernel.h"
26#include "arm_compute/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h"
27#include "arm_compute/core/Types.h"
28#include "arm_compute/core/utils/misc/ShapeCalculator.h"
29#include "tests/CL/CLAccessor.h"
30#include "tests/CL/Helper.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/GEMMLowpFixture.h"
36
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43using namespace arm_compute::misc::shape_calculator;
44
45// Create function for CLGEMMReshapeLHSMatrixKernel
46using CLGEMMReshapeLHSMatrix = CLSynthetizeFunction<CLGEMMReshapeLHSMatrixKernel>;
47
48// Create function for CLGEMMReshapeRHSMatrixKernel
49using CLGEMMReshapeRHSMatrix = CLSynthetizeFunction<CLGEMMReshapeRHSMatrixKernel>;
50
51// Create function for CLGEMMMatrixMultiplyReshapedKernel
52using CLGEMMLowpMatrixMultiplyReshaped = CLSynthetizeFunction<CLGEMMLowpMatrixMultiplyReshapedKernel>;
53
54// Fixture for CLGEMMLowpMatrixMultiplyReshaped
55using CLGEMMLowpMatrixMultiplyReshapedFixture = GEMMLowpMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped>;
56
57// Fixture for CLGEMMMatrixMultiplyReshaped3D
58using CLGEMMLowpMatrixMultiplyReshaped3DFixture =
59 GEMMLowpMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped>;
60
61namespace
62{
63// *INDENT-OFF*
64// clang-format off
65/** M values to test */
66const auto m_values = framework::dataset::make("M", 37);
67
68/** M_W values to test */
69const auto m_w_values = framework::dataset::make("M_W", 5);
70
71/** M_H values to test */
72const auto m_h_values = framework::dataset::make("M_H", 7);
73
74/** N values to test */
75const auto n_values = framework::dataset::make("N", 51);
76
77/** K values to test */
78const auto k_values = framework::dataset::make("K", 23);
79
80/** Batch size values to test */
81const auto b_values = framework::dataset::make("batch_size", 1, 3);
82
83/** M0 values to test - Precommit */
84const auto m0_values_precommit = framework::dataset::make("M0", {4, 6});
85
86/** N0 values to test - Precommit */
87const auto n0_values_precommit = framework::dataset::make("N0", { 2, 4 });
88
89/** K0 values to test - Precommit */
90const auto k0_values_precommit = framework::dataset::make("K0", { 4 });
91
92/** V0 values to test - Precommit */
93const auto v0_values_precommit = framework::dataset::make("V0", 1, 3);
94
95/** H0 values to test - Precommit */
96const auto h0_values_precommit = framework::dataset::make("H0", 1, 3);
97
98/** M0 values to test - Nightly */
99const auto m0_values_nightly = framework::dataset::make("M0", 2, 7);
100
101/** N0 values to test - Nightly */
102const auto n0_values_nightly = framework::dataset::make("N0", { 2, 3, 4, 8 });
103
104/** K0 values to test - Nightly */
105const auto k0_values_nightly = framework::dataset::make("K0", { 2, 3, 4, 8 });
106
107/** V0 values to test - Nightly */
108const auto v0_values_nightly = framework::dataset::make("V0", 1, 4);
109
110/** H0 values to test - Nightly */
111const auto h0_values_nightly = framework::dataset::make("H0", 1, 4);
112
113/** Interleave values to test with LHS matrix */
114const auto i_values_lhs = framework::dataset::make("interleave_lhs", { true, false });
115
116/** Interleave values to test with RHS matrix */
117const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false });
118} // namespace
119
120TEST_SUITE(CL)
121TEST_SUITE(GEMMLowpMatrixMultiplyReshaped)
122FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMLowpMatrixMultiplyReshapedFixture, framework::DatasetMode::ALL,
123 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
124 m_values,
125 n_values),
126 k_values),
127 b_values),
128 m0_values_precommit),
129 n0_values_precommit),
130 k0_values_precommit),
131 v0_values_precommit),
132 h0_values_precommit),
133 i_values_lhs),
134 i_values_rhs))
135{
136 // Validate output
137 validate(CLAccessor(_target), _reference);
138}
139
140FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMLowpMatrixMultiplyReshapedFixture, framework::DatasetMode::NIGHTLY,
141 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
142 m_values,
143 n_values),
144 k_values),
145 b_values),
146 m0_values_nightly),
147 n0_values_nightly),
148 k0_values_nightly),
149 v0_values_nightly),
150 h0_values_nightly),
151 i_values_lhs),
152 i_values_rhs))
153{
154 // Validate output
155 validate(CLAccessor(_target), _reference);
156}
157
158FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMLowpMatrixMultiplyReshaped3DFixture, framework::DatasetMode::ALL,
159 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
160 m_w_values,
161 m_h_values),
162 n_values),
163 k_values),
164 b_values),
165 m0_values_precommit),
166 n0_values_precommit),
167 k0_values_precommit),
168 v0_values_precommit),
169 h0_values_precommit),
170 i_values_lhs),
171 i_values_rhs))
172{
173 // Validate output
174 validate(CLAccessor(_target), _reference);
175}
176
177FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMLowpMatrixMultiplyReshaped3DFixture, framework::DatasetMode::NIGHTLY,
178 combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(
179 m_w_values,
180 m_h_values),
181 n_values),
182 k_values),
183 b_values),
184 m0_values_nightly),
185 n0_values_nightly),
186 k0_values_nightly),
187 v0_values_nightly),
188 h0_values_nightly),
189 i_values_lhs),
190 i_values_rhs))
191{
192 // Validate output
193 validate(CLAccessor(_target), _reference);
194}
Gian Marco Iodice62251f72019-03-11 16:07:12 +0000195TEST_SUITE_END() // GEMMLowpMatrixMultiplyReshaped
Gian Marco Iodicedb63b9c2019-01-17 09:47:04 +0000196TEST_SUITE_END() // CL
197} // namespace validation
198} // namespace test
199} // namespace arm_compute