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