Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 1 | /* |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2020 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 | */ |
| 24 | #include "arm_compute/core/CL/kernels/CLGEMMMatrixMultiplyReshapedKernel.h" |
| 25 | #include "arm_compute/core/CL/kernels/CLGEMMReshapeLHSMatrixKernel.h" |
| 26 | #include "arm_compute/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h" |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/KernelDescriptors.h" |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 28 | #include "arm_compute/core/Types.h" |
| 29 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
| 30 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 31 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
| 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; |
| 49 | |
| 50 | // Create function for CLGEMMReshapeLHSMatrixKernel |
Gian Marco Iodice | bacfec5 | 2019-01-11 11:30:55 +0000 | [diff] [blame] | 51 | using CLGEMMReshapeLHSMatrix = CLSynthetizeFunction<CLGEMMReshapeLHSMatrixKernel>; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 52 | |
| 53 | // Create function for CLGEMMReshapeRHSMatrixKernel |
Gian Marco Iodice | bacfec5 | 2019-01-11 11:30:55 +0000 | [diff] [blame] | 54 | using CLGEMMReshapeRHSMatrix = CLSynthetizeFunction<CLGEMMReshapeRHSMatrixKernel>; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 55 | |
| 56 | // Create function for CLGEMMMatrixMultiplyReshapedKernel |
| 57 | using CLGEMMMatrixMultiplyReshaped = CLSynthetizeFunction<CLGEMMMatrixMultiplyReshapedKernel>; |
| 58 | |
| 59 | // Fixture for CLGEMMMatrixMultiplyReshaped |
| 60 | template <typename T> |
| 61 | using CLGEMMMatrixMultiplyReshapedFixture = GEMMMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>; |
| 62 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 63 | // Fixture for CLGEMMMatrixMultiplyReshaped mixed precision |
| 64 | template <typename T> |
| 65 | using CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture = |
| 66 | GEMMMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>; |
| 67 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 68 | // Fixture for CLGEMMMatrixMultiplyReshaped3D |
| 69 | template <typename T> |
| 70 | using CLGEMMMatrixMultiplyReshaped3DFixture = GEMMMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>; |
| 71 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 72 | // Fixture for CLGEMMMatrixMultiplyReshaped3D mixed precision |
| 73 | template <typename T> |
| 74 | using CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture = |
| 75 | GEMMMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>; |
| 76 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 77 | namespace |
| 78 | { |
| 79 | // *INDENT-OFF* |
| 80 | // clang-format off |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 81 | RelativeTolerance<float> rel_tolerance_f32(0.001f); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 82 | constexpr float abs_tolerance_f32(0.0001f); |
| 83 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 84 | RelativeTolerance<float> rel_tolerance_f16_mixed_precision(0.001f); |
| 85 | constexpr float abs_tolerance_f16_mixed_precision(0.01f); |
| 86 | |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 87 | RelativeTolerance<float> rel_tolerance_f16(0.001f); |
| 88 | constexpr float abs_tolerance_f16(0.01f); |
| 89 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 90 | /** M values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 91 | const auto m_values = framework::dataset::make("M", 17); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 92 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 93 | /** M_W values to test */ |
| 94 | const auto m_w_values = framework::dataset::make("M_W", 5); |
| 95 | |
| 96 | /** M_H values to test */ |
| 97 | const auto m_h_values = framework::dataset::make("M_H", 7); |
| 98 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 99 | /** N values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 100 | const auto n_values = framework::dataset::make("N", 21); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 101 | |
| 102 | /** K values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 103 | const auto k_values = framework::dataset::make("K", 13); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 104 | |
| 105 | /** Batch size values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 106 | const auto b_values = framework::dataset::make("batch_size", 2, 3); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 107 | |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 108 | /** Activation values to test */ |
| 109 | const auto act_values = framework::dataset::make("Activation", |
| 110 | { |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 111 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 8.f, 2.f), |
| 112 | }); |
| 113 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 114 | /** Alpha values to test - Precommit */ |
| 115 | const auto a_values_precommit = framework::dataset::make("alpha", {-0.75f} ); |
| 116 | |
| 117 | /** Beta values to test - Precommit */ |
| 118 | const auto beta_values_precommit = framework::dataset::make("beta", {-0.35f} ); |
| 119 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 120 | /** M0 values to test - Precommit */ |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 121 | const auto m0_values_precommit = framework::dataset::make("M0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 122 | |
| 123 | /** N0 values to test - Precommit */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 124 | const auto n0_values_precommit = framework::dataset::make("N0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 125 | |
| 126 | /** K0 values to test - Precommit */ |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 127 | const auto k0_values_precommit = framework::dataset::make("K0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 128 | |
| 129 | /** V0 values to test - Precommit */ |
| 130 | const auto v0_values_precommit = framework::dataset::make("V0", 1, 3); |
| 131 | |
| 132 | /** H0 values to test - Precommit */ |
| 133 | const auto h0_values_precommit = framework::dataset::make("H0", 1, 3); |
| 134 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 135 | /** Alpha values to test - Nightly */ |
| 136 | const auto a_values_nightly = framework::dataset::make("alpha", {1.0f} ); |
| 137 | |
| 138 | /** Beta values to test - Nightly */ |
| 139 | const auto beta_values_nightly = framework::dataset::make("beta", {1.0f} ); |
| 140 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 141 | /** M0 values to test - Nightly */ |
Michele Di Giorgio | 2568c6b | 2019-09-17 12:08:46 +0100 | [diff] [blame] | 142 | const auto m0_values_nightly = framework::dataset::make("M0", { 2, 3, 4, 8 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 143 | |
| 144 | /** N0 values to test - Nightly */ |
Gian Marco Iodice | bacfec5 | 2019-01-11 11:30:55 +0000 | [diff] [blame] | 145 | const auto n0_values_nightly = framework::dataset::make("N0", { 2, 3, 4, 8 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 146 | |
| 147 | /** K0 values to test - Nightly */ |
Gian Marco Iodice | bacfec5 | 2019-01-11 11:30:55 +0000 | [diff] [blame] | 148 | const auto k0_values_nightly = framework::dataset::make("K0", { 2, 3, 4, 8 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 149 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 150 | /** N0 values to test with export to OpenCL image object - Nightly */ |
| 151 | const auto n0_export_to_cl_image_values_nightly = framework::dataset::make("N0", { 4, 8, 16 }); |
| 152 | |
| 153 | /** K0 values to test with export to OpenCL image object - Nightly */ |
| 154 | const auto k0_export_to_cl_image_values_nightly = framework::dataset::make("K0", { 4, 8, 16 }); |
| 155 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 156 | /** V0 values to test - Nightly */ |
| 157 | const auto v0_values_nightly = framework::dataset::make("V0", 1, 4); |
| 158 | |
| 159 | /** H0 values to test - Nightly */ |
| 160 | const auto h0_values_nightly = framework::dataset::make("H0", 1, 4); |
| 161 | |
| 162 | /** Interleave values to test with LHS matrix */ |
| 163 | const auto i_values_lhs = framework::dataset::make("interleave_lhs", { true, false }); |
| 164 | |
| 165 | /** Interleave values to test with RHS matrix */ |
| 166 | const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false }); |
| 167 | |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 168 | /** Broadcast bias from vector to matrix */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 169 | 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] | 170 | |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 171 | /** LHS transposed values */ |
| 172 | const auto lhs_transpose_values = framework::dataset::make("lhs_transpose", { false, true } ); |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 173 | } // namespace |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 174 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 175 | TEST_SUITE(CL) |
| 176 | TEST_SUITE(GEMMMatrixMultiplyReshaped) |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 177 | |
| 178 | // *INDENT-OFF* |
| 179 | // clang-format off |
| 180 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( |
| 181 | framework::dataset::make("Input0Info", { TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // OK |
| 182 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK |
| 183 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8), // Data type not supported |
| 184 | TensorInfo(TensorShape(10U, 5U, 2U), 1, DataType::F32), // Incorrect dimension bias |
| 185 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // Mismatching shapes |
| 186 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, do not broadcast bias |
| 187 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, wider accummulation |
| 188 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, RHS 4,4,2 |
| 189 | |
| 190 | }), |
| 191 | framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32), |
| 192 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16), |
| 193 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8), |
| 194 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32), |
| 195 | TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), |
| 196 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16), |
| 197 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16), |
| 198 | TensorInfo(TensorShape(128U, 3U, 2U), 1, DataType::F16), |
| 199 | |
| 200 | })), |
| 201 | framework::dataset::make("Input2Info", { TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 202 | TensorInfo(TensorShape(21U), 1, DataType::F16), |
| 203 | TensorInfo(TensorShape(21U), 1, DataType::QASYMM8), |
| 204 | TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 205 | TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 206 | TensorInfo(TensorShape(21U,17U), 1, DataType::F16), |
| 207 | TensorInfo(TensorShape(21U,17U), 1, DataType::F16), |
| 208 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 209 | |
| 210 | })), |
| 211 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32), |
| 212 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 213 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::QASYMM8), |
| 214 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32), |
| 215 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32), |
| 216 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 217 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 218 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 219 | |
| 220 | })), |
| 221 | framework::dataset::make("LHSMInfo",{ |
| 222 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 223 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 224 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 225 | GEMMLHSMatrixInfo(4,2,4,false,false), |
| 226 | GEMMLHSMatrixInfo(4,2,4,false,false), |
| 227 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 228 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 229 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 230 | |
| 231 | })), |
| 232 | framework::dataset::make("RHSMInfo",{ |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 233 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 234 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 235 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 236 | GEMMRHSMatrixInfo(2,2,1,true,false,false), |
| 237 | GEMMRHSMatrixInfo(2,2,1,true,false,false), |
| 238 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 239 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 240 | GEMMRHSMatrixInfo(4,4,2,true,false,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 241 | |
| 242 | |
| 243 | })), |
| 244 | |
| 245 | |
| 246 | framework::dataset::make("GEMMInfo",{ |
| 247 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 248 | 21 /**<N Number of RHS columns*/, |
| 249 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 250 | false /**< reinterpret the input as 3D */, |
| 251 | true /**< Flag used to broadcast the bias addition */, |
| 252 | false /**< wider accumm */, |
| 253 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 254 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 255 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 256 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 257 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 258 | 0 /**< Offset to be added to each element of the matrix A */, |
| 259 | 0 /**< Offset to be added to each element of the matrix B */), |
| 260 | |
| 261 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 262 | 21 /**<N Number of RHS columns*/, |
| 263 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 264 | false /**< reinterpret the input as 3D */, |
| 265 | true /**< Flag used to broadcast the bias addition */, |
| 266 | false /**< wider accumm */, |
| 267 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 268 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 269 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 270 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 271 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 272 | 0 /**< Offset to be added to each element of the matrix A */, |
| 273 | 0 /**< Offset to be added to each element of the matrix B */), |
| 274 | GEMMKernelInfo(), |
| 275 | GEMMKernelInfo(), |
| 276 | GEMMKernelInfo(), |
| 277 | |
| 278 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 279 | 21 /**<N Number of RHS columns*/, |
| 280 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 281 | false /**< reinterpret the input as 3D */, |
| 282 | false /**< Flag used to broadcast the bias addition */, |
| 283 | false /**< wider accumm */, |
| 284 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 285 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 286 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 287 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 288 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 289 | 0 /**< Offset to be added to each element of the matrix A */, |
| 290 | 0 /**< Offset to be added to each element of the matrix B */), |
| 291 | |
| 292 | |
| 293 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 294 | 21 /**<N Number of RHS columns*/, |
| 295 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 296 | false /**< reinterpret the input as 3D */, |
| 297 | false /**< Flag used to broadcast the bias addition */, |
| 298 | true /**< wider accumm */, |
| 299 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 300 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 301 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 302 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 303 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 304 | 0 /**< Offset to be added to each element of the matrix A */, |
| 305 | 0 /**< Offset to be added to each element of the matrix B */), |
| 306 | |
| 307 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 308 | 21 /**<N Number of RHS columns*/, |
| 309 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 310 | false /**< reinterpret the input as 3D */, |
| 311 | false /**< Flag used to broadcast the bias addition */, |
| 312 | false /**< wider accumm */, |
| 313 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 314 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 315 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 316 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 317 | GEMMRHSMatrixInfo(4,4,2,true,false,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 318 | 0 /**< Offset to be added to each element of the matrix A */, |
| 319 | 0 /**< Offset to be added to each element of the matrix B */), |
| 320 | })), |
| 321 | framework::dataset::make("Expected", { true, true, false, false, false, true, true,true})), |
| 322 | input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected) |
| 323 | { |
| 324 | ARM_COMPUTE_EXPECT(bool(CLGEMMMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true), |
| 325 | &input1_info.clone()->set_is_resizable(true), |
| 326 | &input2_info.clone()->set_is_resizable(true), |
| 327 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 328 | lhs_info, |
| 329 | rhs_info, |
| 330 | gemm_info)) == expected, framework::LogLevel::ERRORS); |
| 331 | } |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 332 | TEST_SUITE(Float) |
| 333 | TEST_SUITE(FP32) |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 334 | |
| 335 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 336 | 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] | 337 | m_values, |
| 338 | n_values), |
| 339 | k_values), |
| 340 | b_values), |
| 341 | m0_values_precommit), |
| 342 | n0_values_precommit), |
| 343 | k0_values_precommit), |
| 344 | v0_values_precommit), |
| 345 | h0_values_precommit), |
| 346 | i_values_lhs), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 347 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 348 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 349 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 350 | a_values_precommit), |
| 351 | beta_values_precommit), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 352 | broadcast_bias_values), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 353 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 354 | act_values)) |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 355 | { |
| 356 | // Validate output |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 357 | 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] | 358 | } |
| 359 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 360 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 361 | 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] | 362 | m_values, |
| 363 | n_values), |
| 364 | k_values), |
| 365 | b_values), |
| 366 | m0_values_nightly), |
| 367 | n0_values_nightly), |
| 368 | k0_values_nightly), |
| 369 | v0_values_nightly), |
| 370 | h0_values_nightly), |
| 371 | i_values_lhs), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 372 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 373 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 374 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 375 | a_values_nightly), |
| 376 | beta_values_nightly), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 377 | broadcast_bias_values), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 378 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 379 | act_values)) |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 380 | { |
| 381 | // Validate output |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 382 | 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] | 383 | } |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 384 | |
| 385 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 386 | 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] | 387 | m_w_values, |
| 388 | m_h_values), |
| 389 | n_values), |
| 390 | k_values), |
| 391 | b_values), |
| 392 | m0_values_precommit), |
| 393 | n0_values_precommit), |
| 394 | k0_values_precommit), |
| 395 | v0_values_precommit), |
| 396 | h0_values_precommit), |
| 397 | i_values_lhs), |
| 398 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 399 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 400 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 401 | a_values_precommit), |
| 402 | beta_values_precommit), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 403 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 404 | act_values)) |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 405 | { |
| 406 | // Validate output |
| 407 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 408 | } |
| 409 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 410 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 411 | 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] | 412 | m_w_values, |
| 413 | m_h_values), |
| 414 | n_values), |
| 415 | k_values), |
| 416 | b_values), |
| 417 | m0_values_nightly), |
| 418 | n0_values_nightly), |
| 419 | k0_values_nightly), |
| 420 | v0_values_nightly), |
| 421 | h0_values_nightly), |
| 422 | i_values_lhs), |
| 423 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 424 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 425 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 426 | a_values_nightly), |
| 427 | beta_values_nightly), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 428 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 429 | act_values)) |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 430 | { |
| 431 | // Validate output |
| 432 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 433 | } |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 434 | TEST_SUITE(ExportToCLImage) |
| 435 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( |
| 436 | framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 437 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 438 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 439 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect k0 |
| 440 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect n0 |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 441 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 442 | }), |
| 443 | framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), |
| 444 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), |
| 445 | TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F32), |
| 446 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), |
| 447 | TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F32), |
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("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 451 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 452 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 453 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 454 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 455 | |
| 456 | })), |
| 457 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 458 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 459 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 460 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 461 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 462 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 463 | |
| 464 | })), |
| 465 | framework::dataset::make("LHSMInfo",{ |
| 466 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 467 | GEMMLHSMatrixInfo(4, 8, 1, false, true), |
| 468 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 469 | GEMMLHSMatrixInfo(4, 2, 1, false, false), |
| 470 | GEMMLHSMatrixInfo(4, 4, 1, false, false), |
| 471 | |
| 472 | })), |
| 473 | framework::dataset::make("RHSMInfo",{ |
| 474 | GEMMRHSMatrixInfo(4, 4, 1, true, true, true), |
| 475 | GEMMRHSMatrixInfo(4, 8, 1, true, true, true), |
| 476 | GEMMRHSMatrixInfo(8, 4, 1, true, true, true), |
| 477 | GEMMRHSMatrixInfo(4, 2, 1, true, false, true), |
| 478 | GEMMRHSMatrixInfo(2, 4, 1, true, false, true), |
| 479 | })), |
| 480 | framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 481 | 64 /**<N Number of RHS columns*/, |
| 482 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 483 | false /**< reinterpret the input as 3D */, |
| 484 | true /**< Flag used to broadcast the bias addition */, |
| 485 | false /**< wider accumm */, |
| 486 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 487 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 488 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 489 | GEMMLHSMatrixInfo(), |
| 490 | GEMMRHSMatrixInfo(), |
| 491 | 0 /**< Offset to be added to each element of the matrix A */, |
| 492 | 0 /**< Offset to be added to each element of the matrix B */), |
| 493 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 494 | 64 /**<N Number of RHS columns*/, |
| 495 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 496 | false /**< reinterpret the input as 3D */, |
| 497 | true /**< Flag used to broadcast the bias addition */, |
| 498 | false /**< wider accumm */, |
| 499 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 500 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 501 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 502 | GEMMLHSMatrixInfo(), |
| 503 | GEMMRHSMatrixInfo(), |
| 504 | 0 /**< Offset to be added to each element of the matrix A */, |
| 505 | 0 /**< Offset to be added to each element of the matrix B */), |
| 506 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 507 | 64 /**<N Number of RHS columns*/, |
| 508 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 509 | false /**< reinterpret the input as 3D */, |
| 510 | true /**< Flag used to broadcast the bias addition */, |
| 511 | false /**< wider accumm */, |
| 512 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 513 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 514 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 515 | GEMMLHSMatrixInfo(), |
| 516 | GEMMRHSMatrixInfo(), |
| 517 | 0 /**< Offset to be added to each element of the matrix A */, |
| 518 | 0 /**< Offset to be added to each element of the matrix B */), |
| 519 | |
| 520 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 521 | 64 /**<N Number of RHS columns*/, |
| 522 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 523 | false /**< reinterpret the input as 3D */, |
| 524 | true /**< Flag used to broadcast the bias addition */, |
| 525 | false /**< wider accumm */, |
| 526 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 527 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 528 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 529 | GEMMLHSMatrixInfo(), |
| 530 | GEMMRHSMatrixInfo(), |
| 531 | 0 /**< Offset to be added to each element of the matrix A */, |
| 532 | 0 /**< Offset to be added to each element of the matrix B */), |
| 533 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 534 | 64 /**<N Number of RHS columns*/, |
| 535 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 536 | false /**< reinterpret the input as 3D */, |
| 537 | true /**< Flag used to broadcast the bias addition */, |
| 538 | false /**< wider accumm */, |
| 539 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 540 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 541 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 542 | GEMMLHSMatrixInfo(), |
| 543 | GEMMRHSMatrixInfo(), |
| 544 | 0 /**< Offset to be added to each element of the matrix A */, |
| 545 | 0 /**< Offset to be added to each element of the matrix B */) |
| 546 | })), |
| 547 | framework::dataset::make("Expected", { true, |
| 548 | true, |
| 549 | true, |
| 550 | false, |
| 551 | false})), |
| 552 | input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected) |
| 553 | { |
| 554 | ARM_COMPUTE_EXPECT(bool(CLGEMMMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true), |
| 555 | &input1_info.clone()->set_is_resizable(true), |
| 556 | &input2_info.clone()->set_is_resizable(true), |
| 557 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 558 | lhs_info, |
| 559 | rhs_info, |
| 560 | gemm_info)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS); |
| 561 | } |
| 562 | |
| 563 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL, |
| 564 | 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] | 565 | m_values, |
| 566 | n_values), |
| 567 | k_values), |
| 568 | b_values), |
| 569 | m0_values_precommit), |
| 570 | n0_values_precommit), |
| 571 | k0_values_precommit), |
| 572 | v0_values_precommit), |
| 573 | h0_values_precommit), |
| 574 | i_values_lhs), |
| 575 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 576 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 577 | framework::dataset::make("DataType", DataType::F32)), |
| 578 | a_values_precommit), |
| 579 | beta_values_precommit), |
| 580 | broadcast_bias_values), |
| 581 | lhs_transpose_values), |
| 582 | act_values)) |
| 583 | { |
| 584 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 585 | if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) |
| 586 | { |
| 587 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 588 | } |
| 589 | else |
| 590 | { |
| 591 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 592 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 593 | } |
| 594 | |
| 595 | } |
| 596 | |
| 597 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::NIGHTLY, |
| 598 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 599 | m_values, |
| 600 | n_values), |
| 601 | k_values), |
| 602 | b_values), |
| 603 | m0_values_nightly), |
| 604 | n0_export_to_cl_image_values_nightly), |
| 605 | k0_export_to_cl_image_values_nightly), |
| 606 | v0_values_nightly), |
| 607 | h0_values_nightly), |
| 608 | i_values_lhs), |
| 609 | i_values_rhs), |
| 610 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 611 | framework::dataset::make("DataType", DataType::F32)), |
| 612 | a_values_nightly), |
| 613 | beta_values_nightly), |
| 614 | broadcast_bias_values), |
| 615 | lhs_transpose_values), |
| 616 | act_values)) |
| 617 | { |
| 618 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 619 | if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) |
| 620 | { |
| 621 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 622 | } |
| 623 | else |
| 624 | { |
| 625 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 626 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL, |
| 631 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 632 | m_w_values, |
| 633 | m_h_values), |
| 634 | n_values), |
| 635 | k_values), |
| 636 | b_values), |
| 637 | m0_values_precommit), |
| 638 | n0_values_precommit), |
| 639 | k0_values_precommit), |
| 640 | v0_values_precommit), |
| 641 | h0_values_precommit), |
| 642 | i_values_lhs), |
| 643 | i_values_rhs), |
| 644 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 645 | framework::dataset::make("DataType", DataType::F32)), |
| 646 | a_values_precommit), |
| 647 | beta_values_precommit), |
| 648 | lhs_transpose_values), |
| 649 | act_values)) |
| 650 | { |
| 651 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 652 | if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) |
| 653 | { |
| 654 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 655 | } |
| 656 | else |
| 657 | { |
| 658 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 659 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::NIGHTLY, |
| 664 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 665 | m_w_values, |
| 666 | m_h_values), |
| 667 | n_values), |
| 668 | k_values), |
| 669 | b_values), |
| 670 | m0_values_nightly), |
| 671 | n0_export_to_cl_image_values_nightly), |
| 672 | k0_export_to_cl_image_values_nightly), |
| 673 | v0_values_nightly), |
| 674 | h0_values_nightly), |
| 675 | i_values_lhs), |
| 676 | i_values_rhs), |
| 677 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 678 | framework::dataset::make("DataType", DataType::F32)), |
| 679 | a_values_nightly), |
| 680 | beta_values_nightly), |
| 681 | lhs_transpose_values), |
| 682 | act_values)) |
| 683 | { |
| 684 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 685 | if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) |
| 686 | { |
| 687 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 688 | } |
| 689 | else |
| 690 | { |
| 691 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 692 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 693 | } |
| 694 | } |
| 695 | TEST_SUITE_END() // ExportToCLImage |
| 696 | TEST_SUITE_END() // FP32 |
| 697 | |
| 698 | TEST_SUITE(FP16) |
| 699 | |
| 700 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::ALL, |
| 701 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 702 | m_values, |
| 703 | n_values), |
| 704 | k_values), |
| 705 | b_values), |
| 706 | m0_values_precommit), |
| 707 | n0_values_precommit), |
| 708 | k0_values_precommit), |
| 709 | v0_values_precommit), |
| 710 | h0_values_precommit), |
| 711 | i_values_lhs), |
| 712 | i_values_rhs), |
| 713 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 714 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 715 | a_values_precommit), |
| 716 | beta_values_precommit), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 717 | broadcast_bias_values), |
| 718 | lhs_transpose_values), |
| 719 | act_values)) |
| 720 | { |
| 721 | // Validate output |
| 722 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 723 | } |
| 724 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 725 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 726 | 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] | 727 | m_values, |
| 728 | n_values), |
| 729 | k_values), |
| 730 | b_values), |
| 731 | m0_values_nightly), |
| 732 | n0_values_nightly), |
| 733 | k0_values_nightly), |
| 734 | v0_values_nightly), |
| 735 | h0_values_nightly), |
| 736 | i_values_lhs), |
| 737 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 738 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 739 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 740 | a_values_nightly), |
| 741 | beta_values_nightly), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 742 | broadcast_bias_values), |
| 743 | lhs_transpose_values), |
| 744 | act_values)) |
| 745 | { |
| 746 | // Validate output |
| 747 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 748 | } |
| 749 | |
| 750 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 751 | 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] | 752 | m_w_values, |
| 753 | m_h_values), |
| 754 | n_values), |
| 755 | k_values), |
| 756 | b_values), |
| 757 | m0_values_precommit), |
| 758 | n0_values_precommit), |
| 759 | k0_values_precommit), |
| 760 | v0_values_precommit), |
| 761 | h0_values_precommit), |
| 762 | i_values_lhs), |
| 763 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 764 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 765 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 766 | a_values_precommit), |
| 767 | beta_values_precommit), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 768 | lhs_transpose_values), |
| 769 | act_values)) |
| 770 | { |
| 771 | // Validate output |
| 772 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 773 | } |
| 774 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 775 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 776 | 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] | 777 | m_w_values, |
| 778 | m_h_values), |
| 779 | n_values), |
| 780 | k_values), |
| 781 | b_values), |
| 782 | m0_values_nightly), |
| 783 | n0_values_nightly), |
| 784 | k0_values_nightly), |
| 785 | v0_values_nightly), |
| 786 | h0_values_nightly), |
| 787 | i_values_lhs), |
| 788 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 789 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 790 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 791 | a_values_nightly), |
| 792 | beta_values_nightly), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 793 | lhs_transpose_values), |
| 794 | act_values)) |
| 795 | { |
| 796 | // Validate output |
| 797 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 798 | } |
| 799 | TEST_SUITE_END() // FP16 |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 800 | |
| 801 | TEST_SUITE(MixedPrecision) |
| 802 | |
| 803 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 804 | 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] | 805 | m_values, |
| 806 | n_values), |
| 807 | k_values), |
| 808 | b_values), |
| 809 | m0_values_precommit), |
| 810 | n0_values_precommit), |
| 811 | k0_values_precommit), |
| 812 | v0_values_precommit), |
| 813 | h0_values_precommit), |
| 814 | i_values_lhs), |
| 815 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 816 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 817 | framework::dataset::make("DataType", DataType::F16)), |
| 818 | a_values_precommit), |
| 819 | beta_values_precommit), |
| 820 | broadcast_bias_values), |
| 821 | lhs_transpose_values), |
| 822 | act_values)) |
| 823 | { |
| 824 | // Validate output |
| 825 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 826 | } |
| 827 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 828 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 829 | 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] | 830 | m_values, |
| 831 | n_values), |
| 832 | k_values), |
| 833 | b_values), |
| 834 | m0_values_nightly), |
| 835 | n0_values_nightly), |
| 836 | k0_values_nightly), |
| 837 | v0_values_nightly), |
| 838 | h0_values_nightly), |
| 839 | i_values_lhs), |
| 840 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 841 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 842 | framework::dataset::make("DataType", DataType::F16)), |
| 843 | a_values_nightly), |
| 844 | beta_values_nightly), |
| 845 | broadcast_bias_values), |
| 846 | lhs_transpose_values), |
| 847 | act_values)) |
| 848 | { |
| 849 | // Validate output |
| 850 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 851 | } |
| 852 | |
| 853 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 854 | 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] | 855 | m_w_values, |
| 856 | m_h_values), |
| 857 | n_values), |
| 858 | k_values), |
| 859 | b_values), |
| 860 | m0_values_precommit), |
| 861 | n0_values_precommit), |
| 862 | k0_values_precommit), |
| 863 | v0_values_precommit), |
| 864 | h0_values_precommit), |
| 865 | i_values_lhs), |
| 866 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 867 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 868 | framework::dataset::make("DataType", DataType::F16)), |
| 869 | a_values_precommit), |
| 870 | beta_values_precommit), |
| 871 | lhs_transpose_values), |
| 872 | act_values)) |
| 873 | { |
| 874 | // Validate output |
| 875 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 876 | } |
| 877 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 878 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 879 | 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] | 880 | m_w_values, |
| 881 | m_h_values), |
| 882 | n_values), |
| 883 | k_values), |
| 884 | b_values), |
| 885 | m0_values_nightly), |
| 886 | n0_values_nightly), |
| 887 | k0_values_nightly), |
| 888 | v0_values_nightly), |
| 889 | h0_values_nightly), |
| 890 | i_values_lhs), |
| 891 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame^] | 892 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 893 | framework::dataset::make("DataType", DataType::F16)), |
| 894 | a_values_nightly), |
| 895 | beta_values_nightly), |
| 896 | lhs_transpose_values), |
| 897 | act_values)) |
| 898 | { |
| 899 | // Validate output |
| 900 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 901 | } |
| 902 | TEST_SUITE_END() // MixedPrecision |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 903 | TEST_SUITE_END() // Float |
Gian Marco Iodice | d1f5476 | 2019-07-19 09:54:47 +0100 | [diff] [blame] | 904 | TEST_SUITE_END() // GEMMMatrixMultiplyReshaped |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 905 | TEST_SUITE_END() // CL |
| 906 | } // namespace validation |
| 907 | } // namespace test |
Michele Di Giorgio | 2568c6b | 2019-09-17 12:08:46 +0100 | [diff] [blame] | 908 | } // namespace arm_compute |