blob: aefa00192846d59c4fb208ed29886d11b2e13117 [file] [log] [blame]
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +00001/*
Gian Marco Iodicebacfec52019-01-11 11:30:55 +00002 * Copyright (c) 2018-2019 ARM Limited.
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +00003 *
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/CLGEMMReshapeRHSMatrixKernel.h"
25#include "arm_compute/core/Types.h"
26#include "arm_compute/core/utils/misc/ShapeCalculator.h"
27#include "arm_compute/runtime/CL/CLTensor.h"
28#include "arm_compute/runtime/CL/CLTensorAllocator.h"
29#include "tests/CL/CLAccessor.h"
30#include "tests/CL/Helper.h"
31#include "tests/PaddingCalculator.h"
32#include "tests/datasets/ShapeDatasets.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/GEMMReshapeRHSMatrixFixture.h"
38
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
45namespace
46{
47// *INDENT-OFF*
48// clang-format off
49/** Data types */
50const auto data_types = framework::dataset::make("DataType", { DataType::QASYMM8, DataType::F16, DataType::F32 });
51
52/** Batch size values to test */
53const auto b_values = framework::dataset::make("batchsize", 1, 3);
54
Gian Marco Iodice89124342018-12-19 14:17:22 +000055/** N0 values to test - Precommit */
56const auto n0_values_precommit = framework::dataset::make("N0", { 2, 4 });
57
58/** N0 values to test - Nightly */
Gian Marco Iodicebacfec52019-01-11 11:30:55 +000059const auto n0_values_nightly = framework::dataset::make("N0", { 2, 3, 4, 8, 16 });
Gian Marco Iodice89124342018-12-19 14:17:22 +000060
61/** K0 values to test (transpose=true) - Precommit */
62const auto k0_t_values_precommit = framework::dataset::make("K0", { 4 });
63
64/** K0 values to test (transpose=true) - Nightly */
Gian Marco Iodicebacfec52019-01-11 11:30:55 +000065const auto k0_t_values_nightly = framework::dataset::make("K0", { 2, 3, 4, 8, 16 });
Gian Marco Iodice89124342018-12-19 14:17:22 +000066
67/** K0 values to test (transpose=false) - Precommit */
68const auto k0_nt_values_precommit = framework::dataset::make("K0", { 1, 2, 4 });
69
70/** K0 values to test (transpose=false) - Nightly */
Gian Marco Iodicebacfec52019-01-11 11:30:55 +000071const auto k0_nt_values_nightly = framework::dataset::make("K0", { 1, 2, 3, 4, 8, 16 });
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +000072
73/** H0 values to test */
74const auto h0_values = framework::dataset::make("H0", 1, 4);
75
76/** Interleave values to test */
77const auto i_values = framework::dataset::make("interleave", { true, false });
78
79} // namespace
80
81using namespace arm_compute::misc::shape_calculator;
82
83// Initialize the output tensor with zero and fill the border with zero
84using CLGEMMReshapeRHSMatrix = CLSynthetizeFunctionInitOutputWithZeroAndWithZeroConstantBorder<CLGEMMReshapeRHSMatrixKernel, 16>;
85
86template <typename T>
87using CLGEMMReshapeRHSMatrixFixture = GEMMReshapeRHSMatrixValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeRHSMatrix, T>;
88
89TEST_SUITE(CL)
90TEST_SUITE(GEMMReshapeRHSMatrix)
91
92// This configuration tests only transpose = true
93DATA_TEST_CASE(Configuration0, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
94 b_values),
95 data_types),
Gian Marco Iodice89124342018-12-19 14:17:22 +000096 n0_values_nightly),
97 k0_t_values_nightly),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +000098 h0_values),
99 i_values),
100shape_in, b_value, data_type, n0_value, k0_value, h0_value, i_value)
101{
102 GEMMRHSMatrixInfo rhs_info;
103 rhs_info.n0 = n0_value;
104 rhs_info.k0 = k0_value;
105 rhs_info.h0 = h0_value;
106 rhs_info.interleave = i_value;
107 rhs_info.transpose = true;
108
109 const TensorShape shape_src(shape_in[0], shape_in[1], b_value);
110 const TensorShape shape_dst = compute_rhs_reshaped_shape(TensorInfo(shape_src, 1, data_type), rhs_info);
111
112 // Create tensors
113 CLTensor src = create_tensor<CLTensor>(shape_src, data_type);
114 CLTensor dst = create_tensor<CLTensor>(shape_dst, data_type);
115
116 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
117 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
118
119 // Create and configure function
120 CLGEMMReshapeRHSMatrixKernel reshape_rhs;
121 reshape_rhs.configure(&src, &dst, rhs_info);
122}
123
124// This configuration tests only transpose = false
125DATA_TEST_CASE(Configuration1, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
126 b_values),
127 data_types),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000128 n0_values_nightly),
129 k0_nt_values_nightly),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000130 h0_values),
131 i_values),
132shape_in, b_value, data_type, n0_value, k0_value, h0_value, i_value)
133{
134 GEMMRHSMatrixInfo rhs_info;
135 rhs_info.n0 = n0_value;
136 rhs_info.k0 = k0_value;
137 rhs_info.h0 = h0_value;
138 rhs_info.interleave = i_value;
139 rhs_info.transpose = false;
140
141 const TensorShape shape_src(shape_in[0], shape_in[1], b_value);
142 const TensorShape shape_dst = compute_rhs_reshaped_shape(TensorInfo(shape_src, 1, data_type), rhs_info);
143
144 // Create tensors
145 CLTensor src = create_tensor<CLTensor>(shape_src, data_type);
146 CLTensor dst = create_tensor<CLTensor>(shape_dst, data_type);
147
148 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
149 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
150
151 // Create and configure function
152 CLGEMMReshapeRHSMatrixKernel reshape_rhs;
153 reshape_rhs.configure(&src, &dst, rhs_info);
154}
155
156TEST_SUITE(S32)
157// RunSmall tests only for transpose = false
Gian Marco Iodice89124342018-12-19 14:17:22 +0000158FIXTURE_DATA_TEST_CASE(RunSmall0, CLGEMMReshapeRHSMatrixFixture<int>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000159 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
160 b_values),
161 framework::dataset::make("DataType", DataType::S32)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000162 n0_values_precommit),
163 k0_nt_values_precommit),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000164 h0_values),
165 i_values),
166 framework::dataset::make("transpose", false)))
167{
168 // Validate output
169 validate(CLAccessor(_target), _reference);
170}
171
172// RunSmall tests only for transpose = true
Gian Marco Iodice89124342018-12-19 14:17:22 +0000173FIXTURE_DATA_TEST_CASE(RunSmall1, CLGEMMReshapeRHSMatrixFixture<int>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000174 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
175 b_values),
176 framework::dataset::make("DataType", DataType::S32)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000177 n0_values_precommit),
178 k0_t_values_precommit),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000179 h0_values),
180 i_values),
181 framework::dataset::make("transpose", true)))
182{
183 // Validate output
184 validate(CLAccessor(_target), _reference);
185}
186
187// RunLarge tests only for transpose = false
188FIXTURE_DATA_TEST_CASE(RunLarge0, CLGEMMReshapeRHSMatrixFixture<int>, framework::DatasetMode::NIGHTLY,
189 combine(combine(combine(combine(combine(combine(combine(datasets::LargeGEMMReshape2DShapes(),
190 b_values),
191 framework::dataset::make("DataType", DataType::S32)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000192 n0_values_nightly),
193 k0_nt_values_nightly),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000194 h0_values),
195 i_values),
196 framework::dataset::make("transpose", false)))
197{
198 // Validate output
199 validate(CLAccessor(_target), _reference);
200}
201
202// RunLarge tests only for transpose = true
203FIXTURE_DATA_TEST_CASE(RunLarge1, CLGEMMReshapeRHSMatrixFixture<int>, framework::DatasetMode::NIGHTLY,
204 combine(combine(combine(combine(combine(combine(combine(datasets::LargeGEMMReshape2DShapes(),
205 b_values),
206 framework::dataset::make("DataType", DataType::S32)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000207 n0_values_nightly),
208 k0_t_values_nightly),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000209 h0_values),
210 i_values),
211 framework::dataset::make("transpose", true)))
212{
213 // Validate output
214 validate(CLAccessor(_target), _reference);
215}
216TEST_SUITE_END() // S32
217
218TEST_SUITE(S16)
219// RunSmall tests only for transpose = false
Gian Marco Iodice89124342018-12-19 14:17:22 +0000220FIXTURE_DATA_TEST_CASE(RunSmall0, CLGEMMReshapeRHSMatrixFixture<short>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000221 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
222 b_values),
Georgios Pinitasb5580c02018-12-24 16:34:18 +0000223 framework::dataset::make("DataType", DataType::S16)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000224 n0_values_precommit),
225 k0_nt_values_precommit),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000226 h0_values),
227 i_values),
228 framework::dataset::make("transpose", false)))
229{
230 // Validate output
231 validate(CLAccessor(_target), _reference);
232}
233
234// RunSmall tests only for transpose = true
Gian Marco Iodice89124342018-12-19 14:17:22 +0000235FIXTURE_DATA_TEST_CASE(RunSmall1, CLGEMMReshapeRHSMatrixFixture<short>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000236 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
237 b_values),
Georgios Pinitasb5580c02018-12-24 16:34:18 +0000238 framework::dataset::make("DataType", DataType::S16)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000239 n0_values_precommit),
240 k0_t_values_precommit),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000241 h0_values),
242 i_values),
243 framework::dataset::make("transpose", true)))
244{
245 // Validate output
246 validate(CLAccessor(_target), _reference);
247}
248
249// RunLarge tests only for transpose = false
250FIXTURE_DATA_TEST_CASE(RunLarge0, CLGEMMReshapeRHSMatrixFixture<short>, framework::DatasetMode::NIGHTLY,
251 combine(combine(combine(combine(combine(combine(combine(datasets::LargeGEMMReshape2DShapes(),
252 b_values),
Georgios Pinitasb5580c02018-12-24 16:34:18 +0000253 framework::dataset::make("DataType", DataType::S16)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000254 n0_values_nightly),
255 k0_nt_values_nightly),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000256 h0_values),
257 i_values),
258 framework::dataset::make("transpose", false)))
259{
260 // Validate output
261 validate(CLAccessor(_target), _reference);
262}
263
264// RunLarge tests only for transpose = true
265FIXTURE_DATA_TEST_CASE(RunLarge1, CLGEMMReshapeRHSMatrixFixture<short>, framework::DatasetMode::NIGHTLY,
266 combine(combine(combine(combine(combine(combine(combine(datasets::LargeGEMMReshape2DShapes(),
267 b_values),
Georgios Pinitasb5580c02018-12-24 16:34:18 +0000268 framework::dataset::make("DataType", DataType::S16)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000269 n0_values_nightly),
270 k0_t_values_nightly),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000271 h0_values),
272 i_values),
273 framework::dataset::make("transpose", true)))
274{
275 // Validate output
276 validate(CLAccessor(_target), _reference);
277}
278TEST_SUITE_END() // S16
279
280TEST_SUITE(S8)
281// RunSmall tests only for transpose = false
Gian Marco Iodice89124342018-12-19 14:17:22 +0000282FIXTURE_DATA_TEST_CASE(RunSmall0, CLGEMMReshapeRHSMatrixFixture<char>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000283 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
284 b_values),
Georgios Pinitasb5580c02018-12-24 16:34:18 +0000285 framework::dataset::make("DataType", DataType::S8)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000286 n0_values_precommit),
287 k0_nt_values_precommit),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000288 h0_values),
289 i_values),
290 framework::dataset::make("transpose", false)))
291{
292 // Validate output
293 validate(CLAccessor(_target), _reference);
294}
295
296// RunSmall tests only for transpose = true
Gian Marco Iodice89124342018-12-19 14:17:22 +0000297FIXTURE_DATA_TEST_CASE(RunSmall1, CLGEMMReshapeRHSMatrixFixture<char>, framework::DatasetMode::PRECOMMIT,
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000298 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
299 b_values),
Georgios Pinitasb5580c02018-12-24 16:34:18 +0000300 framework::dataset::make("DataType", DataType::S8)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000301 n0_values_precommit),
302 k0_t_values_precommit),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000303 h0_values),
304 i_values),
305 framework::dataset::make("transpose", true)))
306{
307 // Validate output
308 validate(CLAccessor(_target), _reference);
309}
310
311// RunLarge tests only for transpose = false
312FIXTURE_DATA_TEST_CASE(RunLarge0, CLGEMMReshapeRHSMatrixFixture<char>, framework::DatasetMode::NIGHTLY,
313 combine(combine(combine(combine(combine(combine(combine(datasets::LargeGEMMReshape2DShapes(),
314 b_values),
Georgios Pinitasb5580c02018-12-24 16:34:18 +0000315 framework::dataset::make("DataType", DataType::S8)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000316 n0_values_nightly),
317 k0_nt_values_nightly),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000318 h0_values),
319 i_values),
320 framework::dataset::make("transpose", false)))
321{
322 // Validate output
323 validate(CLAccessor(_target), _reference);
324}
325
326// RunLarge tests only for transpose = true
327FIXTURE_DATA_TEST_CASE(RunLarge1, CLGEMMReshapeRHSMatrixFixture<char>, framework::DatasetMode::NIGHTLY,
328 combine(combine(combine(combine(combine(combine(combine(datasets::LargeGEMMReshape2DShapes(),
329 b_values),
Georgios Pinitasb5580c02018-12-24 16:34:18 +0000330 framework::dataset::make("DataType", DataType::S8)),
Gian Marco Iodice89124342018-12-19 14:17:22 +0000331 n0_values_nightly),
332 k0_t_values_nightly),
Gian Marco Iodice3b0a2652018-12-07 11:18:09 +0000333 h0_values),
334 i_values),
335 framework::dataset::make("transpose", true)))
336{
337 // Validate output
338 validate(CLAccessor(_target), _reference);
339}
340TEST_SUITE_END() // S8
341TEST_SUITE_END() // GEMMReshapeRHSMatrix
342TEST_SUITE_END() // CL
343} // namespace validation
344} // namespace test
345} // namespace arm_compute