Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2019-2020 Arm Limited. |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 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 | */ |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 24 | #include "arm_compute/core/Types.h" |
| 25 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 26 | #include "src/core/CL/kernels/CLGEMMLowpMatrixMultiplyReshapedKernel.h" |
| 27 | #include "src/core/CL/kernels/CLGEMMReshapeLHSMatrixKernel.h" |
| 28 | #include "src/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h" |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 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 | |
| 37 | namespace arm_compute |
| 38 | { |
| 39 | namespace test |
| 40 | { |
| 41 | namespace validation |
| 42 | { |
| 43 | using namespace arm_compute::misc::shape_calculator; |
| 44 | |
| 45 | // Create function for CLGEMMReshapeLHSMatrixKernel |
| 46 | using CLGEMMReshapeLHSMatrix = CLSynthetizeFunction<CLGEMMReshapeLHSMatrixKernel>; |
| 47 | |
| 48 | // Create function for CLGEMMReshapeRHSMatrixKernel |
| 49 | using CLGEMMReshapeRHSMatrix = CLSynthetizeFunction<CLGEMMReshapeRHSMatrixKernel>; |
| 50 | |
| 51 | // Create function for CLGEMMMatrixMultiplyReshapedKernel |
| 52 | using CLGEMMLowpMatrixMultiplyReshaped = CLSynthetizeFunction<CLGEMMLowpMatrixMultiplyReshapedKernel>; |
| 53 | |
| 54 | // Fixture for CLGEMMLowpMatrixMultiplyReshaped |
| 55 | using CLGEMMLowpMatrixMultiplyReshapedFixture = GEMMLowpMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped>; |
| 56 | |
| 57 | // Fixture for CLGEMMMatrixMultiplyReshaped3D |
| 58 | using CLGEMMLowpMatrixMultiplyReshaped3DFixture = |
| 59 | GEMMLowpMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped>; |
| 60 | |
| 61 | namespace |
| 62 | { |
| 63 | // *INDENT-OFF* |
| 64 | // clang-format off |
SiCong Li | 7e5b7bf | 2020-11-17 09:41:13 +0000 | [diff] [blame] | 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 | |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 76 | /** M values to test */ |
SiCong Li | 7e5b7bf | 2020-11-17 09:41:13 +0000 | [diff] [blame] | 77 | const auto m_values = framework::dataset::make("M", {1, 37}); |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 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 */ |
SiCong Li | 7e5b7bf | 2020-11-17 09:41:13 +0000 | [diff] [blame] | 86 | const auto n_values = framework::dataset::make("N", {1, 51}); |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 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 */ |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 95 | const auto m0_values_precommit_1 = framework::dataset::make("M0", { 4 }); |
| 96 | const auto m0_values_precommit_2 = framework::dataset::make("M0", { 6 }); |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 97 | |
| 98 | /** N0 values to test - Precommit */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 99 | const auto n0_values_precommit = framework::dataset::make("N0", { 4 }); |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 100 | |
| 101 | /** K0 values to test - Precommit */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 102 | const auto k0_values_precommit = framework::dataset::make("K0", { 16 }); |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 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 */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 117 | const auto k0_values_nightly = framework::dataset::make("K0", { 2, 3, 4, 8, 16 }); |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 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) |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 134 | |
| 135 | TEST_SUITE(QUANTIZED) |
| 136 | |
| 137 | TEST_SUITE(QASYMM8) |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 138 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMLowpMatrixMultiplyReshapedFixture, framework::DatasetMode::ALL, |
SiCong Li | 7e5b7bf | 2020-11-17 09:41:13 +0000 | [diff] [blame] | 139 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 140 | m_n_values, |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 141 | k_values), |
| 142 | b_values), |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 143 | m0_values_precommit_1), |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 144 | n0_values_precommit), |
| 145 | k0_values_precommit), |
| 146 | v0_values_precommit), |
| 147 | h0_values_precommit), |
| 148 | i_values_lhs), |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 149 | i_values_rhs), |
| 150 | framework::dataset::make("DataType", { DataType::QASYMM8 }))) |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 151 | { |
| 152 | // Validate output |
| 153 | validate(CLAccessor(_target), _reference); |
| 154 | } |
| 155 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 156 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMLowpMatrixMultiplyReshapedFixture, framework::DatasetMode::DISABLED, |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 157 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 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), |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 168 | i_values_rhs), |
| 169 | framework::dataset::make("DataType", { DataType::QASYMM8 }))) |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 170 | { |
| 171 | // Validate output |
| 172 | validate(CLAccessor(_target), _reference); |
| 173 | } |
| 174 | |
| 175 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMLowpMatrixMultiplyReshaped3DFixture, framework::DatasetMode::ALL, |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 176 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 177 | m_w_values, |
| 178 | m_h_values), |
| 179 | n_values), |
| 180 | k_values), |
| 181 | b_values), |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 182 | m0_values_precommit_1), |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 183 | n0_values_precommit), |
| 184 | k0_values_precommit), |
| 185 | v0_values_precommit), |
| 186 | h0_values_precommit), |
| 187 | i_values_lhs), |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 188 | i_values_rhs), |
| 189 | framework::dataset::make("DataType", { DataType::QASYMM8 }))) |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 190 | { |
| 191 | // Validate output |
| 192 | validate(CLAccessor(_target), _reference); |
| 193 | } |
| 194 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 195 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMLowpMatrixMultiplyReshaped3DFixture, framework::DatasetMode::DISABLED, |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 196 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 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), |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 208 | i_values_rhs), |
| 209 | framework::dataset::make("DataType", { DataType::QASYMM8 }))) |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 210 | { |
| 211 | // Validate output |
| 212 | validate(CLAccessor(_target), _reference); |
| 213 | } |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 214 | TEST_SUITE_END() // QASYMM8 |
| 215 | |
| 216 | TEST_SUITE(QASYMM8_SIGNED) |
| 217 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMLowpMatrixMultiplyReshapedFixture, framework::DatasetMode::ALL, |
SiCong Li | 7e5b7bf | 2020-11-17 09:41:13 +0000 | [diff] [blame] | 218 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 219 | m_n_values, |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 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), |
| 229 | framework::dataset::make("DataType", { DataType::QASYMM8_SIGNED }))) |
| 230 | { |
| 231 | // Validate output |
| 232 | validate(CLAccessor(_target), _reference); |
| 233 | } |
| 234 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMLowpMatrixMultiplyReshaped3DFixture, framework::DatasetMode::ALL, |
| 235 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 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), |
| 248 | framework::dataset::make("DataType", { DataType::QASYMM8_SIGNED }))) |
| 249 | { |
| 250 | // Validate output |
| 251 | validate(CLAccessor(_target), _reference); |
| 252 | } |
| 253 | TEST_SUITE_END() // QASYMM8_SIGNED |
| 254 | |
| 255 | TEST_SUITE_END() // QUANTIZED |
Gian Marco Iodice | 62251f7 | 2019-03-11 16:07:12 +0000 | [diff] [blame] | 256 | TEST_SUITE_END() // GEMMLowpMatrixMultiplyReshaped |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 257 | TEST_SUITE_END() // CL |
| 258 | } // namespace validation |
| 259 | } // namespace test |
Sheri Zhang | 28287af | 2020-02-25 14:13:54 +0000 | [diff] [blame] | 260 | } // namespace arm_compute |