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" |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 29 | #include "src/core/experimental/PostOp.h" |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 30 | #include "src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.h" |
| 31 | #include "src/gpu/cl/kernels/ClGemmReshapeLhsMatrixKernel.h" |
| 32 | #include "src/gpu/cl/kernels/ClGemmReshapeRhsMatrixKernel.h" |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 33 | #include "tests/CL/CLAccessor.h" |
| 34 | #include "tests/CL/Helper.h" |
| 35 | #include "tests/PaddingCalculator.h" |
| 36 | #include "tests/datasets/ShapeDatasets.h" |
| 37 | #include "tests/framework/Asserts.h" |
| 38 | #include "tests/framework/Macros.h" |
| 39 | #include "tests/framework/datasets/Datasets.h" |
| 40 | #include "tests/validation/Validation.h" |
| 41 | #include "tests/validation/fixtures/GEMMFixture.h" |
| 42 | |
| 43 | namespace arm_compute |
| 44 | { |
| 45 | namespace test |
| 46 | { |
| 47 | namespace validation |
| 48 | { |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 49 | using namespace arm_compute::misc::shape_calculator; |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 50 | using namespace arm_compute::opencl::kernels; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 51 | |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 52 | // Create function for ClGemmReshapeLhsMatrixKernel |
| 53 | using CLGEMMReshapeLHSMatrix = CLSynthetizeOperator<ClGemmReshapeLhsMatrixKernel>; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 54 | |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 55 | // Create function for ClGemmReshapeRhsMatrixKernel |
| 56 | using CLGEMMReshapeRHSMatrix = CLSynthetizeOperator<ClGemmReshapeRhsMatrixKernel>; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 57 | |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 58 | // Create function for ClGemmMatrixMultiplyReshapedKernel |
| 59 | using CLGEMMMatrixMultiplyReshaped = CLSynthetizeOperator<ClGemmMatrixMultiplyReshapedKernel>; |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 60 | |
| 61 | // Fixture for CLGEMMMatrixMultiplyReshaped |
| 62 | template <typename T> |
| 63 | using CLGEMMMatrixMultiplyReshapedFixture = GEMMMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>; |
| 64 | |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 65 | // Fixture for CLGEMMMatrixMultiplyReshaped with post ops |
| 66 | template <typename T> |
| 67 | using CLGEMMMatrixMultiplyReshapedWithPostOpsFixture = |
| 68 | GEMMMatrixMultiplyReshapedWithPostOpsValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>; |
| 69 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 70 | // Fixture for CLGEMMMatrixMultiplyReshaped mixed precision |
| 71 | template <typename T> |
| 72 | using CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture = |
| 73 | GEMMMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>; |
| 74 | |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 75 | // Fixture for CLGEMMMatrixMultiplyReshaped mixed precision with post ops |
| 76 | template <typename T> |
| 77 | using CLGEMMMatrixMultiplyReshapedMixedPrecisionWithPostOpsFixture = |
| 78 | GEMMMatrixMultiplyReshapedWithPostOpsValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>; |
| 79 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 80 | // Fixture for CLGEMMMatrixMultiplyReshaped3D |
| 81 | template <typename T> |
| 82 | using CLGEMMMatrixMultiplyReshaped3DFixture = GEMMMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped>; |
| 83 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 84 | // Fixture for CLGEMMMatrixMultiplyReshaped3D mixed precision |
| 85 | template <typename T> |
| 86 | using CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture = |
| 87 | GEMMMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshaped, true>; |
| 88 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 89 | namespace |
| 90 | { |
| 91 | // *INDENT-OFF* |
| 92 | // clang-format off |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 93 | RelativeTolerance<float> rel_tolerance_f32(0.001f); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 94 | constexpr float abs_tolerance_f32(0.0001f); |
| 95 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 96 | RelativeTolerance<float> rel_tolerance_f16_mixed_precision(0.001f); |
| 97 | constexpr float abs_tolerance_f16_mixed_precision(0.01f); |
| 98 | |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 99 | RelativeTolerance<float> rel_tolerance_f16(0.001f); |
| 100 | constexpr float abs_tolerance_f16(0.01f); |
| 101 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 102 | /** M values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 103 | const auto m_values = framework::dataset::make("M", 17); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 104 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 105 | /** M_W values to test */ |
| 106 | const auto m_w_values = framework::dataset::make("M_W", 5); |
| 107 | |
| 108 | /** M_H values to test */ |
| 109 | const auto m_h_values = framework::dataset::make("M_H", 7); |
| 110 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 111 | /** N values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 112 | const auto n_values = framework::dataset::make("N", 21); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 113 | |
| 114 | /** K values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 115 | const auto k_values = framework::dataset::make("K", 13); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 116 | |
| 117 | /** Batch size values to test */ |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 118 | const auto b_values = framework::dataset::make("batch_size", 2, 3); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 119 | |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 120 | /** Activation values to test */ |
| 121 | const auto act_values = framework::dataset::make("Activation", |
| 122 | { |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 123 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 8.f, 2.f), |
| 124 | }); |
| 125 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 126 | /** Alpha values to test - Precommit */ |
| 127 | const auto a_values_precommit = framework::dataset::make("alpha", {-0.75f} ); |
| 128 | |
| 129 | /** Beta values to test - Precommit */ |
| 130 | const auto beta_values_precommit = framework::dataset::make("beta", {-0.35f} ); |
| 131 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 132 | /** M0 values to test - Precommit */ |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 133 | const auto m0_values_precommit = framework::dataset::make("M0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 134 | |
| 135 | /** N0 values to test - Precommit */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 136 | const auto n0_values_precommit = framework::dataset::make("N0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 137 | |
| 138 | /** K0 values to test - Precommit */ |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 139 | const auto k0_values_precommit = framework::dataset::make("K0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 140 | |
| 141 | /** V0 values to test - Precommit */ |
| 142 | const auto v0_values_precommit = framework::dataset::make("V0", 1, 3); |
| 143 | |
| 144 | /** H0 values to test - Precommit */ |
| 145 | const auto h0_values_precommit = framework::dataset::make("H0", 1, 3); |
| 146 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 147 | /** Alpha values to test - Nightly */ |
| 148 | const auto a_values_nightly = framework::dataset::make("alpha", {1.0f} ); |
| 149 | |
| 150 | /** Beta values to test - Nightly */ |
| 151 | const auto beta_values_nightly = framework::dataset::make("beta", {1.0f} ); |
| 152 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 153 | /** M0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 154 | const auto m0_values_nightly = framework::dataset::make("M0", { 8 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 155 | |
| 156 | /** N0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 157 | const auto n0_values_nightly = framework::dataset::make("N0", { 8 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 158 | |
| 159 | /** K0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 160 | const auto k0_values_nightly = framework::dataset::make("K0", { 4 }); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 161 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 162 | /** N0 values to test with export to OpenCL image object - Nightly */ |
| 163 | const auto n0_export_to_cl_image_values_nightly = framework::dataset::make("N0", { 4, 8, 16 }); |
| 164 | |
| 165 | /** K0 values to test with export to OpenCL image object - Nightly */ |
| 166 | const auto k0_export_to_cl_image_values_nightly = framework::dataset::make("K0", { 4, 8, 16 }); |
| 167 | |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 168 | /** V0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 169 | const auto v0_values_nightly = framework::dataset::make("V0", 1, 3); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 170 | |
| 171 | /** H0 values to test - Nightly */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 172 | const auto h0_values_nightly = framework::dataset::make("H0", 1, 3); |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 173 | |
| 174 | /** Interleave values to test with LHS matrix */ |
| 175 | const auto i_values_lhs = framework::dataset::make("interleave_lhs", { true, false }); |
| 176 | |
| 177 | /** Interleave values to test with RHS matrix */ |
| 178 | const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false }); |
| 179 | |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 180 | /** Broadcast bias from vector to matrix */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 181 | 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] | 182 | |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 183 | /** LHS transposed values */ |
| 184 | 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] | 185 | |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 186 | /** Post Ops */ |
| 187 | using PostOpArgBroadcast = CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<float>::PostOpArgBroadcast; |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 188 | experimental::PostOpList<PostOpArgBroadcast> post_ops_1() |
| 189 | { |
| 190 | experimental::PostOpList<PostOpArgBroadcast> post_ops{}; |
| 191 | post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); |
| 192 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<PostOpArgBroadcast>>( |
| 193 | std::make_tuple(true, true, false), // If broadcast in dims 0, 1 and 2 |
| 194 | 0, |
| 195 | ConvertPolicy::SATURATE); |
| 196 | post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); |
| 197 | return post_ops; |
| 198 | } |
| 199 | experimental::PostOpList<PostOpArgBroadcast> post_ops_2() |
| 200 | { |
| 201 | experimental::PostOpList<PostOpArgBroadcast> post_ops{}; |
| 202 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<PostOpArgBroadcast>>( |
| 203 | std::make_tuple(false, true, true), // If broadcast in dims 0, 1 and 2 |
| 204 | 1, |
| 205 | ConvertPolicy::SATURATE); |
| 206 | post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); |
| 207 | return post_ops; |
| 208 | } |
| 209 | experimental::PostOpList<PostOpArgBroadcast> post_ops_3() |
| 210 | { |
| 211 | experimental::PostOpList<PostOpArgBroadcast> post_ops{}; |
| 212 | post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); |
| 213 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<PostOpArgBroadcast>>( |
| 214 | std::make_tuple(false, false, true), // If broadcast in dims 0, 1 and 2 |
| 215 | 1, |
| 216 | ConvertPolicy::SATURATE); |
| 217 | return post_ops; |
| 218 | } |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 219 | /** Different Post Op Lists */ |
| 220 | const auto post_op_lists = framework::dataset::make("post_op_lists", { |
| 221 | post_ops_1(), |
| 222 | post_ops_2(), |
| 223 | post_ops_3(), |
| 224 | } ); |
| 225 | |
SiCongLi | eb8bd81 | 2021-10-29 15:05:49 +0100 | [diff] [blame^] | 226 | bool is_post_op_list_valid(unsigned int m, unsigned int n, unsigned int k, unsigned int batch, DataType data_type, const experimental::PostOpList<ITensorInfo*>& post_ops) |
| 227 | { |
| 228 | const auto lhs_info = GEMMLHSMatrixInfo(4,4,1,false,true); |
| 229 | const auto rhs_info = GEMMRHSMatrixInfo(4,4,1,true,true,false); |
| 230 | |
| 231 | // Create TensorInfo for post op arguments |
| 232 | TensorInfo input0_info(TensorShape(k, m, batch), 1, data_type); |
| 233 | TensorInfo input1_info(TensorShape(n, k, batch), 1, data_type); |
| 234 | TensorInfo input2_info(TensorShape(n), 1, data_type); |
| 235 | TensorInfo output_info(TensorShape(n, m, batch), 1, data_type); |
| 236 | |
| 237 | const TensorInfo reshaped_input0_info = input0_info.clone()->set_tensor_shape(misc::shape_calculator::compute_lhs_reshaped_shape(input0_info, lhs_info)); |
| 238 | const TensorInfo reshaped_input1_info = input1_info.clone()->set_tensor_shape(misc::shape_calculator::compute_rhs_reshaped_shape(input1_info, rhs_info)); |
| 239 | |
| 240 | GEMMKernelInfo gemm_info(m, n, k, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 241 | false /**< reinterpret the input as 3D */, |
| 242 | true /**< Flag used to broadcast the bias addition */, |
| 243 | false /**< wider accumm */, |
| 244 | false /**< has pad y */, |
| 245 | ActivationLayerInfo::ActivationFunction::IDENTITY, |
| 246 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 247 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 248 | lhs_info, |
| 249 | rhs_info, |
| 250 | 0 /**< Offset to be added to each element of the matrix A */, |
| 251 | 0 /**< Offset to be added to each element of the matrix B */, |
| 252 | post_ops); |
| 253 | return bool(ClGemmMatrixMultiplyReshapedKernel::validate(&reshaped_input0_info.clone()->set_is_resizable(true), |
| 254 | &reshaped_input1_info.clone()->set_is_resizable(true), |
| 255 | &input2_info.clone()->set_is_resizable(true), |
| 256 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 257 | lhs_info, |
| 258 | rhs_info, |
| 259 | gemm_info)); |
| 260 | } |
| 261 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 262 | } // namespace |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 263 | |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 264 | TEST_SUITE(CL) |
| 265 | TEST_SUITE(GEMMMatrixMultiplyReshaped) |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 266 | |
| 267 | // *INDENT-OFF* |
| 268 | // clang-format off |
| 269 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( |
| 270 | framework::dataset::make("Input0Info", { TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // OK |
| 271 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK |
| 272 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8), // Data type not supported |
| 273 | TensorInfo(TensorShape(10U, 5U, 2U), 1, DataType::F32), // Incorrect dimension bias |
| 274 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F32), // Mismatching shapes |
| 275 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, do not broadcast bias |
| 276 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, wider accummulation |
| 277 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::F16), // OK, RHS 4,4,2 |
| 278 | |
| 279 | }), |
| 280 | framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32), |
| 281 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16), |
| 282 | TensorInfo(TensorShape(64U, 5U, 2U), 1, DataType::QASYMM8), |
| 283 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F32), |
| 284 | TensorInfo(TensorShape(48U, 11U, 2U), 1, DataType::F32), |
| 285 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16), |
| 286 | TensorInfo(TensorShape(64U, 6U, 2U), 1, DataType::F16), |
| 287 | TensorInfo(TensorShape(128U, 3U, 2U), 1, DataType::F16), |
| 288 | |
| 289 | })), |
| 290 | framework::dataset::make("Input2Info", { TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 291 | TensorInfo(TensorShape(21U), 1, DataType::F16), |
| 292 | TensorInfo(TensorShape(21U), 1, DataType::QASYMM8), |
| 293 | TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 294 | TensorInfo(TensorShape(21U), 1, DataType::F32), |
| 295 | TensorInfo(TensorShape(21U,17U), 1, DataType::F16), |
| 296 | TensorInfo(TensorShape(21U,17U), 1, DataType::F16), |
| 297 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 298 | |
| 299 | })), |
| 300 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32), |
| 301 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 302 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::QASYMM8), |
| 303 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32), |
| 304 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F32), |
| 305 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 306 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 307 | TensorInfo(TensorShape(21U,17U,2U), 1, DataType::F16), |
| 308 | |
| 309 | })), |
| 310 | framework::dataset::make("LHSMInfo",{ |
| 311 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 312 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 313 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 314 | GEMMLHSMatrixInfo(4,2,4,false,false), |
| 315 | GEMMLHSMatrixInfo(4,2,4,false,false), |
| 316 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 317 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 318 | GEMMLHSMatrixInfo(4,4,1,false,true), |
| 319 | |
| 320 | })), |
| 321 | framework::dataset::make("RHSMInfo",{ |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 322 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 323 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 324 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 325 | GEMMRHSMatrixInfo(2,2,1,true,false,false), |
| 326 | GEMMRHSMatrixInfo(2,2,1,true,false,false), |
| 327 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 328 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
| 329 | GEMMRHSMatrixInfo(4,4,2,true,false,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 330 | |
| 331 | |
| 332 | })), |
| 333 | |
| 334 | |
| 335 | framework::dataset::make("GEMMInfo",{ |
| 336 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 337 | 21 /**<N Number of RHS columns*/, |
| 338 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 339 | false /**< reinterpret the input as 3D */, |
| 340 | true /**< Flag used to broadcast the bias addition */, |
| 341 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 342 | false /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 343 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 344 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 345 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 346 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 347 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 348 | 0 /**< Offset to be added to each element of the matrix A */, |
| 349 | 0 /**< Offset to be added to each element of the matrix B */), |
| 350 | |
| 351 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 352 | 21 /**<N Number of RHS columns*/, |
| 353 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 354 | false /**< reinterpret the input as 3D */, |
| 355 | true /**< Flag used to broadcast the bias addition */, |
| 356 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 357 | false /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 358 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 359 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 360 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 361 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 362 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 363 | 0 /**< Offset to be added to each element of the matrix A */, |
| 364 | 0 /**< Offset to be added to each element of the matrix B */), |
| 365 | GEMMKernelInfo(), |
| 366 | GEMMKernelInfo(), |
| 367 | GEMMKernelInfo(), |
| 368 | |
| 369 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 370 | 21 /**<N Number of RHS columns*/, |
| 371 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 372 | false /**< reinterpret the input as 3D */, |
| 373 | false /**< Flag used to broadcast the bias addition */, |
| 374 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 375 | false /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 376 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 377 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 378 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 379 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 380 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 381 | 0 /**< Offset to be added to each element of the matrix A */, |
| 382 | 0 /**< Offset to be added to each element of the matrix B */), |
| 383 | |
| 384 | |
| 385 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 386 | 21 /**<N Number of RHS columns*/, |
| 387 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 388 | false /**< reinterpret the input as 3D */, |
| 389 | false /**< Flag used to broadcast the bias addition */, |
| 390 | true /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 391 | true /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 392 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 393 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 394 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 395 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 396 | GEMMRHSMatrixInfo(4,4,1,true,true,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 397 | 0 /**< Offset to be added to each element of the matrix A */, |
| 398 | 0 /**< Offset to be added to each element of the matrix B */), |
| 399 | |
| 400 | GEMMKernelInfo( 17 /**<M Number of LHS rows*/, |
| 401 | 21 /**<N Number of RHS columns*/, |
| 402 | 13 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 403 | false /**< reinterpret the input as 3D */, |
| 404 | false /**< Flag used to broadcast the bias addition */, |
| 405 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 406 | false /**< has pad y */, |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 407 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 408 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 409 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 410 | GEMMLHSMatrixInfo(4,4,1,false,true), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 411 | GEMMRHSMatrixInfo(4,4,2,true,false,false), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 412 | 0 /**< Offset to be added to each element of the matrix A */, |
| 413 | 0 /**< Offset to be added to each element of the matrix B */), |
| 414 | })), |
| 415 | framework::dataset::make("Expected", { true, true, false, false, false, true, true,true})), |
| 416 | input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected) |
| 417 | { |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 418 | ARM_COMPUTE_EXPECT(bool(ClGemmMatrixMultiplyReshapedKernel::validate(&input0_info.clone()->set_is_resizable(true), |
morgolock | aba2f91 | 2020-05-05 16:28:19 +0100 | [diff] [blame] | 419 | &input1_info.clone()->set_is_resizable(true), |
| 420 | &input2_info.clone()->set_is_resizable(true), |
| 421 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 422 | lhs_info, |
| 423 | rhs_info, |
| 424 | gemm_info)) == expected, framework::LogLevel::ERRORS); |
| 425 | } |
SiCongLi | eb8bd81 | 2021-10-29 15:05:49 +0100 | [diff] [blame^] | 426 | TEST_SUITE(ValidateFusedPostOpsConfigs) |
| 427 | TEST_SUITE(Invalid) |
| 428 | TEST_CASE(UnsupportedPostOpSequence, framework::DatasetMode::ALL) |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 429 | { |
SiCongLi | eb8bd81 | 2021-10-29 15:05:49 +0100 | [diff] [blame^] | 430 | const auto data_type = DataType::F32; |
| 431 | const unsigned int m = 17; |
| 432 | const unsigned int n = 1; |
| 433 | const unsigned int k = 13; |
| 434 | const unsigned int batch = 2; |
| 435 | TensorShape post_op_arg0_shape(n, m, batch); |
| 436 | TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); |
| 437 | auto post_op_arg1_info = post_op_arg_info.clone(); |
| 438 | |
| 439 | // Unsupported sequence of post ops |
| 440 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 441 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( |
| 442 | &post_op_arg_info, |
| 443 | 1, |
| 444 | ConvertPolicy::SATURATE); |
| 445 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( |
| 446 | post_op_arg1_info.get(), |
| 447 | 0, |
| 448 | ConvertPolicy::SATURATE); |
| 449 | |
| 450 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 451 | } |
SiCongLi | eb8bd81 | 2021-10-29 15:05:49 +0100 | [diff] [blame^] | 452 | TEST_CASE(OutputWidened, framework::DatasetMode::ALL) |
| 453 | { |
| 454 | // Invalid broadcast: post op tensors "widen" the output tensor |
| 455 | const auto data_type = DataType::F32; |
| 456 | const unsigned int m = 17; |
| 457 | const unsigned int n = 1; |
| 458 | const unsigned int k = 13; |
| 459 | const unsigned int batch = 2; |
| 460 | TensorShape post_op_arg_shape(n + 4, m, batch); // output's X dimension (n) is "widened", which is not allowed |
| 461 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 462 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 463 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 464 | |
| 465 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); |
| 466 | } |
| 467 | TEST_CASE(BroadcastInXDimOnly, framework::DatasetMode::ALL) |
| 468 | { |
| 469 | // Invalid broadcast: post op tensors broadcast in the first dimension (X) only |
| 470 | const auto data_type = DataType::F32; |
| 471 | const unsigned int m = 22; |
| 472 | const unsigned int n = 16; |
| 473 | const unsigned int k = 15; |
| 474 | const unsigned int batch = 3; |
| 475 | TensorShape post_op_arg_shape(1, m, batch); |
| 476 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 477 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 478 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 479 | |
| 480 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); |
| 481 | } |
| 482 | TEST_SUITE_END() // Invalid |
| 483 | TEST_SUITE(Valid) |
| 484 | TEST_CASE(EmptyPostOpList, framework::DatasetMode::ALL) |
| 485 | { |
| 486 | const auto data_type = DataType::F32; |
| 487 | const unsigned int m = 22; |
| 488 | const unsigned int n = 16; |
| 489 | const unsigned int k = 15; |
| 490 | const unsigned int batch = 3; |
| 491 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 492 | |
| 493 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); |
| 494 | } |
| 495 | TEST_CASE(BroadcastInYDimOnly, framework::DatasetMode::ALL) |
| 496 | { |
| 497 | const auto data_type = DataType::F32; |
| 498 | const unsigned int m = 22; |
| 499 | const unsigned int n = 16; |
| 500 | const unsigned int k = 15; |
| 501 | const unsigned int batch = 3; |
| 502 | TensorShape post_op_arg_shape(n, 1, batch); |
| 503 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 504 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 505 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 506 | |
| 507 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); |
| 508 | } |
| 509 | TEST_CASE(BroadcastInBothXandYDims, framework::DatasetMode::ALL) |
| 510 | { |
| 511 | const auto data_type = DataType::F32; |
| 512 | const unsigned int m = 22; |
| 513 | const unsigned int n = 16; |
| 514 | const unsigned int k = 15; |
| 515 | const unsigned int batch = 3; |
| 516 | TensorShape post_op_arg_shape(1, 1, batch); |
| 517 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 518 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 519 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 520 | |
| 521 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); |
| 522 | } |
| 523 | TEST_CASE(BroadcastInAllDims, framework::DatasetMode::ALL) |
| 524 | { |
| 525 | const auto data_type = DataType::F32; |
| 526 | const unsigned int m = 22; |
| 527 | const unsigned int n = 16; |
| 528 | const unsigned int k = 15; |
| 529 | const unsigned int batch = 3; |
| 530 | TensorShape post_op_arg_shape(1, 1, 1); |
| 531 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 532 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 533 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 534 | |
| 535 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); |
| 536 | } |
| 537 | TEST_SUITE_END() // Valid |
| 538 | TEST_SUITE_END() // ValidateFusedPostOps |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 539 | TEST_SUITE(Float) |
| 540 | TEST_SUITE(FP32) |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 541 | |
| 542 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 543 | 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] | 544 | m_values, |
| 545 | n_values), |
| 546 | k_values), |
| 547 | b_values), |
| 548 | m0_values_precommit), |
| 549 | n0_values_precommit), |
| 550 | k0_values_precommit), |
| 551 | v0_values_precommit), |
| 552 | h0_values_precommit), |
| 553 | i_values_lhs), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 554 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 555 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 556 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 557 | a_values_precommit), |
| 558 | beta_values_precommit), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 559 | broadcast_bias_values), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 560 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 561 | act_values)) |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 562 | { |
| 563 | // Validate output |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 564 | 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] | 565 | } |
| 566 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 567 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 568 | 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] | 569 | m_values, |
| 570 | n_values), |
| 571 | k_values), |
| 572 | b_values), |
| 573 | m0_values_nightly), |
| 574 | n0_values_nightly), |
| 575 | k0_values_nightly), |
| 576 | v0_values_nightly), |
| 577 | h0_values_nightly), |
| 578 | i_values_lhs), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 579 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 580 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 581 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 582 | a_values_nightly), |
| 583 | beta_values_nightly), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 584 | broadcast_bias_values), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 585 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 586 | act_values)) |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 587 | { |
| 588 | // Validate output |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 589 | 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] | 590 | } |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 591 | |
| 592 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 593 | 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] | 594 | m_w_values, |
| 595 | m_h_values), |
| 596 | n_values), |
| 597 | k_values), |
| 598 | b_values), |
| 599 | m0_values_precommit), |
| 600 | n0_values_precommit), |
| 601 | k0_values_precommit), |
| 602 | v0_values_precommit), |
| 603 | h0_values_precommit), |
| 604 | i_values_lhs), |
| 605 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 606 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 607 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 608 | a_values_precommit), |
| 609 | beta_values_precommit), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 610 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 611 | act_values)) |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 612 | { |
| 613 | // Validate output |
| 614 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 615 | } |
| 616 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 617 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 618 | 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] | 619 | m_w_values, |
| 620 | m_h_values), |
| 621 | n_values), |
| 622 | k_values), |
| 623 | b_values), |
| 624 | m0_values_nightly), |
| 625 | n0_values_nightly), |
| 626 | k0_values_nightly), |
| 627 | v0_values_nightly), |
| 628 | h0_values_nightly), |
| 629 | i_values_lhs), |
| 630 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 631 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 632 | framework::dataset::make("DataType", DataType::F32)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 633 | a_values_nightly), |
| 634 | beta_values_nightly), |
Giorgio Arena | ae99b6e | 2019-08-01 14:22:12 +0100 | [diff] [blame] | 635 | lhs_transpose_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 636 | act_values)) |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 637 | { |
| 638 | // Validate output |
| 639 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 640 | } |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 641 | TEST_SUITE(FusedPostOps) |
| 642 | |
| 643 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<float>, framework::DatasetMode::ALL, |
| 644 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 645 | m_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 | framework::dataset::make("interleave_lhs", { false })), |
| 655 | framework::dataset::make("interleave_rhs", { false })), |
| 656 | framework::dataset::make("export_to_cl_image_rhs", false)), |
| 657 | framework::dataset::make("DataType", DataType::F32)), |
| 658 | a_values_precommit), |
| 659 | beta_values_precommit), |
| 660 | framework::dataset::make("broadcast_bias", { true } )), |
| 661 | lhs_transpose_values), |
| 662 | act_values), |
| 663 | post_op_lists) |
| 664 | ) |
| 665 | { |
| 666 | // Validate output |
| 667 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 668 | } |
| 669 | |
| 670 | TEST_SUITE_END() // FusedPostOps |
| 671 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 672 | TEST_SUITE(ExportToCLImage) |
| 673 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( |
| 674 | framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 675 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 676 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 677 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect k0 |
| 678 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), // Incorrect n0 |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 679 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 680 | }), |
| 681 | framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), |
| 682 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), |
| 683 | TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F32), |
| 684 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F32), |
| 685 | TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F32), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 686 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 687 | })), |
| 688 | framework::dataset::make("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 689 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 690 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 691 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 692 | TensorInfo(TensorShape(64U), 1, DataType::F32), |
| 693 | |
| 694 | })), |
| 695 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 696 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 697 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 698 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 699 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 700 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F32), |
| 701 | |
| 702 | })), |
| 703 | framework::dataset::make("LHSMInfo",{ |
| 704 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 705 | GEMMLHSMatrixInfo(4, 8, 1, false, true), |
| 706 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 707 | GEMMLHSMatrixInfo(4, 2, 1, false, false), |
| 708 | GEMMLHSMatrixInfo(4, 4, 1, false, false), |
| 709 | |
| 710 | })), |
| 711 | framework::dataset::make("RHSMInfo",{ |
| 712 | GEMMRHSMatrixInfo(4, 4, 1, true, true, true), |
| 713 | GEMMRHSMatrixInfo(4, 8, 1, true, true, true), |
| 714 | GEMMRHSMatrixInfo(8, 4, 1, true, true, true), |
| 715 | GEMMRHSMatrixInfo(4, 2, 1, true, false, true), |
| 716 | GEMMRHSMatrixInfo(2, 4, 1, true, false, true), |
| 717 | })), |
| 718 | framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 719 | 64 /**<N Number of RHS columns*/, |
| 720 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 721 | false /**< reinterpret the input as 3D */, |
| 722 | true /**< Flag used to broadcast the bias addition */, |
| 723 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 724 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 725 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 726 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 727 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 728 | GEMMLHSMatrixInfo(), |
| 729 | GEMMRHSMatrixInfo(), |
| 730 | 0 /**< Offset to be added to each element of the matrix A */, |
| 731 | 0 /**< Offset to be added to each element of the matrix B */), |
| 732 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 733 | 64 /**<N Number of RHS columns*/, |
| 734 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 735 | false /**< reinterpret the input as 3D */, |
| 736 | true /**< Flag used to broadcast the bias addition */, |
| 737 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 738 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 739 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 740 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 741 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 742 | GEMMLHSMatrixInfo(), |
| 743 | GEMMRHSMatrixInfo(), |
| 744 | 0 /**< Offset to be added to each element of the matrix A */, |
| 745 | 0 /**< Offset to be added to each element of the matrix B */), |
| 746 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 747 | 64 /**<N Number of RHS columns*/, |
| 748 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 749 | false /**< reinterpret the input as 3D */, |
| 750 | true /**< Flag used to broadcast the bias addition */, |
| 751 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 752 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 753 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 754 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 755 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 756 | GEMMLHSMatrixInfo(), |
| 757 | GEMMRHSMatrixInfo(), |
| 758 | 0 /**< Offset to be added to each element of the matrix A */, |
| 759 | 0 /**< Offset to be added to each element of the matrix B */), |
| 760 | |
| 761 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 762 | 64 /**<N Number of RHS columns*/, |
| 763 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 764 | false /**< reinterpret the input as 3D */, |
| 765 | true /**< Flag used to broadcast the bias addition */, |
| 766 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 767 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 768 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 769 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 770 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 771 | GEMMLHSMatrixInfo(), |
| 772 | GEMMRHSMatrixInfo(), |
| 773 | 0 /**< Offset to be added to each element of the matrix A */, |
| 774 | 0 /**< Offset to be added to each element of the matrix B */), |
| 775 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 776 | 64 /**<N Number of RHS columns*/, |
| 777 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 778 | false /**< reinterpret the input as 3D */, |
| 779 | true /**< Flag used to broadcast the bias addition */, |
| 780 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 781 | false /**< has pad y */, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 782 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 783 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 784 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 785 | GEMMLHSMatrixInfo(), |
| 786 | GEMMRHSMatrixInfo(), |
| 787 | 0 /**< Offset to be added to each element of the matrix A */, |
| 788 | 0 /**< Offset to be added to each element of the matrix B */) |
| 789 | })), |
| 790 | framework::dataset::make("Expected", { true, |
| 791 | true, |
| 792 | true, |
| 793 | false, |
| 794 | false})), |
| 795 | input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected) |
| 796 | { |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 797 | 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] | 798 | &input1_info.clone()->set_is_resizable(true), |
| 799 | &input2_info.clone()->set_is_resizable(true), |
| 800 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 801 | lhs_info, |
| 802 | rhs_info, |
| 803 | gemm_info)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS); |
| 804 | } |
| 805 | |
| 806 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::ALL, |
| 807 | 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] | 808 | m_values, |
| 809 | n_values), |
| 810 | k_values), |
| 811 | b_values), |
| 812 | m0_values_precommit), |
| 813 | n0_values_precommit), |
| 814 | k0_values_precommit), |
| 815 | v0_values_precommit), |
| 816 | h0_values_precommit), |
| 817 | i_values_lhs), |
| 818 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 819 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 820 | framework::dataset::make("DataType", DataType::F32)), |
| 821 | a_values_precommit), |
| 822 | beta_values_precommit), |
| 823 | broadcast_bias_values), |
| 824 | lhs_transpose_values), |
| 825 | act_values)) |
| 826 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 827 | // Validate output only if validate() is successful |
| 828 | if(validate_result) |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 829 | { |
| 830 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 831 | } |
| 832 | else |
| 833 | { |
| 834 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 835 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 836 | } |
| 837 | |
| 838 | } |
| 839 | |
| 840 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<float>, framework::DatasetMode::NIGHTLY, |
| 841 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 842 | m_values, |
| 843 | n_values), |
| 844 | k_values), |
| 845 | b_values), |
| 846 | m0_values_nightly), |
| 847 | n0_export_to_cl_image_values_nightly), |
| 848 | k0_export_to_cl_image_values_nightly), |
| 849 | v0_values_nightly), |
| 850 | h0_values_nightly), |
| 851 | i_values_lhs), |
| 852 | i_values_rhs), |
| 853 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 854 | framework::dataset::make("DataType", DataType::F32)), |
| 855 | a_values_nightly), |
| 856 | beta_values_nightly), |
| 857 | broadcast_bias_values), |
| 858 | lhs_transpose_values), |
| 859 | act_values)) |
| 860 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 861 | // Validate output only if validate() is successful |
| 862 | if(validate_result) |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 863 | { |
| 864 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 865 | } |
| 866 | else |
| 867 | { |
| 868 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 869 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::ALL, |
| 874 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 875 | m_w_values, |
| 876 | m_h_values), |
| 877 | n_values), |
| 878 | k_values), |
| 879 | b_values), |
| 880 | m0_values_precommit), |
| 881 | n0_values_precommit), |
| 882 | k0_values_precommit), |
| 883 | v0_values_precommit), |
| 884 | h0_values_precommit), |
| 885 | i_values_lhs), |
| 886 | i_values_rhs), |
| 887 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 888 | framework::dataset::make("DataType", DataType::F32)), |
| 889 | a_values_precommit), |
| 890 | beta_values_precommit), |
| 891 | lhs_transpose_values), |
| 892 | act_values)) |
| 893 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 894 | // Validate output only if validate() is successful |
| 895 | if(validate_result) |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 896 | { |
| 897 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 898 | } |
| 899 | else |
| 900 | { |
| 901 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 902 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 903 | } |
| 904 | } |
| 905 | |
| 906 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<float>, framework::DatasetMode::NIGHTLY, |
| 907 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 908 | m_w_values, |
| 909 | m_h_values), |
| 910 | n_values), |
| 911 | k_values), |
| 912 | b_values), |
| 913 | m0_values_nightly), |
| 914 | n0_export_to_cl_image_values_nightly), |
| 915 | k0_export_to_cl_image_values_nightly), |
| 916 | v0_values_nightly), |
| 917 | h0_values_nightly), |
| 918 | i_values_lhs), |
| 919 | i_values_rhs), |
| 920 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 921 | framework::dataset::make("DataType", DataType::F32)), |
| 922 | a_values_nightly), |
| 923 | beta_values_nightly), |
| 924 | lhs_transpose_values), |
| 925 | act_values)) |
| 926 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 927 | // Validate output only if validate() is successful |
| 928 | if(validate_result) |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 929 | { |
| 930 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 931 | } |
| 932 | else |
| 933 | { |
| 934 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 935 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 936 | } |
| 937 | } |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 938 | TEST_SUITE(FusedPostOps) |
| 939 | |
| 940 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<float>, framework::DatasetMode::ALL, |
| 941 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 942 | m_values, |
| 943 | n_values), |
| 944 | k_values), |
| 945 | b_values), |
| 946 | m0_values_precommit), |
| 947 | n0_values_precommit), |
| 948 | k0_values_precommit), |
| 949 | v0_values_precommit), |
| 950 | h0_values_precommit), |
| 951 | framework::dataset::make("interleave_lhs", { false })), |
| 952 | framework::dataset::make("interleave_rhs", { false })), |
| 953 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 954 | framework::dataset::make("DataType", DataType::F32)), |
| 955 | a_values_precommit), |
| 956 | beta_values_precommit), |
| 957 | framework::dataset::make("broadcast_bias", { true } )), |
| 958 | lhs_transpose_values), |
| 959 | act_values), |
| 960 | post_op_lists) |
| 961 | ) |
| 962 | { |
| 963 | // Validate output only if validate() is successful |
| 964 | if(validate_result) |
| 965 | { |
| 966 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 967 | } |
| 968 | else |
| 969 | { |
| 970 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 971 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 972 | } |
| 973 | } |
| 974 | |
| 975 | TEST_SUITE_END() // FusedPostOps |
| 976 | |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 977 | TEST_SUITE_END() // ExportToCLImage |
| 978 | TEST_SUITE_END() // FP32 |
| 979 | |
| 980 | TEST_SUITE(FP16) |
| 981 | |
| 982 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::ALL, |
| 983 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 984 | m_values, |
| 985 | n_values), |
| 986 | k_values), |
| 987 | b_values), |
| 988 | m0_values_precommit), |
| 989 | n0_values_precommit), |
| 990 | k0_values_precommit), |
| 991 | v0_values_precommit), |
| 992 | h0_values_precommit), |
| 993 | i_values_lhs), |
| 994 | i_values_rhs), |
| 995 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 996 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 997 | a_values_precommit), |
| 998 | beta_values_precommit), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 999 | broadcast_bias_values), |
| 1000 | lhs_transpose_values), |
| 1001 | act_values)) |
| 1002 | { |
| 1003 | // Validate output |
| 1004 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1005 | } |
| 1006 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 1007 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1008 | 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] | 1009 | m_values, |
| 1010 | n_values), |
| 1011 | k_values), |
| 1012 | b_values), |
| 1013 | m0_values_nightly), |
| 1014 | n0_values_nightly), |
| 1015 | k0_values_nightly), |
| 1016 | v0_values_nightly), |
| 1017 | h0_values_nightly), |
| 1018 | i_values_lhs), |
| 1019 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1020 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 1021 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1022 | a_values_nightly), |
| 1023 | beta_values_nightly), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 1024 | broadcast_bias_values), |
| 1025 | lhs_transpose_values), |
| 1026 | act_values)) |
| 1027 | { |
| 1028 | // Validate output |
| 1029 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1030 | } |
| 1031 | |
| 1032 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1033 | 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] | 1034 | m_w_values, |
| 1035 | m_h_values), |
| 1036 | n_values), |
| 1037 | k_values), |
| 1038 | b_values), |
| 1039 | m0_values_precommit), |
| 1040 | n0_values_precommit), |
| 1041 | k0_values_precommit), |
| 1042 | v0_values_precommit), |
| 1043 | h0_values_precommit), |
| 1044 | i_values_lhs), |
| 1045 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1046 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 1047 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1048 | a_values_precommit), |
| 1049 | beta_values_precommit), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 1050 | lhs_transpose_values), |
| 1051 | act_values)) |
| 1052 | { |
| 1053 | // Validate output |
| 1054 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1055 | } |
| 1056 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 1057 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1058 | 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] | 1059 | m_w_values, |
| 1060 | m_h_values), |
| 1061 | n_values), |
| 1062 | k_values), |
| 1063 | b_values), |
| 1064 | m0_values_nightly), |
| 1065 | n0_values_nightly), |
| 1066 | k0_values_nightly), |
| 1067 | v0_values_nightly), |
| 1068 | h0_values_nightly), |
| 1069 | i_values_lhs), |
| 1070 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1071 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 1072 | framework::dataset::make("DataType", DataType::F16)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1073 | a_values_nightly), |
| 1074 | beta_values_nightly), |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 1075 | lhs_transpose_values), |
| 1076 | act_values)) |
| 1077 | { |
| 1078 | // Validate output |
| 1079 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1080 | } |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1081 | |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 1082 | TEST_SUITE(FusedPostOps) |
| 1083 | |
| 1084 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<half>, framework::DatasetMode::ALL, |
| 1085 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1086 | m_values, |
| 1087 | n_values), |
| 1088 | k_values), |
| 1089 | b_values), |
| 1090 | m0_values_precommit), |
| 1091 | n0_values_precommit), |
| 1092 | k0_values_precommit), |
| 1093 | v0_values_precommit), |
| 1094 | h0_values_precommit), |
| 1095 | framework::dataset::make("interleave_lhs", { false })), |
| 1096 | framework::dataset::make("interleave_rhs", { false })), |
| 1097 | framework::dataset::make("export_to_cl_image_rhs", false)), |
| 1098 | framework::dataset::make("DataType", DataType::F16)), |
| 1099 | a_values_precommit), |
| 1100 | beta_values_precommit), |
| 1101 | framework::dataset::make("broadcast_bias", { true } )), |
| 1102 | lhs_transpose_values), |
| 1103 | act_values), |
| 1104 | post_op_lists) |
| 1105 | ) |
| 1106 | { |
| 1107 | // Validate output |
| 1108 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1109 | } |
| 1110 | |
| 1111 | TEST_SUITE_END() // FusedPostOps |
| 1112 | |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1113 | TEST_SUITE(ExportToCLImage) |
| 1114 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip( |
| 1115 | framework::dataset::make("Input0Info", { TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 1116 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 1117 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // OK or incorrect if cl_khr_image2d_from_buffer not supported |
| 1118 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect k0 |
| 1119 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), // Incorrect n0 |
| 1120 | |
| 1121 | }), |
| 1122 | framework::dataset::make("Input1Info",{ TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), |
| 1123 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), |
| 1124 | TensorInfo(TensorShape(512U, 8U, 2U), 1, DataType::F16), |
| 1125 | TensorInfo(TensorShape(256U, 16U, 2U), 1, DataType::F16), |
| 1126 | TensorInfo(TensorShape(128U, 32U, 2U), 1, DataType::F16), |
| 1127 | |
| 1128 | })), |
| 1129 | framework::dataset::make("Input2Info", { TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 1130 | TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 1131 | TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 1132 | TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 1133 | TensorInfo(TensorShape(64U), 1, DataType::F16), |
| 1134 | |
| 1135 | })), |
| 1136 | framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 1137 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 1138 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 1139 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 1140 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 1141 | TensorInfo(TensorShape(64U, 64U, 2U), 1, DataType::F16), |
| 1142 | |
| 1143 | })), |
| 1144 | framework::dataset::make("LHSMInfo",{ |
| 1145 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 1146 | GEMMLHSMatrixInfo(4, 8, 1, false, true), |
| 1147 | GEMMLHSMatrixInfo(4, 4, 1, false, true), |
| 1148 | GEMMLHSMatrixInfo(4, 2, 1, false, false), |
| 1149 | GEMMLHSMatrixInfo(4, 4, 1, false, false), |
| 1150 | |
| 1151 | })), |
| 1152 | framework::dataset::make("RHSMInfo",{ |
| 1153 | GEMMRHSMatrixInfo(4, 4, 1, true, true, true), |
| 1154 | GEMMRHSMatrixInfo(4, 8, 1, true, true, true), |
| 1155 | GEMMRHSMatrixInfo(8, 4, 1, true, true, true), |
| 1156 | GEMMRHSMatrixInfo(4, 2, 1, true, false, true), |
| 1157 | GEMMRHSMatrixInfo(2, 4, 1, true, false, true), |
| 1158 | })), |
| 1159 | framework::dataset::make("GEMMInfo",{GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 1160 | 64 /**<N Number of RHS columns*/, |
| 1161 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 1162 | false /**< reinterpret the input as 3D */, |
| 1163 | true /**< Flag used to broadcast the bias addition */, |
| 1164 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 1165 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1166 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 1167 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 1168 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 1169 | GEMMLHSMatrixInfo(), |
| 1170 | GEMMRHSMatrixInfo(), |
| 1171 | 0 /**< Offset to be added to each element of the matrix A */, |
| 1172 | 0 /**< Offset to be added to each element of the matrix B */), |
| 1173 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 1174 | 64 /**<N Number of RHS columns*/, |
| 1175 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 1176 | false /**< reinterpret the input as 3D */, |
| 1177 | true /**< Flag used to broadcast the bias addition */, |
| 1178 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 1179 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1180 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 1181 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 1182 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 1183 | GEMMLHSMatrixInfo(), |
| 1184 | GEMMRHSMatrixInfo(), |
| 1185 | 0 /**< Offset to be added to each element of the matrix A */, |
| 1186 | 0 /**< Offset to be added to each element of the matrix B */), |
| 1187 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 1188 | 64 /**<N Number of RHS columns*/, |
| 1189 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 1190 | false /**< reinterpret the input as 3D */, |
| 1191 | true /**< Flag used to broadcast the bias addition */, |
| 1192 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 1193 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1194 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 1195 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 1196 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 1197 | GEMMLHSMatrixInfo(), |
| 1198 | GEMMRHSMatrixInfo(), |
| 1199 | 0 /**< Offset to be added to each element of the matrix A */, |
| 1200 | 0 /**< Offset to be added to each element of the matrix B */), |
| 1201 | |
| 1202 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 1203 | 64 /**<N Number of RHS columns*/, |
| 1204 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 1205 | false /**< reinterpret the input as 3D */, |
| 1206 | true /**< Flag used to broadcast the bias addition */, |
| 1207 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 1208 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1209 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 1210 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 1211 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 1212 | GEMMLHSMatrixInfo(), |
| 1213 | GEMMRHSMatrixInfo(), |
| 1214 | 0 /**< Offset to be added to each element of the matrix A */, |
| 1215 | 0 /**< Offset to be added to each element of the matrix B */), |
| 1216 | GEMMKernelInfo( 64 /**<M Number of LHS rows*/, |
| 1217 | 64 /**<N Number of RHS columns*/, |
| 1218 | 64 /**<K Number of LHS columns or RHS rows */, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 1219 | false /**< reinterpret the input as 3D */, |
| 1220 | true /**< Flag used to broadcast the bias addition */, |
| 1221 | false /**< wider accumm */, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 1222 | false /**< has pad y */, |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1223 | ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, |
| 1224 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 1225 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 1226 | GEMMLHSMatrixInfo(), |
| 1227 | GEMMRHSMatrixInfo(), |
| 1228 | 0 /**< Offset to be added to each element of the matrix A */, |
| 1229 | 0 /**< Offset to be added to each element of the matrix B */) |
| 1230 | })), |
| 1231 | framework::dataset::make("Expected", { true, |
| 1232 | true, |
| 1233 | true, |
| 1234 | false, |
| 1235 | false})), |
| 1236 | input0_info ,input1_info, input2_info, output_info, lhs_info, rhs_info, gemm_info, expected) |
| 1237 | { |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 1238 | 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] | 1239 | &input1_info.clone()->set_is_resizable(true), |
| 1240 | &input2_info.clone()->set_is_resizable(true), |
| 1241 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 1242 | lhs_info, |
| 1243 | rhs_info, |
| 1244 | gemm_info)) == (expected && image2d_from_buffer_supported(CLKernelLibrary::get().get_device())), framework::LogLevel::ERRORS); |
| 1245 | } |
| 1246 | |
| 1247 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::ALL, |
| 1248 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1249 | m_values, |
| 1250 | n_values), |
| 1251 | k_values), |
| 1252 | b_values), |
| 1253 | m0_values_precommit), |
| 1254 | n0_values_precommit), |
| 1255 | k0_values_precommit), |
| 1256 | v0_values_precommit), |
| 1257 | h0_values_precommit), |
| 1258 | i_values_lhs), |
| 1259 | i_values_rhs), |
| 1260 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 1261 | framework::dataset::make("DataType", DataType::F16)), |
| 1262 | a_values_precommit), |
| 1263 | beta_values_precommit), |
| 1264 | broadcast_bias_values), |
| 1265 | lhs_transpose_values), |
| 1266 | act_values)) |
| 1267 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 1268 | // Validate output only if validate() is successful |
| 1269 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1270 | { |
| 1271 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1272 | } |
| 1273 | else |
| 1274 | { |
| 1275 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 1276 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 1277 | } |
| 1278 | |
| 1279 | } |
| 1280 | |
| 1281 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedFixture<half>, framework::DatasetMode::NIGHTLY, |
| 1282 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1283 | m_values, |
| 1284 | n_values), |
| 1285 | k_values), |
| 1286 | b_values), |
| 1287 | m0_values_nightly), |
| 1288 | n0_export_to_cl_image_values_nightly), |
| 1289 | k0_export_to_cl_image_values_nightly), |
| 1290 | v0_values_nightly), |
| 1291 | h0_values_nightly), |
| 1292 | i_values_lhs), |
| 1293 | i_values_rhs), |
| 1294 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 1295 | framework::dataset::make("DataType", DataType::F16)), |
| 1296 | a_values_nightly), |
| 1297 | beta_values_nightly), |
| 1298 | broadcast_bias_values), |
| 1299 | lhs_transpose_values), |
| 1300 | act_values)) |
| 1301 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 1302 | // Validate output only if validate() is successful |
| 1303 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1304 | { |
| 1305 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1306 | } |
| 1307 | else |
| 1308 | { |
| 1309 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 1310 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 1311 | } |
| 1312 | } |
| 1313 | |
| 1314 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::ALL, |
| 1315 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1316 | m_w_values, |
| 1317 | m_h_values), |
| 1318 | n_values), |
| 1319 | k_values), |
| 1320 | b_values), |
| 1321 | m0_values_precommit), |
| 1322 | n0_values_precommit), |
| 1323 | k0_values_precommit), |
| 1324 | v0_values_precommit), |
| 1325 | h0_values_precommit), |
| 1326 | i_values_lhs), |
| 1327 | i_values_rhs), |
| 1328 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 1329 | framework::dataset::make("DataType", DataType::F16)), |
| 1330 | a_values_precommit), |
| 1331 | beta_values_precommit), |
| 1332 | lhs_transpose_values), |
| 1333 | act_values)) |
| 1334 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 1335 | // Validate output only if validate() is successful |
| 1336 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1337 | { |
| 1338 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1339 | } |
| 1340 | else |
| 1341 | { |
| 1342 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 1343 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 1344 | } |
| 1345 | } |
| 1346 | |
| 1347 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DFixture<half>, framework::DatasetMode::NIGHTLY, |
| 1348 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1349 | m_w_values, |
| 1350 | m_h_values), |
| 1351 | n_values), |
| 1352 | k_values), |
| 1353 | b_values), |
| 1354 | m0_values_nightly), |
| 1355 | n0_export_to_cl_image_values_nightly), |
| 1356 | k0_export_to_cl_image_values_nightly), |
| 1357 | v0_values_nightly), |
| 1358 | h0_values_nightly), |
| 1359 | i_values_lhs), |
| 1360 | i_values_rhs), |
| 1361 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 1362 | framework::dataset::make("DataType", DataType::F16)), |
| 1363 | a_values_nightly), |
| 1364 | beta_values_nightly), |
| 1365 | lhs_transpose_values), |
| 1366 | act_values)) |
| 1367 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 1368 | // Validate output only if validate() is successful |
| 1369 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1370 | { |
| 1371 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1372 | } |
| 1373 | else |
| 1374 | { |
| 1375 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 1376 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 1377 | } |
| 1378 | } |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 1379 | TEST_SUITE(FusedPostOps) |
| 1380 | |
| 1381 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedWithPostOpsFixture<half>, framework::DatasetMode::ALL, |
| 1382 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1383 | m_values, |
| 1384 | n_values), |
| 1385 | k_values), |
| 1386 | b_values), |
| 1387 | m0_values_precommit), |
| 1388 | n0_values_precommit), |
| 1389 | k0_values_precommit), |
| 1390 | v0_values_precommit), |
| 1391 | h0_values_precommit), |
| 1392 | framework::dataset::make("interleave_lhs", { false })), |
| 1393 | framework::dataset::make("interleave_rhs", { false })), |
| 1394 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 1395 | framework::dataset::make("DataType", DataType::F16)), |
| 1396 | a_values_precommit), |
| 1397 | beta_values_precommit), |
| 1398 | framework::dataset::make("broadcast_bias", { true } )), |
| 1399 | lhs_transpose_values), |
| 1400 | act_values), |
| 1401 | post_op_lists) |
| 1402 | ) |
| 1403 | { |
| 1404 | // Validate output only if validate() is successful |
| 1405 | if(validate_result) |
| 1406 | { |
| 1407 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 1408 | } |
| 1409 | else |
| 1410 | { |
| 1411 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 1412 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 1413 | } |
| 1414 | } |
| 1415 | |
| 1416 | TEST_SUITE_END() // FusedPostOps |
| 1417 | |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 1418 | TEST_SUITE_END() // ExportToCLImage |
Gian Marco Iodice | 05639f6 | 2019-09-24 12:05:06 +0100 | [diff] [blame] | 1419 | TEST_SUITE_END() // FP16 |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1420 | |
| 1421 | TEST_SUITE(MixedPrecision) |
| 1422 | |
| 1423 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1424 | 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] | 1425 | m_values, |
| 1426 | n_values), |
| 1427 | k_values), |
| 1428 | b_values), |
| 1429 | m0_values_precommit), |
| 1430 | n0_values_precommit), |
| 1431 | k0_values_precommit), |
| 1432 | v0_values_precommit), |
| 1433 | h0_values_precommit), |
| 1434 | i_values_lhs), |
| 1435 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1436 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1437 | framework::dataset::make("DataType", DataType::F16)), |
| 1438 | a_values_precommit), |
| 1439 | beta_values_precommit), |
| 1440 | broadcast_bias_values), |
| 1441 | lhs_transpose_values), |
| 1442 | act_values)) |
| 1443 | { |
| 1444 | // Validate output |
| 1445 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 1446 | } |
| 1447 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 1448 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMMatrixMultiplyReshapedMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1449 | 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] | 1450 | m_values, |
| 1451 | n_values), |
| 1452 | k_values), |
| 1453 | b_values), |
| 1454 | m0_values_nightly), |
| 1455 | n0_values_nightly), |
| 1456 | k0_values_nightly), |
| 1457 | v0_values_nightly), |
| 1458 | h0_values_nightly), |
| 1459 | i_values_lhs), |
| 1460 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1461 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1462 | framework::dataset::make("DataType", DataType::F16)), |
| 1463 | a_values_nightly), |
| 1464 | beta_values_nightly), |
| 1465 | broadcast_bias_values), |
| 1466 | lhs_transpose_values), |
| 1467 | act_values)) |
| 1468 | { |
| 1469 | // Validate output |
| 1470 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 1471 | } |
| 1472 | |
| 1473 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::ALL, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1474 | 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] | 1475 | m_w_values, |
| 1476 | m_h_values), |
| 1477 | n_values), |
| 1478 | k_values), |
| 1479 | b_values), |
| 1480 | m0_values_precommit), |
| 1481 | n0_values_precommit), |
| 1482 | k0_values_precommit), |
| 1483 | v0_values_precommit), |
| 1484 | h0_values_precommit), |
| 1485 | i_values_lhs), |
| 1486 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1487 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1488 | framework::dataset::make("DataType", DataType::F16)), |
| 1489 | a_values_precommit), |
| 1490 | beta_values_precommit), |
| 1491 | lhs_transpose_values), |
| 1492 | act_values)) |
| 1493 | { |
| 1494 | // Validate output |
| 1495 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 1496 | } |
| 1497 | |
Michalis Spyrou | 1d89777 | 2019-12-09 18:47:29 +0000 | [diff] [blame] | 1498 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMMatrixMultiplyReshaped3DMixedPrecisionFixture<half>, framework::DatasetMode::DISABLED, |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1499 | 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] | 1500 | m_w_values, |
| 1501 | m_h_values), |
| 1502 | n_values), |
| 1503 | k_values), |
| 1504 | b_values), |
| 1505 | m0_values_nightly), |
| 1506 | n0_values_nightly), |
| 1507 | k0_values_nightly), |
| 1508 | v0_values_nightly), |
| 1509 | h0_values_nightly), |
| 1510 | i_values_lhs), |
| 1511 | i_values_rhs), |
Gian Marco Iodice | e3a849a | 2020-06-10 17:59:30 +0100 | [diff] [blame] | 1512 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1513 | framework::dataset::make("DataType", DataType::F16)), |
| 1514 | a_values_nightly), |
| 1515 | beta_values_nightly), |
| 1516 | lhs_transpose_values), |
| 1517 | act_values)) |
| 1518 | { |
| 1519 | // Validate output |
| 1520 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 1521 | } |
SiCongLi | 1af5416 | 2021-10-06 15:25:57 +0100 | [diff] [blame] | 1522 | |
| 1523 | TEST_SUITE(FusedPostOps) |
| 1524 | |
| 1525 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMMatrixMultiplyReshapedMixedPrecisionWithPostOpsFixture<half>, framework::DatasetMode::ALL, |
| 1526 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 1527 | m_values, |
| 1528 | n_values), |
| 1529 | k_values), |
| 1530 | b_values), |
| 1531 | m0_values_precommit), |
| 1532 | n0_values_precommit), |
| 1533 | k0_values_precommit), |
| 1534 | v0_values_precommit), |
| 1535 | h0_values_precommit), |
| 1536 | framework::dataset::make("interleave_lhs", { false })), |
| 1537 | framework::dataset::make("interleave_rhs", { false })), |
| 1538 | framework::dataset::make("export_to_cl_image_rhs", { true, false })), |
| 1539 | framework::dataset::make("DataType", DataType::F16)), |
| 1540 | a_values_precommit), |
| 1541 | beta_values_precommit), |
| 1542 | framework::dataset::make("broadcast_bias", { true } )), |
| 1543 | lhs_transpose_values), |
| 1544 | act_values), |
| 1545 | post_op_lists) |
| 1546 | ) |
| 1547 | { |
| 1548 | // Validate output |
| 1549 | validate(CLAccessor(_target), _reference, rel_tolerance_f16_mixed_precision, 0.f, abs_tolerance_f16_mixed_precision); |
| 1550 | } |
| 1551 | |
| 1552 | TEST_SUITE_END() // FusedPostOps |
| 1553 | |
Gian Marco Iodice | 0c17aa2 | 2019-09-27 09:23:15 +0100 | [diff] [blame] | 1554 | TEST_SUITE_END() // MixedPrecision |
Gian Marco Iodice | 9382ab3 | 2018-12-17 15:12:07 +0000 | [diff] [blame] | 1555 | TEST_SUITE_END() // Float |
Gian Marco Iodice | d1f5476 | 2019-07-19 09:54:47 +0100 | [diff] [blame] | 1556 | TEST_SUITE_END() // GEMMMatrixMultiplyReshaped |
Gian Marco Iodice | bf9731e | 2018-12-12 10:18:04 +0000 | [diff] [blame] | 1557 | TEST_SUITE_END() // CL |
| 1558 | } // namespace validation |
| 1559 | } // namespace test |
Michele Di Giorgio | 2568c6b | 2019-09-17 12:08:46 +0100 | [diff] [blame] | 1560 | } // namespace arm_compute |