Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 1 | /* |
Giorgio Arena | 2ab585b | 2021-02-25 15:41:49 +0000 | [diff] [blame] | 2 | * Copyright (c) 2019-2021 Arm Limited. |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +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 | adc5395 | 2019-02-15 11:10:31 +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 | afa1972 | 2021-10-24 19:12:33 +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/ClGemmMatrixMultiplyReshapedOnlyRhsKernel.h" |
| 31 | #include "src/gpu/cl/kernels/ClGemmReshapeRhsMatrixKernel.h" |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 32 | #include "tests/CL/CLAccessor.h" |
| 33 | #include "tests/CL/Helper.h" |
| 34 | #include "tests/PaddingCalculator.h" |
| 35 | #include "tests/datasets/ShapeDatasets.h" |
| 36 | #include "tests/framework/Asserts.h" |
| 37 | #include "tests/framework/Macros.h" |
| 38 | #include "tests/framework/datasets/Datasets.h" |
| 39 | #include "tests/validation/Validation.h" |
| 40 | #include "tests/validation/fixtures/GEMMFixture.h" |
| 41 | |
| 42 | namespace arm_compute |
| 43 | { |
| 44 | namespace test |
| 45 | { |
| 46 | namespace validation |
| 47 | { |
| 48 | using namespace arm_compute::misc::shape_calculator; |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 49 | using namespace arm_compute::opencl::kernels; |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 50 | |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 51 | // Create function for ClGemmReshapeRhsMatrixKernel |
| 52 | using CLGEMMReshapeRHSMatrix = CLSynthetizeOperator<ClGemmReshapeRhsMatrixKernel>; |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 53 | |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame] | 54 | // Create function for ClGemmMatrixMultiplyReshapedOnlyRhsKernel |
| 55 | using CLGEMMMatrixMultiplyReshapedOnlyRHS = CLSynthetizeOperator<ClGemmMatrixMultiplyReshapedOnlyRhsKernel>; |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 56 | |
| 57 | // Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS |
| 58 | template <typename T> |
| 59 | using CLGEMMMatrixMultiplyReshapedOnlyRHSFixture = GEMMMatrixMultiplyReshapedOnlyRHSValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshapedOnlyRHS>; |
| 60 | |
| 61 | // Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS3D |
| 62 | template <typename T> |
| 63 | using CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture = GEMMMatrixMultiplyReshapedOnlyRHS3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshapedOnlyRHS>; |
| 64 | |
SiCongLi | afa1972 | 2021-10-24 19:12:33 +0100 | [diff] [blame] | 65 | // Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS with post ops |
| 66 | template <typename T> |
| 67 | using CLGEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsFixture = |
| 68 | GEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshapedOnlyRHS>; |
| 69 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 70 | namespace |
| 71 | { |
| 72 | // *INDENT-OFF* |
| 73 | // clang-format off |
| 74 | RelativeTolerance<float> rel_tolerance_f32(0.001f); |
| 75 | constexpr float abs_tolerance_f32(0.0001f); |
| 76 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 77 | RelativeTolerance<float> rel_tolerance_f16(0.001f); |
| 78 | constexpr float abs_tolerance_f16(0.01f); |
| 79 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 80 | /** Alpha values to test */ |
| 81 | const auto a_values = framework::dataset::make("alpha", {-0.75f} ); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 82 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 83 | /** Beta values to test */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 84 | const auto beta_values = framework::dataset::make("beta", {-0.35f} ); |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 85 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 86 | /** M values to test */ |
| 87 | const auto m_values = framework::dataset::make("M", 37); |
| 88 | |
| 89 | /** M_W values to test */ |
| 90 | const auto m_w_values = framework::dataset::make("M_W", 5); |
| 91 | |
| 92 | /** M_H values to test */ |
| 93 | const auto m_h_values = framework::dataset::make("M_H", 7); |
| 94 | |
| 95 | /** N values to test */ |
| 96 | const auto n_values = framework::dataset::make("N", 51); |
| 97 | |
| 98 | /** K values to test */ |
| 99 | const auto k_values = framework::dataset::make("K", 23); |
| 100 | |
| 101 | /** Batch size values to test */ |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 102 | const auto b_values = framework::dataset::make("batch_size", 2); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 103 | |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 104 | /** Activation values to test */ |
| 105 | const auto act_values = framework::dataset::make("Activation", |
| 106 | { |
Giorgio Arena | 2ab585b | 2021-02-25 15:41:49 +0000 | [diff] [blame] | 107 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 10.f), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 108 | }); |
| 109 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 110 | /** M0 values to test - precommit */ |
| 111 | const auto m0_values_precommit = framework::dataset::make("M0", { 4 }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 112 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 113 | /** N0 values to test - precommit*/ |
| 114 | const auto n0_values_precommit = framework::dataset::make("N0", { 4 }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 115 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 116 | /** K0 values to test - precommit*/ |
| 117 | const auto k0_values_precommit = framework::dataset::make("K0", { 4 }); |
| 118 | |
| 119 | /** M0 values to test - nightly */ |
| 120 | const auto m0_values_nightly = framework::dataset::make("M0", { 8 }); |
| 121 | |
| 122 | /** N0 values to test - nightly */ |
| 123 | const auto n0_values_nightly = framework::dataset::make("N0", { 16 }); |
| 124 | |
| 125 | /** K0 values to test - nightly */ |
| 126 | const auto k0_values_nightly = framework::dataset::make("K0", { 16 }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 127 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 128 | /** H0 values to test */ |
| 129 | const auto h0_values = framework::dataset::make("H0", 1, 3); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 130 | |
| 131 | /** Interleave values to test with RHS matrix */ |
| 132 | const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false }); |
| 133 | |
| 134 | /** Transpose values to test with RHS matrix */ |
Gian Marco Iodice | ba5e096 | 2019-03-11 12:17:44 +0000 | [diff] [blame] | 135 | const auto t_values_rhs = framework::dataset::make("transpose_rhs", { true, false }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 136 | |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 137 | /** Broadcast bias from vector to matrix */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 138 | const auto broadcast_bias_values = framework::dataset::make("broadcast_bias", { false, true } ); |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 139 | |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 140 | /** Boundary handling cases for testing partial/non-partial (full) block dimensions, resulting from different combinations |
| 141 | * of M, M0, N and N0 values. |
| 142 | * M0 and N0 are kept constant, while the different test cases need to vary M and N. |
| 143 | * |
| 144 | * Eg. M = 64 and N = 33 result in a block dimension that has no partial blocks (all full blocks) in Y dimension and |
| 145 | * parital blocks in X dimension. |
| 146 | */ |
| 147 | const auto boundary_handling_cases = combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 148 | // Large k to force potential out-of-bound reads on input0 |
| 149 | framework::dataset::make("K", 315), |
| 150 | // Batch size == 1 to force potential out-of-bound reads on input0 |
| 151 | framework::dataset::make("batch_size", 1)), |
| 152 | framework::dataset::make("M0", 4)), |
| 153 | framework::dataset::make("N0", 4)), |
| 154 | framework::dataset::make("K0", 4)), |
| 155 | framework::dataset::make("H0", 3)), |
| 156 | i_values_rhs), |
| 157 | t_values_rhs), |
| 158 | framework::dataset::make("export_to_cl_image_rhs", {true, false})), |
| 159 | // Only need to test F32 as F16 shares identical boundary handling logics |
| 160 | framework::dataset::make("DataType", DataType::F32)), |
| 161 | framework::dataset::make("alpha", -0.75f )), |
| 162 | framework::dataset::make("beta", -0.35f )), |
| 163 | broadcast_bias_values), |
| 164 | framework::dataset::make("Activation", ActivationLayerInfo())); |
| 165 | |
SiCongLi | afa1972 | 2021-10-24 19:12:33 +0100 | [diff] [blame] | 166 | /** Post Ops */ |
| 167 | using PostOpArgBroadcast = CLGEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsFixture<float>::PostOpArgBroadcast; |
| 168 | experimental::PostOpList<PostOpArgBroadcast> post_ops_1() |
| 169 | { |
| 170 | experimental::PostOpList<PostOpArgBroadcast> post_ops{}; |
| 171 | post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::LINEAR, 0.5F, 0.0F}); |
| 172 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<PostOpArgBroadcast>>( |
| 173 | std::make_tuple(true, true, false), // If broadcast in dims 0, 1 and 2 |
| 174 | 0, |
| 175 | ConvertPolicy::SATURATE); |
| 176 | post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); |
| 177 | return post_ops; |
| 178 | } |
| 179 | experimental::PostOpList<PostOpArgBroadcast> post_ops_2() |
| 180 | { |
| 181 | experimental::PostOpList<PostOpArgBroadcast> post_ops{}; |
| 182 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<PostOpArgBroadcast>>( |
| 183 | std::make_tuple(false, true, true), // If broadcast in dims 0, 1 and 2 |
| 184 | 1, |
| 185 | ConvertPolicy::SATURATE); |
| 186 | post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); |
| 187 | return post_ops; |
| 188 | } |
| 189 | experimental::PostOpList<PostOpArgBroadcast> post_ops_3() |
| 190 | { |
| 191 | experimental::PostOpList<PostOpArgBroadcast> post_ops{}; |
| 192 | post_ops.push_back_op<experimental::PostOpAct<PostOpArgBroadcast>>(ActivationLayerInfo{ActivationLayerInfo::ActivationFunction::RELU, 2.1F, 1.3F}); |
| 193 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<PostOpArgBroadcast>>( |
| 194 | std::make_tuple(false, false, true), // If broadcast in dims 0, 1 and 2 |
| 195 | 1, |
| 196 | ConvertPolicy::SATURATE); |
| 197 | return post_ops; |
| 198 | } |
| 199 | |
| 200 | /** Different Post Op Lists */ |
| 201 | const auto post_op_lists = framework::dataset::make("post_op_lists", { |
| 202 | post_ops_1(), |
| 203 | post_ops_2(), |
| 204 | post_ops_3(), |
| 205 | } ); |
| 206 | |
| 207 | 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) |
| 208 | { |
| 209 | const auto lhs_info = GEMMLHSMatrixInfo(4,4,1,false,true); |
| 210 | const auto rhs_info = GEMMRHSMatrixInfo(4,4,1,true,true,false); |
| 211 | |
| 212 | // Create TensorInfo for post op arguments |
| 213 | TensorInfo input0_info(TensorShape(k, m, batch), 1, data_type); |
| 214 | TensorInfo input1_info(TensorShape(n, k, batch), 1, data_type); |
| 215 | TensorInfo input2_info(TensorShape(n), 1, data_type); |
| 216 | TensorInfo output_info(TensorShape(n, m, batch), 1, data_type); |
| 217 | |
| 218 | const TensorInfo reshaped_input1_info = input1_info.clone()->set_tensor_shape(misc::shape_calculator::compute_rhs_reshaped_shape(input1_info, rhs_info)); |
| 219 | |
| 220 | GEMMKernelInfo gemm_info(m, n, k, 0 /**< Depth of the output tensor in case is reinterpreted as 3D */, |
| 221 | false /**< reinterpret the input as 3D */, |
| 222 | true /**< Flag used to broadcast the bias addition */, |
| 223 | false /**< wider accumm */, |
| 224 | false /**< has pad y */, |
| 225 | ActivationLayerInfo::ActivationFunction::IDENTITY, |
| 226 | 1 /**< Multiplication factor for the width of the 1xW transposed block */, |
| 227 | 1 /**< Multiplication factor for the height of the 4x4 interleaved block */, |
| 228 | lhs_info, |
| 229 | rhs_info, |
| 230 | 0 /**< Offset to be added to each element of the matrix A */, |
| 231 | 0 /**< Offset to be added to each element of the matrix B */, |
| 232 | post_ops); |
| 233 | return bool(ClGemmMatrixMultiplyReshapedOnlyRhsKernel::validate(&input0_info.clone()->set_is_resizable(true), |
| 234 | &reshaped_input1_info.clone()->set_is_resizable(true), |
| 235 | &input2_info.clone()->set_is_resizable(true), |
| 236 | &output_info.clone()->set_is_resizable(true),1.f,1.f, |
| 237 | lhs_info, |
| 238 | rhs_info, |
| 239 | gemm_info)); |
| 240 | } |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 241 | /** Configuration test */ |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 242 | bool validate_configuration(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value, |
| 243 | unsigned int m0_value, unsigned int n0_value, unsigned int k0_value, unsigned int h0_value, |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 244 | bool i_value_rhs, bool t_value_rhs, bool export_to_cl_image, bool broadcast_bias, bool input_as_3d, unsigned int depth_output_gemm3d, const ActivationLayerInfo &act_info, |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 245 | DataType dt_input0, DataType dt_input1, DataType dt_input2, DataType dt_output, float alpha, float beta) |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 246 | { |
| 247 | const unsigned int M = m_value; |
| 248 | const unsigned int N = n_value; |
| 249 | const unsigned int K = k_value; |
| 250 | |
| 251 | GEMMLHSMatrixInfo lhs_info; |
| 252 | lhs_info.m0 = m0_value; |
| 253 | lhs_info.k0 = k0_value; |
| 254 | |
| 255 | GEMMRHSMatrixInfo rhs_info; |
| 256 | rhs_info.n0 = n0_value; |
| 257 | rhs_info.k0 = k0_value; |
| 258 | rhs_info.h0 = h0_value; |
| 259 | rhs_info.interleave = i_value_rhs; |
Gian Marco Iodice | ba5e096 | 2019-03-11 12:17:44 +0000 | [diff] [blame] | 260 | rhs_info.transpose = t_value_rhs; |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 261 | rhs_info.export_to_cl_image = export_to_cl_image; |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 262 | |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 263 | GEMMKernelInfo kernel_info; |
| 264 | kernel_info.m = M; |
| 265 | kernel_info.n = N; |
| 266 | kernel_info.k = K; |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 267 | kernel_info.depth_output_gemm3d = depth_output_gemm3d; |
| 268 | kernel_info.reinterpret_input_as_3d = input_as_3d; |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 269 | kernel_info.broadcast_bias = broadcast_bias; |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 270 | kernel_info.activation_info = act_info; |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 271 | |
| 272 | const TensorShape lhs_shape(K, M, b_value); |
| 273 | const TensorShape rhs_shape(N, K, b_value); |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 274 | const TensorShape rhs_shape_reshaped = compute_rhs_reshaped_shape(TensorInfo(rhs_shape, 1, dt_input1), |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 275 | rhs_info); |
| 276 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 277 | const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0), |
| 278 | TensorInfo(rhs_shape_reshaped, 1, dt_input1), |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 279 | kernel_info); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 280 | |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 281 | const TensorShape bias_shape(N, |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 282 | M, // Correct calculation should be: broadcast_bias? 1 : M, it's wrong here on purpose just for validation test |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 283 | broadcast_bias? 1 : b_value); |
| 284 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 285 | // Create tensor info |
| 286 | TensorInfo lhs = TensorInfo(lhs_shape, 1, dt_input0); |
| 287 | TensorInfo rhs_reshaped = TensorInfo(rhs_shape_reshaped, 1, dt_input1); |
| 288 | TensorInfo bias = TensorInfo(bias_shape, 1, dt_input2); |
| 289 | TensorInfo dst = TensorInfo(dst_shape, 1, dt_output); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 290 | |
| 291 | // Create and configure function |
| 292 | CLGEMMMatrixMultiplyReshapedOnlyRHS gemm; |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 293 | return bool(gemm.validate(&lhs, &rhs_reshaped, &bias, &dst, alpha, beta, lhs_info, rhs_info, kernel_info)); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 294 | } |
SiCongLi | afa1972 | 2021-10-24 19:12:33 +0100 | [diff] [blame] | 295 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 296 | } // namespace |
| 297 | |
| 298 | TEST_SUITE(CL) |
| 299 | TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS) |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 300 | |
| 301 | /** Validate tests |
| 302 | * |
| 303 | * A series of validation tests on configurations which according to the API specification |
| 304 | * the function should fail against. |
| 305 | * |
| 306 | * Checks performed in order: |
| 307 | * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16. |
| 308 | * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8 |
| 309 | * - Unsupported N0: NO can only be 2,3,4,8,16 |
| 310 | * - Unsupported K0: KO can only be 2,3,4,8,16 |
| 311 | * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D |
| 312 | * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m) |
| 313 | * - Incorrect input0 dimension when input is reinterpreted as 3D: input0->dimension(1) * input0->dimension(2) != m |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 314 | * - Correct support for creating an OpenCL image object from buffer |
| 315 | * - Incorrect support for creating an OpenCL image object from buffer. N0 is 2 but it can only be 4,8 and 16 |
SiCong Li | 5bdde85 | 2020-08-26 13:55:15 +0100 | [diff] [blame] | 316 | * - Correct F16 support for creating an OpenCL image object from buffer. |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 317 | */ |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 318 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip( |
| 319 | framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }), |
| 320 | framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })), |
| 321 | framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })), |
| 322 | framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })), |
| 323 | framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })), |
| 324 | framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })), |
| 325 | framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })), |
| 326 | framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })), |
| 327 | framework::dataset::make("data_type_input0", { DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F16})), |
| 328 | framework::dataset::make("data_type_input1", { DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F16})), |
| 329 | framework::dataset::make("data_type_input2", { DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F16})), |
| 330 | framework::dataset::make("data_type_output", { DataType::F16, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F32, DataType::F16})), |
| 331 | framework::dataset::make("Beta", { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f , 1.0f})), |
SiCong Li | 5bdde85 | 2020-08-26 13:55:15 +0100 | [diff] [blame] | 332 | framework::dataset::make("Expected", { false, false, false, false, false, false, false, true, false, true })), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 333 | b_value, m0_value, n0_value, k0_value, broadcast_bias, input_as_3d, depth_output_gemm3d, export_to_cl_image, dt_input0, dt_intpu1, dt_input2, dt_output, beta, expected) |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 334 | { |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 335 | bool expected_value = expected; |
| 336 | |
| 337 | // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension |
| 338 | if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image) |
| 339 | { |
| 340 | expected_value = false; |
| 341 | } |
| 342 | |
| 343 | bool status = validate_configuration(37, 51, 23, b_value, m0_value, n0_value, k0_value, 1, false, false, export_to_cl_image, broadcast_bias, input_as_3d, depth_output_gemm3d, ActivationLayerInfo(), dt_input0, dt_intpu1, dt_input2, dt_output, 1.0f, beta); |
| 344 | ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS); |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 345 | } |
| 346 | |
SiCongLi | afa1972 | 2021-10-24 19:12:33 +0100 | [diff] [blame] | 347 | TEST_SUITE(ValidateFusedPostOpsConfigs) |
| 348 | TEST_SUITE(Invalid) |
| 349 | TEST_CASE(UnsupportedPostOpSequence, framework::DatasetMode::ALL) |
| 350 | { |
| 351 | const auto data_type = DataType::F32; |
| 352 | const unsigned int m = 17; |
| 353 | const unsigned int n = 1; |
| 354 | const unsigned int k = 13; |
| 355 | const unsigned int batch = 2; |
| 356 | TensorShape post_op_arg0_shape(n, m, batch); |
| 357 | TensorInfo post_op_arg_info(post_op_arg0_shape, 1, data_type); |
| 358 | auto post_op_arg1_info = post_op_arg_info.clone(); |
| 359 | |
| 360 | // Unsupported sequence of post ops |
| 361 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 362 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( |
| 363 | &post_op_arg_info, |
| 364 | 1, |
| 365 | ConvertPolicy::SATURATE); |
| 366 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( |
| 367 | post_op_arg1_info.get(), |
| 368 | 0, |
| 369 | ConvertPolicy::SATURATE); |
| 370 | |
| 371 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); |
| 372 | } |
| 373 | TEST_CASE(OutputWidened, framework::DatasetMode::ALL) |
| 374 | { |
| 375 | // Invalid broadcast: post op tensors "widen" the output tensor |
| 376 | const auto data_type = DataType::F32; |
| 377 | const unsigned int m = 17; |
| 378 | const unsigned int n = 1; |
| 379 | const unsigned int k = 1; |
| 380 | const unsigned int batch = 1; |
| 381 | TensorShape post_op_arg_shape(n, m, batch + 4); // output's batch dimension is "widened", which is not allowed |
| 382 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 383 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 384 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 385 | |
| 386 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); |
| 387 | } |
| 388 | TEST_CASE(BroadcastInXDimOnly, framework::DatasetMode::ALL) |
| 389 | { |
| 390 | // Invalid broadcast: post op tensors broadcast in the first dimension (X) only |
| 391 | const auto data_type = DataType::F32; |
| 392 | const unsigned int m = 22; |
| 393 | const unsigned int n = 16; |
| 394 | const unsigned int k = 15; |
| 395 | const unsigned int batch = 3; |
| 396 | TensorShape post_op_arg_shape(1, m, batch); |
| 397 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 398 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 399 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 400 | |
| 401 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == false, framework::LogLevel::ERRORS); |
| 402 | } |
| 403 | TEST_SUITE_END() // Invalid |
| 404 | TEST_SUITE(Valid) |
| 405 | TEST_CASE(EmptyPostOpList, framework::DatasetMode::ALL) |
| 406 | { |
| 407 | const auto data_type = DataType::F32; |
| 408 | const unsigned int m = 22; |
| 409 | const unsigned int n = 16; |
| 410 | const unsigned int k = 15; |
| 411 | const unsigned int batch = 3; |
| 412 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 413 | |
| 414 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); |
| 415 | } |
| 416 | TEST_CASE(BroadcastInYDimOnly, framework::DatasetMode::ALL) |
| 417 | { |
| 418 | const auto data_type = DataType::F32; |
| 419 | const unsigned int m = 22; |
| 420 | const unsigned int n = 16; |
| 421 | const unsigned int k = 15; |
| 422 | const unsigned int batch = 3; |
| 423 | TensorShape post_op_arg_shape(n, 1, batch); |
| 424 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 425 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 426 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 427 | |
| 428 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); |
| 429 | } |
| 430 | TEST_CASE(BroadcastInBothXandYDims, framework::DatasetMode::ALL) |
| 431 | { |
| 432 | const auto data_type = DataType::F32; |
| 433 | const unsigned int m = 22; |
| 434 | const unsigned int n = 16; |
| 435 | const unsigned int k = 15; |
| 436 | const unsigned int batch = 3; |
| 437 | TensorShape post_op_arg_shape(1, 1, batch); |
| 438 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 439 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 440 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 441 | |
| 442 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); |
| 443 | } |
| 444 | TEST_CASE(BroadcastInAllDims, framework::DatasetMode::ALL) |
| 445 | { |
| 446 | const auto data_type = DataType::F32; |
| 447 | const unsigned int m = 22; |
| 448 | const unsigned int n = 16; |
| 449 | const unsigned int k = 15; |
| 450 | const unsigned int batch = 3; |
| 451 | TensorShape post_op_arg_shape(1, 1, 1); |
| 452 | TensorInfo post_op_arg_info(post_op_arg_shape, 1, data_type); |
| 453 | experimental::PostOpList<ITensorInfo*> post_ops{}; |
| 454 | post_ops.push_back_op<experimental::PostOpEltwiseAdd<ITensorInfo*>>( &post_op_arg_info, 0, ConvertPolicy::SATURATE); |
| 455 | |
| 456 | ARM_COMPUTE_EXPECT(is_post_op_list_valid(m, n, k, batch, data_type, post_ops) == true, framework::LogLevel::ERRORS); |
| 457 | } |
| 458 | TEST_SUITE_END() // Valid |
| 459 | TEST_SUITE_END() // ValidateFusedPostOps |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 460 | TEST_SUITE(Float) |
| 461 | TEST_SUITE(FP32) |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 462 | |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 463 | FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 464 | combine(combine( |
| 465 | framework::dataset::make("M", 3), |
| 466 | framework::dataset::make("N", 1)), |
| 467 | boundary_handling_cases)) |
| 468 | { |
| 469 | // Validate output |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 470 | if(validate_result) |
| 471 | { |
| 472 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 473 | } |
| 474 | else |
| 475 | { |
| 476 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 477 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 478 | } |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 482 | combine(combine( |
| 483 | framework::dataset::make("M", 64), |
| 484 | framework::dataset::make("N", 43)), |
| 485 | boundary_handling_cases)) |
| 486 | { |
| 487 | // Validate output |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 488 | if(validate_result) |
| 489 | { |
| 490 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 491 | } |
| 492 | else |
| 493 | { |
| 494 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 495 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 496 | } |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 500 | combine(combine( |
| 501 | framework::dataset::make("M", 64), |
| 502 | framework::dataset::make("N", 32)), |
| 503 | boundary_handling_cases)) |
| 504 | { |
| 505 | // Validate output |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 506 | if(validate_result) |
| 507 | { |
| 508 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 509 | } |
| 510 | else |
| 511 | { |
| 512 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 513 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 514 | } |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 518 | combine(combine( |
| 519 | framework::dataset::make("M", 37), |
| 520 | framework::dataset::make("N", 32)), |
| 521 | boundary_handling_cases)) |
| 522 | { |
| 523 | // Validate output |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 524 | if(validate_result) |
| 525 | { |
| 526 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 527 | } |
| 528 | else |
| 529 | { |
| 530 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 531 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 532 | } |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 533 | } |
| 534 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 535 | FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 536 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 537 | m_values, |
| 538 | n_values), |
| 539 | k_values), |
| 540 | b_values), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 541 | m0_values_precommit), |
| 542 | n0_values_precommit), |
| 543 | k0_values_precommit), |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 544 | h0_values), |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 545 | i_values_rhs), |
| 546 | t_values_rhs), |
Manuel Bottini | 827817e | 2020-11-19 12:12:06 +0000 | [diff] [blame] | 547 | framework::dataset::make("export_to_cl_image_rhs", {false, true})), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 548 | framework::dataset::make("DataType", DataType::F32)), |
| 549 | a_values), |
| 550 | beta_values), |
| 551 | broadcast_bias_values), |
| 552 | act_values)) |
| 553 | { |
| 554 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 555 | if(validate_result) |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 556 | { |
| 557 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 558 | } |
| 559 | else |
| 560 | { |
| 561 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 562 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY, |
| 567 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 568 | m_values, |
| 569 | n_values), |
| 570 | k_values), |
| 571 | b_values), |
| 572 | m0_values_nightly), |
| 573 | n0_values_nightly), |
| 574 | k0_values_nightly), |
| 575 | h0_values), |
| 576 | i_values_rhs), |
| 577 | t_values_rhs), |
Manuel Bottini | 827817e | 2020-11-19 12:12:06 +0000 | [diff] [blame] | 578 | framework::dataset::make("export_to_cl_image_rhs", {false, true})), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 579 | framework::dataset::make("DataType", DataType::F32)), |
| 580 | a_values), |
| 581 | beta_values), |
| 582 | broadcast_bias_values), |
| 583 | act_values)) |
| 584 | { |
| 585 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 586 | if(validate_result) |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 587 | { |
| 588 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 589 | } |
| 590 | else |
| 591 | { |
| 592 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 593 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 598 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 599 | m_w_values, |
| 600 | m_h_values), |
| 601 | n_values), |
| 602 | k_values), |
| 603 | b_values), |
| 604 | m0_values_precommit), |
| 605 | n0_values_precommit), |
| 606 | k0_values_precommit), |
| 607 | h0_values), |
| 608 | i_values_rhs), |
| 609 | t_values_rhs), |
Manuel Bottini | 827817e | 2020-11-19 12:12:06 +0000 | [diff] [blame] | 610 | framework::dataset::make("export_to_cl_image_rhs", {false, true})), |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 611 | framework::dataset::make("has_pad_y", {false, true})), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 612 | framework::dataset::make("DataType", DataType::F32)), |
| 613 | a_values), |
| 614 | beta_values), |
| 615 | act_values)) |
| 616 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 617 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 618 | if(validate_result) |
| 619 | { |
| 620 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 621 | } |
| 622 | else |
| 623 | { |
| 624 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 625 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 626 | } |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 630 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 631 | m_w_values, |
| 632 | m_h_values), |
| 633 | n_values), |
| 634 | k_values), |
| 635 | b_values), |
| 636 | m0_values_nightly), |
| 637 | n0_values_nightly), |
| 638 | k0_values_nightly), |
| 639 | h0_values), |
| 640 | i_values_rhs), |
| 641 | t_values_rhs), |
Manuel Bottini | 827817e | 2020-11-19 12:12:06 +0000 | [diff] [blame] | 642 | framework::dataset::make("export_to_cl_image_rhs", {false, true})), |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 643 | framework::dataset::make("has_pad_y", {false, true})), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 644 | framework::dataset::make("DataType", DataType::F32)), |
| 645 | a_values), |
| 646 | beta_values), |
| 647 | act_values)) |
| 648 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 649 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 650 | if(validate_result) |
| 651 | { |
| 652 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 653 | } |
| 654 | else |
| 655 | { |
| 656 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 657 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 658 | } |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 659 | } |
SiCongLi | afa1972 | 2021-10-24 19:12:33 +0100 | [diff] [blame] | 660 | |
| 661 | TEST_SUITE(FusedPostOps) |
| 662 | |
| 663 | FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsFixture<float>, framework::DatasetMode::ALL, |
| 664 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 665 | m_values, |
| 666 | n_values), |
| 667 | k_values), |
| 668 | b_values), |
| 669 | m0_values_precommit), |
| 670 | n0_values_precommit), |
| 671 | k0_values_precommit), |
| 672 | framework::dataset::make("H0", {1})), |
| 673 | framework::dataset::make("interleave_rhs", { true })), |
| 674 | t_values_rhs), |
SiCongLi | bc78838 | 2021-11-02 14:52:02 +0000 | [diff] [blame^] | 675 | framework::dataset::make("export_to_cl_image_rhs", {false, true})), |
SiCongLi | afa1972 | 2021-10-24 19:12:33 +0100 | [diff] [blame] | 676 | framework::dataset::make("DataType", DataType::F32)), |
| 677 | a_values), |
| 678 | beta_values), |
| 679 | framework::dataset::make("broadcast_bias", { false } )), |
| 680 | act_values), |
| 681 | post_op_lists) |
| 682 | ) |
| 683 | { |
| 684 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 685 | if(validate_result) |
| 686 | { |
| 687 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 688 | } |
| 689 | else |
| 690 | { |
| 691 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 692 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | TEST_SUITE_END() // FusedPostOps |
| 697 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 698 | TEST_SUITE_END() // FP32 |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 699 | |
| 700 | TEST_SUITE(FP16) |
| 701 | FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT, |
| 702 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 703 | m_values, |
| 704 | n_values), |
| 705 | k_values), |
| 706 | b_values), |
| 707 | m0_values_precommit), |
| 708 | n0_values_precommit), |
| 709 | k0_values_precommit), |
| 710 | h0_values), |
| 711 | i_values_rhs), |
| 712 | t_values_rhs), |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 713 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 714 | framework::dataset::make("DataType", DataType::F16)), |
| 715 | a_values), |
| 716 | beta_values), |
| 717 | broadcast_bias_values), |
| 718 | act_values)) |
| 719 | { |
| 720 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 721 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 722 | { |
| 723 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 724 | } |
| 725 | else |
| 726 | { |
| 727 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 728 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY, |
| 733 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 734 | m_values, |
| 735 | n_values), |
| 736 | k_values), |
| 737 | b_values), |
| 738 | m0_values_nightly), |
| 739 | n0_values_nightly), |
| 740 | k0_values_nightly), |
| 741 | h0_values), |
| 742 | i_values_rhs), |
| 743 | t_values_rhs), |
| 744 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 745 | framework::dataset::make("DataType", DataType::F16)), |
| 746 | a_values), |
| 747 | beta_values), |
| 748 | broadcast_bias_values), |
| 749 | act_values)) |
| 750 | { |
| 751 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 752 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 753 | { |
| 754 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 755 | } |
| 756 | else |
| 757 | { |
| 758 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 759 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 764 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 765 | m_w_values, |
| 766 | m_h_values), |
| 767 | n_values), |
| 768 | k_values), |
| 769 | b_values), |
| 770 | m0_values_precommit), |
| 771 | n0_values_precommit), |
| 772 | k0_values_precommit), |
| 773 | h0_values), |
| 774 | i_values_rhs), |
| 775 | t_values_rhs), |
| 776 | framework::dataset::make("export_to_cl_image_rhs", true)), |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 777 | framework::dataset::make("has_pad_y", {false, true})), |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 778 | framework::dataset::make("DataType", DataType::F16)), |
| 779 | a_values), |
| 780 | beta_values), |
| 781 | act_values)) |
| 782 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 783 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 784 | if(validate_result) |
| 785 | { |
| 786 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 787 | } |
| 788 | else |
| 789 | { |
| 790 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 791 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 792 | } |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 796 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 797 | m_w_values, |
| 798 | m_h_values), |
| 799 | n_values), |
| 800 | k_values), |
| 801 | b_values), |
| 802 | m0_values_nightly), |
| 803 | n0_values_nightly), |
| 804 | k0_values_nightly), |
| 805 | h0_values), |
| 806 | i_values_rhs), |
| 807 | t_values_rhs), |
| 808 | framework::dataset::make("export_to_cl_image_rhs", true)), |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 809 | framework::dataset::make("has_pad_y", {false, true})), |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 810 | framework::dataset::make("DataType", DataType::F16)), |
| 811 | a_values), |
| 812 | beta_values), |
| 813 | act_values)) |
| 814 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 815 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 816 | if(validate_result) |
| 817 | { |
| 818 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 819 | } |
| 820 | else |
| 821 | { |
| 822 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 823 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 824 | } |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 825 | } |
SiCongLi | afa1972 | 2021-10-24 19:12:33 +0100 | [diff] [blame] | 826 | TEST_SUITE(FusedPostOps) |
| 827 | |
| 828 | FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSWithPostOpsFixture<half>, framework::DatasetMode::ALL, |
| 829 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 830 | m_values, |
| 831 | n_values), |
| 832 | k_values), |
| 833 | b_values), |
| 834 | m0_values_precommit), |
| 835 | n0_values_precommit), |
| 836 | k0_values_precommit), |
| 837 | framework::dataset::make("H0", {1})), |
| 838 | framework::dataset::make("interleave_rhs", { true })), |
| 839 | t_values_rhs), |
| 840 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 841 | framework::dataset::make("DataType", DataType::F16)), |
| 842 | a_values), |
| 843 | beta_values), |
| 844 | framework::dataset::make("broadcast_bias", { false } )), |
| 845 | act_values), |
| 846 | post_op_lists) |
| 847 | ) |
| 848 | { |
| 849 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 850 | if(validate_result) |
| 851 | { |
| 852 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 853 | } |
| 854 | else |
| 855 | { |
| 856 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 857 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | TEST_SUITE_END() // FusedPostOps |
| 862 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 863 | TEST_SUITE_END() // FP16 |
| 864 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 865 | TEST_SUITE_END() // Float |
| 866 | TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS |
| 867 | TEST_SUITE_END() // CL |
| 868 | } // namespace validation |
| 869 | } // namespace test |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 870 | } // namespace arm_compute |