Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 1 | /* |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18: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 | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 24 | #include "arm_compute/core/KernelDescriptors.h" |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 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" |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 29 | #include "src/core/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.h" |
| 30 | #include "src/core/gpu/cl/kernels/ClGemmReshapeLhsMatrixKernel.h" |
| 31 | #include "src/core/gpu/cl/kernels/ClGemmReshapeRhsMatrixKernel.h" |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 32 | #include "tests/CL/CLAccessor.h" |
| 33 | #include "tests/CL/Helper.h" |
| 34 | #include "tests/PaddingCalculator.h" |
| 35 | #include "tests/datasets/ShapeDatasets.h" |
| 36 | #include "tests/framework/Asserts.h" |
| 37 | #include "tests/framework/Macros.h" |
| 38 | #include "tests/framework/datasets/Datasets.h" |
| 39 | #include "tests/validation/Validation.h" |
| 40 | #include "tests/validation/fixtures/GEMMFixture.h" |
| 41 | |
| 42 | namespace arm_compute |
| 43 | { |
| 44 | namespace test |
| 45 | { |
| 46 | namespace validation |
| 47 | { |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 48 | using namespace arm_compute::misc::shape_calculator; |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 49 | using namespace arm_compute::opencl::kernels; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 50 | |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 51 | // Create function for ClGemmReshapeLhsMatrixKernel |
| 52 | using CLGEMMReshapeLHSMatrix = CLSynthetizeOperator<ClGemmReshapeLhsMatrixKernel>; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 53 | |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 54 | // Create function for ClGemmReshapeRhsMatrixKernel |
| 55 | using CLGEMMReshapeRHSMatrix = CLSynthetizeOperator<ClGemmReshapeRhsMatrixKernel>; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 56 | |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 57 | // Create function for ClGemmMatrixMultiplyReshapedKernel |
| 58 | using CLGEMMMatrixMultiplyReshaped = CLSynthetizeOperator<ClGemmMatrixMultiplyReshapedKernel>; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 59 | |
| 60 | // Fixture for CLGEMMMatrixMultiplyReshaped |
| 61 | template <typename T> |
| 62 | using CLGEMMMatrixMultiplyReshapedFixture = GEMMMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>; |
| 63 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 64 | // Fixture for CLGEMMMatrixMultiplyReshaped mixed precision |
| 65 | template <typename T> |
| 66 | using CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture = |
| 67 | GEMMMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>; |
| 68 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 69 | // Fixture for CLGEMMMatrixMultiplyReshaped3D |
| 70 | template <typename T> |
| 71 | using CLGEMMMatrixMultiplyReshaped3DFixture = GEMMMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>; |
| 72 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 73 | // Fixture for CLGEMMMatrixMultiplyReshaped3D mixed precision |
| 74 | template <typename T> |
| 75 | using CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture = |
| 76 | GEMMMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>; |
| 77 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 78 | namespace |
| 79 | { |
| 80 | // *INDENT-OFF* |
| 81 | // clang-format off |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 82 | RelativeTolerance<float> rel_tolerance_f32(0.001f); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 83 | constexpr float abs_tolerance_f32(0.0001f); |
| 84 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 85 | RelativeTolerance<float> rel_tolerance_f16_mixed_precision(0.001f); |
| 86 | constexpr float abs_tolerance_f16_mixed_precision(0.01f); |
| 87 | |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 88 | RelativeTolerance<float> rel_tolerance_f16(0.001f); |
| 89 | constexpr float abs_tolerance_f16(0.01f); |
| 90 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 91 | /** M values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 92 | const auto m_values = framework::dataset::make("M", 17); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 93 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 94 | /** M_W values to test */ |
| 95 | const auto m_w_values = framework::dataset::make("M_W", 5); |
| 96 | |
| 97 | /** M_H values to test */ |
| 98 | const auto m_h_values = framework::dataset::make("M_H", 7); |
| 99 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 100 | /** N values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 101 | const auto n_values = framework::dataset::make("N", 21); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 102 | |
| 103 | /** K values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 104 | const auto k_values = framework::dataset::make("K", 13); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 105 | |
| 106 | /** Batch size values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 107 | const auto b_values = framework::dataset::make("batch_size", 2, 3); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 108 | |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 109 | /** Activation values to test */ |
| 110 | const auto act_values = framework::dataset::make("Activation", |
| 111 | { |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 112 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 8.f, 2.f), |
| 113 | }); |
| 114 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 115 | /** Alpha values to test - Precommit */ |
| 116 | const auto a_values_precommit = framework::dataset::make("alpha", {-0.75f} ); |
| 117 | |
| 118 | /** Beta values to test - Precommit */ |
| 119 | const auto beta_values_precommit = framework::dataset::make("beta", {-0.35f} ); |
| 120 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 121 | /** M0 values to test - Precommit */ |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 122 | const auto m0_values_precommit = framework::dataset::make("M0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 123 | |
| 124 | /** N0 values to test - Precommit */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 125 | const auto n0_values_precommit = framework::dataset::make("N0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 126 | |
| 127 | /** K0 values to test - Precommit */ |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 128 | const auto k0_values_precommit = framework::dataset::make("K0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 129 | |
| 130 | /** V0 values to test - Precommit */ |
| 131 | const auto v0_values_precommit = framework::dataset::make("V0", 1, 3); |
| 132 | |
| 133 | /** H0 values to test - Precommit */ |
| 134 | const auto h0_values_precommit = framework::dataset::make("H0", 1, 3); |
| 135 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 136 | /** Alpha values to test - Nightly */ |
| 137 | const auto a_values_nightly = framework::dataset::make("alpha", {1.0f} ); |
| 138 | |
| 139 | /** Beta values to test - Nightly */ |
| 140 | const auto beta_values_nightly = framework::dataset::make("beta", {1.0f} ); |
| 141 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 142 | /** M0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 143 | const auto m0_values_nightly = framework::dataset::make("M0", { 8 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 144 | |
| 145 | /** N0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 146 | const auto n0_values_nightly = framework::dataset::make("N0", { 8 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 147 | |
| 148 | /** K0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 149 | const auto k0_values_nightly = framework::dataset::make("K0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 150 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 151 | /** N0 values to test with export to OpenCL image object - Nightly */ |
| 152 | const auto n0_export_to_cl_image_values_nightly = framework::dataset::make("N0", { 4, 8, 16 }); |
| 153 | |
| 154 | /** K0 values to test with export to OpenCL image object - Nightly */ |
| 155 | const auto k0_export_to_cl_image_values_nightly = framework::dataset::make("K0", { 4, 8, 16 }); |
| 156 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 157 | /** V0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 158 | const auto v0_values_nightly = framework::dataset::make("V0", 1, 3); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 159 | |
| 160 | /** H0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 161 | const auto h0_values_nightly = framework::dataset::make("H0", 1, 3); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 162 | |
| 163 | /** Interleave values to test with LHS matrix */ |
| 164 | const auto i_values_lhs = framework::dataset::make("interleave_lhs", { true, false }); |
| 165 | |
| 166 | /** Interleave values to test with RHS matrix */ |
| 167 | const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false }); |
| 168 | |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 169 | /** Broadcast bias from vector to matrix */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 170 | const auto broadcast_bias_values = framework::dataset::make("broadcast_bias", { false, true } ); |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 171 | |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 172 | /** LHS transposed values */ |
| 173 | const auto lhs_transpose_values = framework::dataset::make("lhs_transpose", { false, true } ); |
Gian Marco Iodice | 088d63a | 2020-08-11 14:14:06 +0100 | [diff] [blame] | 174 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 175 | } // namespace |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 176 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 177 | TEST_SUITE(CL) |
| 178 | TEST_SUITE(GEMMMatrixMultiplyReshaped) |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 179 | |
| 180 | // *INDENT-OFF* |
| 181 | // clang-format off |
| 182 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( |
| 183 | framework::dataset::make("Input0Info", { TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // OK |
| 184 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK |
| 185 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8), // Data type not supported |
| 186 | TensorInfo(TensorShape(10U, 5U, 2U), 1, DataType::F32), // Incorrect dimension bias |
| 187 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // Mismatching shapes |
| 188 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, do not broadcast bias |
| 189 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, wider accummulation |
| 190 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, RHS 4,4,2 |
| 191 | |
| 192 | }), |
| 193 | framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32), |
| 194 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16), |
| 195 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8), |
| 196 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32), |
| 197 | TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), |
| 198 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16), |
| 199 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16), |
| 200 | TensorInfo(TensorShape(128U, 3U, 2U), 1, DataType::F16), |
| 201 | |
| 202 | })), |
| 203 | framework::dataset::make("Input2Info", { TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 204 | TensorInfo(TensorShape(21U), 1, DataType::F16), |
| 205 | TensorInfo(TensorShape(21U), 1, DataType::QASYMM8), |
| 206 | TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 207 | TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 208 | TensorInfo(TensorShape(21U,17U), 1, DataType::F16), |
| 209 | TensorInfo(TensorShape(21U,17U), 1, DataType::F16), |
| 210 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 211 | |
| 212 | })), |
| 213 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32), |
| 214 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 215 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::QASYMM8), |
| 216 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32), |
| 217 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32), |
| 218 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 219 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 220 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 221 | |
| 222 | })), |
| 223 | framework::dataset::make("LHSMInfo",{ |
| 224 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 225 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 226 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 227 | GEMMLHSMatrixInfo(4,2,4,false,false), |
| 228 | GEMMLHSMatrixInfo(4,2,4,false,false), |
| 229 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 230 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 231 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 232 | |
| 233 | })), |
| 234 | framework::dataset::make("RHSMInfo",{ |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 235 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 236 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 237 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 238 | GEMMRHSMatrixInfo(2,2,1,true,false,false), |
| 239 | GEMMRHSMatrixInfo(2,2,1,true,false,false), |
| 240 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 241 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 242 | GEMMRHSMatrixInfo(4,4,2,true,false,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 243 | |
| 244 | |
| 245 | })), |
| 246 | |
| 247 | |
| 248 | framework::dataset::make("GEMMInfo",{ |
| 249 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 250 | 21 /**<N Number of RHS columns*/, |
| 251 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 252 | false /**< reinterpret the input as 3D */, |
| 253 | true /**< Flag used to broadcast the bias addition */, |
| 254 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 255 | false /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 256 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 257 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 258 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 259 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 260 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 261 | 0 /**< Offset to be added to each element of the matrix A */, |
| 262 | 0 /**< Offset to be added to each element of the matrix B */), |
| 263 | |
| 264 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 265 | 21 /**<N Number of RHS columns*/, |
| 266 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 267 | false /**< reinterpret the input as 3D */, |
| 268 | true /**< Flag used to broadcast the bias addition */, |
| 269 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 270 | false /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 271 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 272 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 273 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 274 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 275 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 276 | 0 /**< Offset to be added to each element of the matrix A */, |
| 277 | 0 /**< Offset to be added to each element of the matrix B */), |
| 278 | GEMMKernelInfo(), |
| 279 | GEMMKernelInfo(), |
| 280 | GEMMKernelInfo(), |
| 281 | |
| 282 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 283 | 21 /**<N Number of RHS columns*/, |
| 284 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 285 | false /**< reinterpret the input as 3D */, |
| 286 | false /**< Flag used to broadcast the bias addition */, |
| 287 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 288 | false /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 289 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 290 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 291 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 292 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 293 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 294 | 0 /**< Offset to be added to each element of the matrix A */, |
| 295 | 0 /**< Offset to be added to each element of the matrix B */), |
| 296 | |
| 297 | |
| 298 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 299 | 21 /**<N Number of RHS columns*/, |
| 300 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 301 | false /**< reinterpret the input as 3D */, |
| 302 | false /**< Flag used to broadcast the bias addition */, |
| 303 | true /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 304 | true /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 305 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 306 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 307 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 308 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 309 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 310 | 0 /**< Offset to be added to each element of the matrix A */, |
| 311 | 0 /**< Offset to be added to each element of the matrix B */), |
| 312 | |
| 313 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 314 | 21 /**<N Number of RHS columns*/, |
| 315 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 316 | false /**< reinterpret the input as 3D */, |
| 317 | false /**< Flag used to broadcast the bias addition */, |
| 318 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 319 | false /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 320 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 321 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 322 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 323 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 324 | GEMMRHSMatrixInfo(4,4,2,true,false,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 325 | 0 /**< Offset to be added to each element of the matrix A */, |
| 326 | 0 /**< Offset to be added to each element of the matrix B */), |
| 327 | })), |
| 328 | framework::dataset::make("Expected", { true, true, false, false, false, true, true,true})), |
| 329 | input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected) |
| 330 | { |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 331 | ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 332 | &input1_info.clone()->set_is_resizable(true), |
| 333 | &input2_info.clone()->set_is_resizable(true), |
| 334 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 335 | lhs_info, |
| 336 | rhs_info, |
| 337 | gemm_info)) == expected, framework::LogLevel::ERRORS); |
| 338 | } |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 339 | TEST_SUITE(Float) |
| 340 | TEST_SUITE(FP32) |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 341 | |
| 342 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 343 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 344 | m_values, |
| 345 | n_values), |
| 346 | k_values), |
| 347 | b_values), |
| 348 | m0_values_precommit), |
| 349 | n0_values_precommit), |
| 350 | k0_values_precommit), |
| 351 | v0_values_precommit), |
| 352 | h0_values_precommit), |
| 353 | i_values_lhs), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 354 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 355 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 356 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 357 | a_values_precommit), |
| 358 | beta_values_precommit), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 359 | broadcast_bias_values), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 360 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 361 | act_values)) |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 362 | { |
| 363 | // Validate output |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 364 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 367 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 368 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 369 | m_values, |
| 370 | n_values), |
| 371 | k_values), |
| 372 | b_values), |
| 373 | m0_values_nightly), |
| 374 | n0_values_nightly), |
| 375 | k0_values_nightly), |
| 376 | v0_values_nightly), |
| 377 | h0_values_nightly), |
| 378 | i_values_lhs), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 379 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 380 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 381 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 382 | a_values_nightly), |
| 383 | beta_values_nightly), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 384 | broadcast_bias_values), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 385 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 386 | act_values)) |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 387 | { |
| 388 | // Validate output |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 389 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 390 | } |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 391 | |
| 392 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 393 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 394 | m_w_values, |
| 395 | m_h_values), |
| 396 | n_values), |
| 397 | k_values), |
| 398 | b_values), |
| 399 | m0_values_precommit), |
| 400 | n0_values_precommit), |
| 401 | k0_values_precommit), |
| 402 | v0_values_precommit), |
| 403 | h0_values_precommit), |
| 404 | i_values_lhs), |
| 405 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 406 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 407 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 408 | a_values_precommit), |
| 409 | beta_values_precommit), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 410 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 411 | act_values)) |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 412 | { |
| 413 | // Validate output |
| 414 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 415 | } |
| 416 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 417 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 418 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 419 | m_w_values, |
| 420 | m_h_values), |
| 421 | n_values), |
| 422 | k_values), |
| 423 | b_values), |
| 424 | m0_values_nightly), |
| 425 | n0_values_nightly), |
| 426 | k0_values_nightly), |
| 427 | v0_values_nightly), |
| 428 | h0_values_nightly), |
| 429 | i_values_lhs), |
| 430 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 431 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 432 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 433 | a_values_nightly), |
| 434 | beta_values_nightly), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 435 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 436 | act_values)) |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 437 | { |
| 438 | // Validate output |
| 439 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 440 | } |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 441 | TEST_SUITE(ExportToCLImage) |
| 442 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( |
| 443 | framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 444 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 445 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 446 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect k0 |
| 447 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect n0 |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 448 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 449 | }), |
| 450 | framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), |
| 451 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), |
| 452 | TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F32), |
| 453 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), |
| 454 | TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F32), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 455 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 456 | })), |
| 457 | framework::dataset::make("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 458 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 459 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 460 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 461 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 462 | |
| 463 | })), |
| 464 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 465 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 466 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 467 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 468 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 469 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 470 | |
| 471 | })), |
| 472 | framework::dataset::make("LHSMInfo",{ |
| 473 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 474 | GEMMLHSMatrixInfo(4, 8, 1, false, true), |
| 475 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 476 | GEMMLHSMatrixInfo(4, 2, 1, false, false), |
| 477 | GEMMLHSMatrixInfo(4, 4, 1, false, false), |
| 478 | |
| 479 | })), |
| 480 | framework::dataset::make("RHSMInfo",{ |
| 481 | GEMMRHSMatrixInfo(4, 4, 1, true, true, true), |
| 482 | GEMMRHSMatrixInfo(4, 8, 1, true, true, true), |
| 483 | GEMMRHSMatrixInfo(8, 4, 1, true, true, true), |
| 484 | GEMMRHSMatrixInfo(4, 2, 1, true, false, true), |
| 485 | GEMMRHSMatrixInfo(2, 4, 1, true, false, true), |
| 486 | })), |
| 487 | framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 488 | 64 /**<N Number of RHS columns*/, |
| 489 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 490 | false /**< reinterpret the input as 3D */, |
| 491 | true /**< Flag used to broadcast the bias addition */, |
| 492 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 493 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 494 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 495 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 496 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 497 | GEMMLHSMatrixInfo(), |
| 498 | GEMMRHSMatrixInfo(), |
| 499 | 0 /**< Offset to be added to each element of the matrix A */, |
| 500 | 0 /**< Offset to be added to each element of the matrix B */), |
| 501 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 502 | 64 /**<N Number of RHS columns*/, |
| 503 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 504 | false /**< reinterpret the input as 3D */, |
| 505 | true /**< Flag used to broadcast the bias addition */, |
| 506 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 507 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 508 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 509 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 510 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 511 | GEMMLHSMatrixInfo(), |
| 512 | GEMMRHSMatrixInfo(), |
| 513 | 0 /**< Offset to be added to each element of the matrix A */, |
| 514 | 0 /**< Offset to be added to each element of the matrix B */), |
| 515 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 516 | 64 /**<N Number of RHS columns*/, |
| 517 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 518 | false /**< reinterpret the input as 3D */, |
| 519 | true /**< Flag used to broadcast the bias addition */, |
| 520 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 521 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 522 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 523 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 524 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 525 | GEMMLHSMatrixInfo(), |
| 526 | GEMMRHSMatrixInfo(), |
| 527 | 0 /**< Offset to be added to each element of the matrix A */, |
| 528 | 0 /**< Offset to be added to each element of the matrix B */), |
| 529 | |
| 530 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 531 | 64 /**<N Number of RHS columns*/, |
| 532 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 533 | false /**< reinterpret the input as 3D */, |
| 534 | true /**< Flag used to broadcast the bias addition */, |
| 535 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 536 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 537 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 538 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 539 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 540 | GEMMLHSMatrixInfo(), |
| 541 | GEMMRHSMatrixInfo(), |
| 542 | 0 /**< Offset to be added to each element of the matrix A */, |
| 543 | 0 /**< Offset to be added to each element of the matrix B */), |
| 544 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 545 | 64 /**<N Number of RHS columns*/, |
| 546 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 547 | false /**< reinterpret the input as 3D */, |
| 548 | true /**< Flag used to broadcast the bias addition */, |
| 549 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 550 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 551 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 552 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 553 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 554 | GEMMLHSMatrixInfo(), |
| 555 | GEMMRHSMatrixInfo(), |
| 556 | 0 /**< Offset to be added to each element of the matrix A */, |
| 557 | 0 /**< Offset to be added to each element of the matrix B */) |
| 558 | })), |
| 559 | framework::dataset::make("Expected", { true, |
| 560 | true, |
| 561 | true, |
| 562 | false, |
| 563 | false})), |
| 564 | input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected) |
| 565 | { |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 566 | ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 567 | &input1_info.clone()->set_is_resizable(true), |
| 568 | &input2_info.clone()->set_is_resizable(true), |
| 569 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 570 | lhs_info, |
| 571 | rhs_info, |
| 572 | gemm_info)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS); |
| 573 | } |
| 574 | |
| 575 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL, |
| 576 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 577 | m_values, |
| 578 | n_values), |
| 579 | k_values), |
| 580 | b_values), |
| 581 | m0_values_precommit), |
| 582 | n0_values_precommit), |
| 583 | k0_values_precommit), |
| 584 | v0_values_precommit), |
| 585 | h0_values_precommit), |
| 586 | i_values_lhs), |
| 587 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 588 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 589 | framework::dataset::make("DataType", DataType::F32)), |
| 590 | a_values_precommit), |
| 591 | beta_values_precommit), |
| 592 | broadcast_bias_values), |
| 593 | lhs_transpose_values), |
| 594 | act_values)) |
| 595 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 596 | // Validate output only if validate() is successful |
| 597 | if(validate_result) |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 598 | { |
| 599 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 600 | } |
| 601 | else |
| 602 | { |
| 603 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 604 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 605 | } |
| 606 | |
| 607 | } |
| 608 | |
| 609 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::NIGHTLY, |
| 610 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 611 | m_values, |
| 612 | n_values), |
| 613 | k_values), |
| 614 | b_values), |
| 615 | m0_values_nightly), |
| 616 | n0_export_to_cl_image_values_nightly), |
| 617 | k0_export_to_cl_image_values_nightly), |
| 618 | v0_values_nightly), |
| 619 | h0_values_nightly), |
| 620 | i_values_lhs), |
| 621 | i_values_rhs), |
| 622 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 623 | framework::dataset::make("DataType", DataType::F32)), |
| 624 | a_values_nightly), |
| 625 | beta_values_nightly), |
| 626 | broadcast_bias_values), |
| 627 | lhs_transpose_values), |
| 628 | act_values)) |
| 629 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 630 | // Validate output only if validate() is successful |
| 631 | if(validate_result) |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 632 | { |
| 633 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 634 | } |
| 635 | else |
| 636 | { |
| 637 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 638 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL, |
| 643 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 644 | m_w_values, |
| 645 | m_h_values), |
| 646 | n_values), |
| 647 | k_values), |
| 648 | b_values), |
| 649 | m0_values_precommit), |
| 650 | n0_values_precommit), |
| 651 | k0_values_precommit), |
| 652 | v0_values_precommit), |
| 653 | h0_values_precommit), |
| 654 | i_values_lhs), |
| 655 | i_values_rhs), |
| 656 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 657 | framework::dataset::make("DataType", DataType::F32)), |
| 658 | a_values_precommit), |
| 659 | beta_values_precommit), |
| 660 | lhs_transpose_values), |
| 661 | act_values)) |
| 662 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 663 | // Validate output only if validate() is successful |
| 664 | if(validate_result) |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 665 | { |
| 666 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 667 | } |
| 668 | else |
| 669 | { |
| 670 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 671 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::NIGHTLY, |
| 676 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 677 | m_w_values, |
| 678 | m_h_values), |
| 679 | n_values), |
| 680 | k_values), |
| 681 | b_values), |
| 682 | m0_values_nightly), |
| 683 | n0_export_to_cl_image_values_nightly), |
| 684 | k0_export_to_cl_image_values_nightly), |
| 685 | v0_values_nightly), |
| 686 | h0_values_nightly), |
| 687 | i_values_lhs), |
| 688 | i_values_rhs), |
| 689 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 690 | framework::dataset::make("DataType", DataType::F32)), |
| 691 | a_values_nightly), |
| 692 | beta_values_nightly), |
| 693 | lhs_transpose_values), |
| 694 | act_values)) |
| 695 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 696 | // Validate output only if validate() is successful |
| 697 | if(validate_result) |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 698 | { |
| 699 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 700 | } |
| 701 | else |
| 702 | { |
| 703 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 704 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 705 | } |
| 706 | } |
| 707 | TEST_SUITE_END() // ExportToCLImage |
| 708 | TEST_SUITE_END() // FP32 |
| 709 | |
| 710 | TEST_SUITE(FP16) |
| 711 | |
| 712 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::ALL, |
| 713 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 714 | m_values, |
| 715 | n_values), |
| 716 | k_values), |
| 717 | b_values), |
| 718 | m0_values_precommit), |
| 719 | n0_values_precommit), |
| 720 | k0_values_precommit), |
| 721 | v0_values_precommit), |
| 722 | h0_values_precommit), |
| 723 | i_values_lhs), |
| 724 | i_values_rhs), |
| 725 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 726 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 727 | a_values_precommit), |
| 728 | beta_values_precommit), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 729 | broadcast_bias_values), |
| 730 | lhs_transpose_values), |
| 731 | act_values)) |
| 732 | { |
| 733 | // Validate output |
| 734 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 735 | } |
| 736 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 737 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 738 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 739 | m_values, |
| 740 | n_values), |
| 741 | k_values), |
| 742 | b_values), |
| 743 | m0_values_nightly), |
| 744 | n0_values_nightly), |
| 745 | k0_values_nightly), |
| 746 | v0_values_nightly), |
| 747 | h0_values_nightly), |
| 748 | i_values_lhs), |
| 749 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 750 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 751 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 752 | a_values_nightly), |
| 753 | beta_values_nightly), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 754 | broadcast_bias_values), |
| 755 | lhs_transpose_values), |
| 756 | act_values)) |
| 757 | { |
| 758 | // Validate output |
| 759 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 760 | } |
| 761 | |
| 762 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 763 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 764 | m_w_values, |
| 765 | m_h_values), |
| 766 | n_values), |
| 767 | k_values), |
| 768 | b_values), |
| 769 | m0_values_precommit), |
| 770 | n0_values_precommit), |
| 771 | k0_values_precommit), |
| 772 | v0_values_precommit), |
| 773 | h0_values_precommit), |
| 774 | i_values_lhs), |
| 775 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 776 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 777 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 778 | a_values_precommit), |
| 779 | beta_values_precommit), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 780 | lhs_transpose_values), |
| 781 | act_values)) |
| 782 | { |
| 783 | // Validate output |
| 784 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 785 | } |
| 786 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 787 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 788 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 789 | m_w_values, |
| 790 | m_h_values), |
| 791 | n_values), |
| 792 | k_values), |
| 793 | b_values), |
| 794 | m0_values_nightly), |
| 795 | n0_values_nightly), |
| 796 | k0_values_nightly), |
| 797 | v0_values_nightly), |
| 798 | h0_values_nightly), |
| 799 | i_values_lhs), |
| 800 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 801 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 802 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 803 | a_values_nightly), |
| 804 | beta_values_nightly), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 805 | lhs_transpose_values), |
| 806 | act_values)) |
| 807 | { |
| 808 | // Validate output |
| 809 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 810 | } |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 811 | |
| 812 | TEST_SUITE(ExportToCLImage) |
| 813 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( |
| 814 | framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 815 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 816 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 817 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect k0 |
| 818 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect n0 |
| 819 | |
| 820 | }), |
| 821 | framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), |
| 822 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), |
| 823 | TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F16), |
| 824 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), |
| 825 | TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F16), |
| 826 | |
| 827 | })), |
| 828 | framework::dataset::make("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 829 | TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 830 | TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 831 | TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 832 | TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 833 | |
| 834 | })), |
| 835 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 836 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 837 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 838 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 839 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 840 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 841 | |
| 842 | })), |
| 843 | framework::dataset::make("LHSMInfo",{ |
| 844 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 845 | GEMMLHSMatrixInfo(4, 8, 1, false, true), |
| 846 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 847 | GEMMLHSMatrixInfo(4, 2, 1, false, false), |
| 848 | GEMMLHSMatrixInfo(4, 4, 1, false, false), |
| 849 | |
| 850 | })), |
| 851 | framework::dataset::make("RHSMInfo",{ |
| 852 | GEMMRHSMatrixInfo(4, 4, 1, true, true, true), |
| 853 | GEMMRHSMatrixInfo(4, 8, 1, true, true, true), |
| 854 | GEMMRHSMatrixInfo(8, 4, 1, true, true, true), |
| 855 | GEMMRHSMatrixInfo(4, 2, 1, true, false, true), |
| 856 | GEMMRHSMatrixInfo(2, 4, 1, true, false, true), |
| 857 | })), |
| 858 | framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 859 | 64 /**<N Number of RHS columns*/, |
| 860 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 861 | false /**< reinterpret the input as 3D */, |
| 862 | true /**< Flag used to broadcast the bias addition */, |
| 863 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 864 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 865 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 866 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 867 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 868 | GEMMLHSMatrixInfo(), |
| 869 | GEMMRHSMatrixInfo(), |
| 870 | 0 /**< Offset to be added to each element of the matrix A */, |
| 871 | 0 /**< Offset to be added to each element of the matrix B */), |
| 872 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 873 | 64 /**<N Number of RHS columns*/, |
| 874 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 875 | false /**< reinterpret the input as 3D */, |
| 876 | true /**< Flag used to broadcast the bias addition */, |
| 877 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 878 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 879 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 880 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 881 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 882 | GEMMLHSMatrixInfo(), |
| 883 | GEMMRHSMatrixInfo(), |
| 884 | 0 /**< Offset to be added to each element of the matrix A */, |
| 885 | 0 /**< Offset to be added to each element of the matrix B */), |
| 886 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 887 | 64 /**<N Number of RHS columns*/, |
| 888 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 889 | false /**< reinterpret the input as 3D */, |
| 890 | true /**< Flag used to broadcast the bias addition */, |
| 891 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 892 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 893 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 894 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 895 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 896 | GEMMLHSMatrixInfo(), |
| 897 | GEMMRHSMatrixInfo(), |
| 898 | 0 /**< Offset to be added to each element of the matrix A */, |
| 899 | 0 /**< Offset to be added to each element of the matrix B */), |
| 900 | |
| 901 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 902 | 64 /**<N Number of RHS columns*/, |
| 903 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 904 | false /**< reinterpret the input as 3D */, |
| 905 | true /**< Flag used to broadcast the bias addition */, |
| 906 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 907 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 908 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 909 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 910 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 911 | GEMMLHSMatrixInfo(), |
| 912 | GEMMRHSMatrixInfo(), |
| 913 | 0 /**< Offset to be added to each element of the matrix A */, |
| 914 | 0 /**< Offset to be added to each element of the matrix B */), |
| 915 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 916 | 64 /**<N Number of RHS columns*/, |
| 917 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 918 | false /**< reinterpret the input as 3D */, |
| 919 | true /**< Flag used to broadcast the bias addition */, |
| 920 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 921 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 922 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 923 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 924 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 925 | GEMMLHSMatrixInfo(), |
| 926 | GEMMRHSMatrixInfo(), |
| 927 | 0 /**< Offset to be added to each element of the matrix A */, |
| 928 | 0 /**< Offset to be added to each element of the matrix B */) |
| 929 | })), |
| 930 | framework::dataset::make("Expected", { true, |
| 931 | true, |
| 932 | true, |
| 933 | false, |
| 934 | false})), |
| 935 | input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected) |
| 936 | { |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 937 | ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true), |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 938 | &input1_info.clone()->set_is_resizable(true), |
| 939 | &input2_info.clone()->set_is_resizable(true), |
| 940 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 941 | lhs_info, |
| 942 | rhs_info, |
| 943 | gemm_info)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS); |
| 944 | } |
| 945 | |
| 946 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::ALL, |
| 947 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 948 | m_values, |
| 949 | n_values), |
| 950 | k_values), |
| 951 | b_values), |
| 952 | m0_values_precommit), |
| 953 | n0_values_precommit), |
| 954 | k0_values_precommit), |
| 955 | v0_values_precommit), |
| 956 | h0_values_precommit), |
| 957 | i_values_lhs), |
| 958 | i_values_rhs), |
| 959 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 960 | framework::dataset::make("DataType", DataType::F16)), |
| 961 | a_values_precommit), |
| 962 | beta_values_precommit), |
| 963 | broadcast_bias_values), |
| 964 | lhs_transpose_values), |
| 965 | act_values)) |
| 966 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 967 | // Validate output only if validate() is successful |
| 968 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 969 | { |
| 970 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 971 | } |
| 972 | else |
| 973 | { |
| 974 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 975 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 976 | } |
| 977 | |
| 978 | } |
| 979 | |
| 980 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::NIGHTLY, |
| 981 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 982 | m_values, |
| 983 | n_values), |
| 984 | k_values), |
| 985 | b_values), |
| 986 | m0_values_nightly), |
| 987 | n0_export_to_cl_image_values_nightly), |
| 988 | k0_export_to_cl_image_values_nightly), |
| 989 | v0_values_nightly), |
| 990 | h0_values_nightly), |
| 991 | i_values_lhs), |
| 992 | i_values_rhs), |
| 993 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 994 | framework::dataset::make("DataType", DataType::F16)), |
| 995 | a_values_nightly), |
| 996 | beta_values_nightly), |
| 997 | broadcast_bias_values), |
| 998 | lhs_transpose_values), |
| 999 | act_values)) |
| 1000 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 1001 | // Validate output only if validate() is successful |
| 1002 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1003 | { |
| 1004 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1005 | } |
| 1006 | else |
| 1007 | { |
| 1008 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 1009 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::ALL, |
| 1014 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1015 | m_w_values, |
| 1016 | m_h_values), |
| 1017 | n_values), |
| 1018 | k_values), |
| 1019 | b_values), |
| 1020 | m0_values_precommit), |
| 1021 | n0_values_precommit), |
| 1022 | k0_values_precommit), |
| 1023 | v0_values_precommit), |
| 1024 | h0_values_precommit), |
| 1025 | i_values_lhs), |
| 1026 | i_values_rhs), |
| 1027 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 1028 | framework::dataset::make("DataType", DataType::F16)), |
| 1029 | a_values_precommit), |
| 1030 | beta_values_precommit), |
| 1031 | lhs_transpose_values), |
| 1032 | act_values)) |
| 1033 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 1034 | // Validate output only if validate() is successful |
| 1035 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1036 | { |
| 1037 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1038 | } |
| 1039 | else |
| 1040 | { |
| 1041 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 1042 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::NIGHTLY, |
| 1047 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1048 | m_w_values, |
| 1049 | m_h_values), |
| 1050 | n_values), |
| 1051 | k_values), |
| 1052 | b_values), |
| 1053 | m0_values_nightly), |
| 1054 | n0_export_to_cl_image_values_nightly), |
| 1055 | k0_export_to_cl_image_values_nightly), |
| 1056 | v0_values_nightly), |
| 1057 | h0_values_nightly), |
| 1058 | i_values_lhs), |
| 1059 | i_values_rhs), |
| 1060 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 1061 | framework::dataset::make("DataType", DataType::F16)), |
| 1062 | a_values_nightly), |
| 1063 | beta_values_nightly), |
| 1064 | lhs_transpose_values), |
| 1065 | act_values)) |
| 1066 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 1067 | // Validate output only if validate() is successful |
| 1068 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1069 | { |
| 1070 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1071 | } |
| 1072 | else |
| 1073 | { |
| 1074 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 1075 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 1076 | } |
| 1077 | } |
| 1078 | TEST_SUITE_END() // ExportToCLImage |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 1079 | TEST_SUITE_END() // FP16 |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1080 | |
| 1081 | TEST_SUITE(MixedPrecision) |
| 1082 | |
| 1083 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1084 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1085 | m_values, |
| 1086 | n_values), |
| 1087 | k_values), |
| 1088 | b_values), |
| 1089 | m0_values_precommit), |
| 1090 | n0_values_precommit), |
| 1091 | k0_values_precommit), |
| 1092 | v0_values_precommit), |
| 1093 | h0_values_precommit), |
| 1094 | i_values_lhs), |
| 1095 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1096 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1097 | framework::dataset::make("DataType", DataType::F16)), |
| 1098 | a_values_precommit), |
| 1099 | beta_values_precommit), |
| 1100 | broadcast_bias_values), |
| 1101 | lhs_transpose_values), |
| 1102 | act_values)) |
| 1103 | { |
| 1104 | // Validate output |
| 1105 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 1106 | } |
| 1107 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 1108 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1109 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1110 | m_values, |
| 1111 | n_values), |
| 1112 | k_values), |
| 1113 | b_values), |
| 1114 | m0_values_nightly), |
| 1115 | n0_values_nightly), |
| 1116 | k0_values_nightly), |
| 1117 | v0_values_nightly), |
| 1118 | h0_values_nightly), |
| 1119 | i_values_lhs), |
| 1120 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1121 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1122 | framework::dataset::make("DataType", DataType::F16)), |
| 1123 | a_values_nightly), |
| 1124 | beta_values_nightly), |
| 1125 | broadcast_bias_values), |
| 1126 | lhs_transpose_values), |
| 1127 | act_values)) |
| 1128 | { |
| 1129 | // Validate output |
| 1130 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 1131 | } |
| 1132 | |
| 1133 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1134 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1135 | m_w_values, |
| 1136 | m_h_values), |
| 1137 | n_values), |
| 1138 | k_values), |
| 1139 | b_values), |
| 1140 | m0_values_precommit), |
| 1141 | n0_values_precommit), |
| 1142 | k0_values_precommit), |
| 1143 | v0_values_precommit), |
| 1144 | h0_values_precommit), |
| 1145 | i_values_lhs), |
| 1146 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1147 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1148 | framework::dataset::make("DataType", DataType::F16)), |
| 1149 | a_values_precommit), |
| 1150 | beta_values_precommit), |
| 1151 | lhs_transpose_values), |
| 1152 | act_values)) |
| 1153 | { |
| 1154 | // Validate output |
| 1155 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 1156 | } |
| 1157 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 1158 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1159 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1160 | m_w_values, |
| 1161 | m_h_values), |
| 1162 | n_values), |
| 1163 | k_values), |
| 1164 | b_values), |
| 1165 | m0_values_nightly), |
| 1166 | n0_values_nightly), |
| 1167 | k0_values_nightly), |
| 1168 | v0_values_nightly), |
| 1169 | h0_values_nightly), |
| 1170 | i_values_lhs), |
| 1171 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1172 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1173 | framework::dataset::make("DataType", DataType::F16)), |
| 1174 | a_values_nightly), |
| 1175 | beta_values_nightly), |
| 1176 | lhs_transpose_values), |
| 1177 | act_values)) |
| 1178 | { |
| 1179 | // Validate output |
| 1180 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 1181 | } |
| 1182 | TEST_SUITE_END() // MixedPrecision |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 1183 | TEST_SUITE_END() // Float |
Gian Marco Iodice | d1f5476 | 2019-07-19 09:54:47 +0100 | [diff] [blame] | 1184 | TEST_SUITE_END() // GEMMMatrixMultiplyReshaped |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 1185 | TEST_SUITE_END() // CL |
| 1186 | } // namespace validation |
| 1187 | } // namespace test |
Michele Di Giorgio | 2568c6b | 2019-09-17 12:08:46 +0100 | [diff] [blame] | 1188 | } // namespace arm_compute |