blob: 34c37dffdea742f7e9a79d9b546b1ec0112b4960 [file] [log] [blame]
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2020 Arm Limited.
Gian Marco Iodice5ba5e092018-12-06 17:13: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 */
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +000024#include "arm_compute/core/Types.h"
25#include "arm_compute/core/utils/misc/ShapeCalculator.h"
26#include "arm_compute/runtime/CL/CLTensor.h"
27#include "arm_compute/runtime/CL/CLTensorAllocator.h"
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010028#include "src/core/CL/kernels/CLGEMMReshapeLHSMatrixKernel.h"
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +000029#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/GEMMReshapeLHSMatrixFixture.h"
38
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +000045using namespace arm_compute::misc::shape_calculator;
46
47// Initialize the output tensor with zero and fill the border with zero
48using CLGEMMReshapeLHSMatrix = CLSynthetizeFunctionInitOutputWithZeroAndWithZeroConstantBorder<CLGEMMReshapeLHSMatrixKernel, 16>;
49
50template <typename T>
51using CLGEMMReshapeLHSMatrixFixture = GEMMReshapeLHSMatrixValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, T, false>;
52
53// Fixture to use when the input has to be reinterpreted as 3D
54template <typename T>
55using CLGEMMReshapeLHSMatrix3DFixture = GEMMReshapeLHSMatrixValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, T, true>;
56
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +000057// *INDENT-OFF*
58// clang-format off
59/** Data types */
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +000060
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +000061namespace
62{
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +000063/** Batch size values to test */
64const auto b_values = framework::dataset::make("batchsize", 1, 3);
65
Michalis Spyrou8bb8de32020-04-29 13:22:15 +010066/** M0 values to test */
67const auto m0_values_s32 = framework::dataset::make("M0", { 2, 3 });
68const auto m0_values_s16 = framework::dataset::make("M0", { 4, 5 });
69const auto m0_values_s8 = framework::dataset::make("M0", { 6, 7, 8 });
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +000070
Michalis Spyrou8bb8de32020-04-29 13:22:15 +010071/** K0 values to test */
72const auto k0_values_s32 = framework::dataset::make("K0", { 2, 3 });
73const auto k0_values_s16 = framework::dataset::make("K0", { 4, 8 });
74const auto k0_values_s8 = framework::dataset::make("K0", { 16 });
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +000075
76/** V0 values to test */
77const auto v0_values = framework::dataset::make("V0", 1, 4);
78
79/** Interleave values to test */
80const auto i_values = framework::dataset::make("interleave", { true, false });
81
82/** Transpose values to test */
83const auto t_values = framework::dataset::make("transpose", { true, false });
Gian Marco Iodice73cdaac2020-08-10 21:44:14 +010084
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +000085} // namespace
86
87TEST_SUITE(CL)
88TEST_SUITE(GEMMReshapeLHSMatrix)
Gian Marco Iodice73cdaac2020-08-10 21:44:14 +010089
Michalis Spyrou8bb8de32020-04-29 13:22:15 +010090FIXTURE_DATA_TEST_CASE(S32, CLGEMMReshapeLHSMatrixFixture<int>, framework::DatasetMode::ALL,
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +000091 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
92 b_values),
93 framework::dataset::make("DataType", DataType::S32)),
Michalis Spyrou8bb8de32020-04-29 13:22:15 +010094 m0_values_s32),
95 k0_values_s32),
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +000096 v0_values),
97 i_values),
98 t_values))
99{
100 // Validate output
101 validate(CLAccessor(_target), _reference);
102}
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100103FIXTURE_DATA_TEST_CASE(S16, CLGEMMReshapeLHSMatrixFixture<short>, framework::DatasetMode::ALL,
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000104 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
105 b_values),
106 framework::dataset::make("DataType", DataType::S16)),
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100107 m0_values_s16),
108 k0_values_s16),
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000109 v0_values),
110 i_values),
111 t_values))
112{
113 // Validate output
114 validate(CLAccessor(_target), _reference);
115}
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100116FIXTURE_DATA_TEST_CASE(S8, CLGEMMReshapeLHSMatrixFixture<char>, framework::DatasetMode::ALL,
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000117 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape2DShapes(),
118 b_values),
119 framework::dataset::make("DataType", DataType::S8)),
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100120 m0_values_s8),
121 k0_values_s8),
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000122 v0_values),
123 i_values),
124 t_values))
125{
126 // Validate output
127 validate(CLAccessor(_target), _reference);
128}
129
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +0000130TEST_SUITE(ReinterpretInputAs3D)
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100131FIXTURE_DATA_TEST_CASE(S32, CLGEMMReshapeLHSMatrix3DFixture<int>, framework::DatasetMode::ALL,
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000132 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape3DShapes(),
133 b_values),
134 framework::dataset::make("DataType", DataType::S32)),
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100135 m0_values_s32),
136 k0_values_s32),
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000137 v0_values),
138 i_values),
139 t_values))
140{
141 // Validate output
142 validate(CLAccessor(_target), _reference);
143}
144
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100145FIXTURE_DATA_TEST_CASE(S16, CLGEMMReshapeLHSMatrix3DFixture<short>, framework::DatasetMode::ALL,
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000146 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape3DShapes(),
147 b_values),
148 framework::dataset::make("DataType", DataType::S16)),
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100149 m0_values_s16),
150 k0_values_s16),
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000151 v0_values),
152 i_values),
153 t_values))
154{
155 // Validate output
156 validate(CLAccessor(_target), _reference);
157}
158
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100159FIXTURE_DATA_TEST_CASE(S8, CLGEMMReshapeLHSMatrix3DFixture<char>, framework::DatasetMode::ALL,
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000160 combine(combine(combine(combine(combine(combine(combine(datasets::SmallGEMMReshape3DShapes(),
161 b_values),
162 framework::dataset::make("DataType", DataType::S8)),
Michalis Spyrou8bb8de32020-04-29 13:22:15 +0100163 m0_values_s8),
164 k0_values_s8),
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000165 v0_values),
166 i_values),
167 t_values))
168{
169 // Validate output
170 validate(CLAccessor(_target), _reference);
171}
Gian Marco Iodice08ddd7b2018-12-19 10:01:18 +0000172TEST_SUITE_END() // ReinterpretInputAs3D
Gian Marco Iodice5ba5e092018-12-06 17:13:09 +0000173TEST_SUITE_END() // GEMMReshapeLHSMatrix
174TEST_SUITE_END() // CL
175} // namespace validation
176} // namespace test
Gian Marco Iodice73cdaac2020-08-10 21:44:14 +0100177} // namespace arm_compute