Compute Library
 22.11
GEMMLowpMatrixMultiplyReshaped.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2021 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/Types.h"
29 #include "tests/CL/CLAccessor.h"
30 #include "tests/CL/Helper.h"
32 #include "tests/framework/Macros.h"
35 #include "tests/validation/fixtures/GEMMLowpFixture.h"
36 
37 namespace arm_compute
38 {
39 namespace test
40 {
41 namespace validation
42 {
44 
45 // Create function for ClGemmReshapeLhsMatrixKernel
47 
48 // Create function for ClGemmReshapeRhsMatrixKernel
50 
51 // Create function for CLGEMMLowpMatrixMultiplyReshapedKernel
53 
54 // Fixture for CLGEMMLowpMatrixMultiplyReshaped
55 using CLGEMMLowpMatrixMultiplyReshapedFixture = GEMMLowpMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped>;
56 
57 // Fixture for CLGEMMMatrixMultiplyReshaped3D
59  GEMMLowpMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped>;
60 
61 namespace
62 {
63 // *INDENT-OFF*
64 // clang-format off
65 
66 /** M, N combinations to test
67  * 1: Special 1x1 case
68  * 2: Special multples of processor size in both dimensions
69  * 3: Non multiples of processor size in both dimensions
70 */
71 const auto m_n_values = zip(
72  framework::dataset::make("M", {1, 16, 37}),
73  framework::dataset::make("N", {1, 16, 51})
74  );
75 
76 /** M values to test */
77 const auto m_values = framework::dataset::make("M", {1, 37});
78 
79 /** M_W values to test */
80 const auto m_w_values = framework::dataset::make("M_W", 5);
81 
82 /** M_H values to test */
83 const auto m_h_values = framework::dataset::make("M_H", 7);
84 
85 /** N values to test */
86 const auto n_values = framework::dataset::make("N", {1, 51});
87 
88 /** K values to test */
89 const auto k_values = framework::dataset::make("K", 23);
90 
91 /** Batch size values to test */
92 const auto b_values = framework::dataset::make("batch_size", 1, 3);
93 
94 /** M0 values to test - Precommit */
95 const auto m0_values_precommit_1 = framework::dataset::make("M0", { 4 });
96 const auto m0_values_precommit_2 = framework::dataset::make("M0", { 6 });
97 
98 /** N0 values to test - Precommit */
99 const auto n0_values_precommit = framework::dataset::make("N0", { 4 });
100 
101 /** K0 values to test - Precommit */
102 const auto k0_values_precommit = framework::dataset::make("K0", { 16 });
103 
104 /** V0 values to test - Precommit */
105 const auto v0_values_precommit = framework::dataset::make("V0", 1, 3);
106 
107 /** H0 values to test - Precommit */
108 const auto h0_values_precommit = framework::dataset::make("H0", 1, 3);
109 
110 /** M0 values to test - Nightly */
111 const auto m0_values_nightly = framework::dataset::make("M0", 2, 7);
112 
113 /** N0 values to test - Nightly */
114 const auto n0_values_nightly = framework::dataset::make("N0", { 2, 3, 4, 8 });
115 
116 /** K0 values to test - Nightly */
117 const auto k0_values_nightly = framework::dataset::make("K0", { 2, 3, 4, 8, 16 });
118 
119 /** V0 values to test - Nightly */
120 const auto v0_values_nightly = framework::dataset::make("V0", 1, 4);
121 
122 /** H0 values to test - Nightly */
123 const auto h0_values_nightly = framework::dataset::make("H0", 1, 4);
124 
125 /** Interleave values to test with LHS matrix */
126 const auto i_values_lhs = framework::dataset::make("interleave_lhs", { true, false });
127 
128 /** Interleave values to test with RHS matrix */
129 const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false });
130 } // namespace
131 
132 TEST_SUITE(CL)
133 TEST_SUITE(GEMMLowpMatrixMultiplyReshaped)
134 
135 TEST_SUITE(QUANTIZED)
136 
140  m_n_values,
141  k_values),
142  b_values),
143  m0_values_precommit_1),
144  n0_values_precommit),
145  k0_values_precommit),
146  v0_values_precommit),
147  h0_values_precommit),
148  i_values_lhs),
149  i_values_rhs),
150  framework::dataset::make("DataType", { DataType::QASYMM8 })))
151 {
152  // Validate output
153  validate(CLAccessor(_target), _reference);
154 }
155 
158  m_values,
159  n_values),
160  k_values),
161  b_values),
162  m0_values_nightly),
163  n0_values_nightly),
164  k0_values_nightly),
165  v0_values_nightly),
166  h0_values_nightly),
167  i_values_lhs),
168  i_values_rhs),
170 {
171  // Validate output
172  validate(CLAccessor(_target), _reference);
173 }
174 
177  m_w_values,
178  m_h_values),
179  n_values),
180  k_values),
181  b_values),
182  m0_values_precommit_1),
183  n0_values_precommit),
184  k0_values_precommit),
185  v0_values_precommit),
186  h0_values_precommit),
187  i_values_lhs),
188  i_values_rhs),
190 {
191  // Validate output
192  validate(CLAccessor(_target), _reference);
193 }
194 
197  m_w_values,
198  m_h_values),
199  n_values),
200  k_values),
201  b_values),
202  m0_values_nightly),
203  n0_values_nightly),
204  k0_values_nightly),
205  v0_values_nightly),
206  h0_values_nightly),
207  i_values_lhs),
208  i_values_rhs),
210 {
211  // Validate output
212  validate(CLAccessor(_target), _reference);
213 }
214 TEST_SUITE_END() // QASYMM8
215 
219  m_n_values,
220  k_values),
221  b_values),
222  m0_values_precommit_2),
223  n0_values_precommit),
224  k0_values_precommit),
225  v0_values_precommit),
226  h0_values_precommit),
227  i_values_lhs),
228  i_values_rhs),
230 {
231  // Validate output
232  validate(CLAccessor(_target), _reference);
233 }
236  m_w_values,
237  m_h_values),
238  n_values),
239  k_values),
240  b_values),
241  m0_values_precommit_2),
242  n0_values_precommit),
243  k0_values_precommit),
244  v0_values_precommit),
245  h0_values_precommit),
246  i_values_lhs),
247  i_values_rhs),
249 {
250  // Validate output
251  validate(CLAccessor(_target), _reference);
252 }
253 TEST_SUITE_END() // QASYMM8_SIGNED
254 
255 TEST_SUITE_END() // QUANTIZED
256 TEST_SUITE_END() // GEMMLowpMatrixMultiplyReshaped
257 TEST_SUITE_END() // CL
258 } // namespace validation
259 } // namespace test
260 } // namespace arm_compute
GEMMLowpMatrixMultiplyReshapedValidationFixture< CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped > CLGEMMLowpMatrixMultiplyReshapedFixture
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
Copyright (c) 2017-2022 Arm Limited.
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
quantized, asymmetric fixed-point 8-bit number unsigned
Accessor implementation for CLTensor objects.
Definition: CLAccessor.h:36
GEMMLowpMatrixMultiplyReshaped3DValidationFixture< CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped > CLGEMMLowpMatrixMultiplyReshaped3DFixture
validate(CLAccessor(output_state), expected_output)
This template synthetizes a simple IOperator which runs the given kernel K.
Definition: Helper.h:46
FIXTURE_DATA_TEST_CASE(RunSmall, CLAbsLayerFixture< half >, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)))
Definition: AbsLayer.cpp:50
quantized, asymmetric fixed-point 8-bit number signed
zip(zip(framework::dataset::make("Weights", { TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 1U), 1, DataType::F32), }), framework::dataset::make("MVBGInfo",{ TensorInfo(TensorShape(2U), 1, DataType::F32), TensorInfo(TensorShape(2U), 1, DataType::F16), TensorInfo(TensorShape(5U), 1, DataType::F32), })), framework::dataset::make("Expected", { true, false, false}))
TEST_SUITE(QASYMM8_to_F32) FIXTURE_DATA_TEST_CASE(RunSmall
DataType
Available data types.
Definition: Types.h:79
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))
Definition: AbsLayer.cpp:65