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" |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 29 | #include "src/core/CL/kernels/CLGEMMMatrixMultiplyReshapedOnlyRHSKernel.h" |
| 30 | #include "src/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h" |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 31 | #include "tests/CL/CLAccessor.h" |
| 32 | #include "tests/CL/Helper.h" |
| 33 | #include "tests/PaddingCalculator.h" |
| 34 | #include "tests/datasets/ShapeDatasets.h" |
| 35 | #include "tests/framework/Asserts.h" |
| 36 | #include "tests/framework/Macros.h" |
| 37 | #include "tests/framework/datasets/Datasets.h" |
| 38 | #include "tests/validation/Validation.h" |
| 39 | #include "tests/validation/fixtures/GEMMFixture.h" |
| 40 | |
| 41 | namespace arm_compute |
| 42 | { |
| 43 | namespace test |
| 44 | { |
| 45 | namespace validation |
| 46 | { |
| 47 | using namespace arm_compute::misc::shape_calculator; |
| 48 | |
| 49 | // Create function for CLGEMMReshapeRHSMatrixKernel |
| 50 | using CLGEMMReshapeRHSMatrix = CLSynthetizeFunction<CLGEMMReshapeRHSMatrixKernel>; |
| 51 | |
| 52 | // Create function for CLGEMMMatrixMultiplyReshapedOnlyRHSKernel |
| 53 | using CLGEMMMatrixMultiplyReshapedOnlyRHS = CLSynthetizeFunction<CLGEMMMatrixMultiplyReshapedOnlyRHSKernel>; |
| 54 | |
| 55 | // Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS |
| 56 | template <typename T> |
| 57 | using CLGEMMMatrixMultiplyReshapedOnlyRHSFixture = GEMMMatrixMultiplyReshapedOnlyRHSValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshapedOnlyRHS>; |
| 58 | |
| 59 | // Fixture for CLGEMMMatrixMultiplyReshapedOnlyRHS3D |
| 60 | template <typename T> |
| 61 | using CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture = GEMMMatrixMultiplyReshapedOnlyRHS3DValidationFixture<CLTensor, CLAccessor, T, CLGEMMReshapeRHSMatrix, CLGEMMMatrixMultiplyReshapedOnlyRHS>; |
| 62 | |
| 63 | namespace |
| 64 | { |
| 65 | // *INDENT-OFF* |
| 66 | // clang-format off |
| 67 | RelativeTolerance<float> rel_tolerance_f32(0.001f); |
| 68 | constexpr float abs_tolerance_f32(0.0001f); |
| 69 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 70 | RelativeTolerance<float> rel_tolerance_f16(0.001f); |
| 71 | constexpr float abs_tolerance_f16(0.01f); |
| 72 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 73 | /** Alpha values to test */ |
| 74 | const auto a_values = framework::dataset::make("alpha", {-0.75f} ); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 75 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 76 | /** Beta values to test */ |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 77 | const auto beta_values = framework::dataset::make("beta", {-0.35f} ); |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 78 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 79 | /** M values to test */ |
| 80 | const auto m_values = framework::dataset::make("M", 37); |
| 81 | |
| 82 | /** M_W values to test */ |
| 83 | const auto m_w_values = framework::dataset::make("M_W", 5); |
| 84 | |
| 85 | /** M_H values to test */ |
| 86 | const auto m_h_values = framework::dataset::make("M_H", 7); |
| 87 | |
| 88 | /** N values to test */ |
| 89 | const auto n_values = framework::dataset::make("N", 51); |
| 90 | |
| 91 | /** K values to test */ |
| 92 | const auto k_values = framework::dataset::make("K", 23); |
| 93 | |
| 94 | /** Batch size values to test */ |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 95 | const auto b_values = framework::dataset::make("batch_size", 2); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 96 | |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 97 | /** Activation values to test */ |
| 98 | const auto act_values = framework::dataset::make("Activation", |
| 99 | { |
Giorgio Arena | 2ab585b | 2021-02-25 15:41:49 +0000 | [diff] [blame] | 100 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 10.f), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 101 | }); |
| 102 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 103 | /** M0 values to test - precommit */ |
| 104 | const auto m0_values_precommit = framework::dataset::make("M0", { 4 }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 105 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 106 | /** N0 values to test - precommit*/ |
| 107 | const auto n0_values_precommit = framework::dataset::make("N0", { 4 }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 108 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 109 | /** K0 values to test - precommit*/ |
| 110 | const auto k0_values_precommit = framework::dataset::make("K0", { 4 }); |
| 111 | |
| 112 | /** M0 values to test - nightly */ |
| 113 | const auto m0_values_nightly = framework::dataset::make("M0", { 8 }); |
| 114 | |
| 115 | /** N0 values to test - nightly */ |
| 116 | const auto n0_values_nightly = framework::dataset::make("N0", { 16 }); |
| 117 | |
| 118 | /** K0 values to test - nightly */ |
| 119 | const auto k0_values_nightly = framework::dataset::make("K0", { 16 }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 120 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 121 | /** H0 values to test */ |
| 122 | const auto h0_values = framework::dataset::make("H0", 1, 3); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 123 | |
| 124 | /** Interleave values to test with RHS matrix */ |
| 125 | const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false }); |
| 126 | |
| 127 | /** Transpose values to test with RHS matrix */ |
Gian Marco Iodice | ba5e096 | 2019-03-11 12:17:44 +0000 | [diff] [blame] | 128 | 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] | 129 | |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 130 | /** Broadcast bias from vector to matrix */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 131 | const auto broadcast_bias_values = framework::dataset::make("broadcast_bias", { false, true } ); |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 132 | |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 133 | /** Boundary handling cases for testing partial/non-partial (full) block dimensions, resulting from different combinations |
| 134 | * of M, M0, N and N0 values. |
| 135 | * M0 and N0 are kept constant, while the different test cases need to vary M and N. |
| 136 | * |
| 137 | * Eg. M = 64 and N = 33 result in a block dimension that has no partial blocks (all full blocks) in Y dimension and |
| 138 | * parital blocks in X dimension. |
| 139 | */ |
| 140 | const auto boundary_handling_cases = combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 141 | // Large k to force potential out-of-bound reads on input0 |
| 142 | framework::dataset::make("K", 315), |
| 143 | // Batch size == 1 to force potential out-of-bound reads on input0 |
| 144 | framework::dataset::make("batch_size", 1)), |
| 145 | framework::dataset::make("M0", 4)), |
| 146 | framework::dataset::make("N0", 4)), |
| 147 | framework::dataset::make("K0", 4)), |
| 148 | framework::dataset::make("H0", 3)), |
| 149 | i_values_rhs), |
| 150 | t_values_rhs), |
| 151 | framework::dataset::make("export_to_cl_image_rhs", {true, false})), |
| 152 | // Only need to test F32 as F16 shares identical boundary handling logics |
| 153 | framework::dataset::make("DataType", DataType::F32)), |
| 154 | framework::dataset::make("alpha", -0.75f )), |
| 155 | framework::dataset::make("beta", -0.35f )), |
| 156 | broadcast_bias_values), |
| 157 | framework::dataset::make("Activation", ActivationLayerInfo())); |
| 158 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 159 | /** Configuration test */ |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 160 | bool validate_configuration(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value, |
| 161 | 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] | 162 | 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] | 163 | 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] | 164 | { |
| 165 | const unsigned int M = m_value; |
| 166 | const unsigned int N = n_value; |
| 167 | const unsigned int K = k_value; |
| 168 | |
| 169 | GEMMLHSMatrixInfo lhs_info; |
| 170 | lhs_info.m0 = m0_value; |
| 171 | lhs_info.k0 = k0_value; |
| 172 | |
| 173 | GEMMRHSMatrixInfo rhs_info; |
| 174 | rhs_info.n0 = n0_value; |
| 175 | rhs_info.k0 = k0_value; |
| 176 | rhs_info.h0 = h0_value; |
| 177 | rhs_info.interleave = i_value_rhs; |
Gian Marco Iodice | ba5e096 | 2019-03-11 12:17:44 +0000 | [diff] [blame] | 178 | rhs_info.transpose = t_value_rhs; |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 179 | rhs_info.export_to_cl_image = export_to_cl_image; |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 180 | |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 181 | GEMMKernelInfo kernel_info; |
| 182 | kernel_info.m = M; |
| 183 | kernel_info.n = N; |
| 184 | kernel_info.k = K; |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 185 | kernel_info.depth_output_gemm3d = depth_output_gemm3d; |
| 186 | kernel_info.reinterpret_input_as_3d = input_as_3d; |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 187 | kernel_info.broadcast_bias = broadcast_bias; |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 188 | kernel_info.activation_info = act_info; |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 189 | |
| 190 | const TensorShape lhs_shape(K, M, b_value); |
| 191 | const TensorShape rhs_shape(N, K, b_value); |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 192 | 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] | 193 | rhs_info); |
| 194 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 195 | const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0), |
| 196 | TensorInfo(rhs_shape_reshaped, 1, dt_input1), |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 197 | kernel_info); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 198 | |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 199 | const TensorShape bias_shape(N, |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 200 | 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] | 201 | broadcast_bias? 1 : b_value); |
| 202 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 203 | // Create tensor info |
| 204 | TensorInfo lhs = TensorInfo(lhs_shape, 1, dt_input0); |
| 205 | TensorInfo rhs_reshaped = TensorInfo(rhs_shape_reshaped, 1, dt_input1); |
| 206 | TensorInfo bias = TensorInfo(bias_shape, 1, dt_input2); |
| 207 | TensorInfo dst = TensorInfo(dst_shape, 1, dt_output); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 208 | |
| 209 | // Create and configure function |
| 210 | CLGEMMMatrixMultiplyReshapedOnlyRHS gemm; |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 211 | 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] | 212 | } |
| 213 | } // namespace |
| 214 | |
| 215 | TEST_SUITE(CL) |
| 216 | TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS) |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 217 | |
| 218 | /** Validate tests |
| 219 | * |
| 220 | * A series of validation tests on configurations which according to the API specification |
| 221 | * the function should fail against. |
| 222 | * |
| 223 | * Checks performed in order: |
| 224 | * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16. |
| 225 | * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8 |
| 226 | * - Unsupported N0: NO can only be 2,3,4,8,16 |
| 227 | * - Unsupported K0: KO can only be 2,3,4,8,16 |
| 228 | * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D |
| 229 | * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m) |
| 230 | * - 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] | 231 | * - Correct support for creating an OpenCL image object from buffer |
| 232 | * - 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] | 233 | * - Correct F16 support for creating an OpenCL image object from buffer. |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 234 | */ |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 235 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip( |
| 236 | framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }), |
| 237 | framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })), |
| 238 | framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })), |
| 239 | framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })), |
| 240 | framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })), |
| 241 | framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })), |
| 242 | framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })), |
| 243 | framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })), |
| 244 | 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})), |
| 245 | 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})), |
| 246 | 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})), |
| 247 | 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})), |
| 248 | 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] | 249 | 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] | 250 | 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] | 251 | { |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 252 | bool expected_value = expected; |
| 253 | |
| 254 | // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension |
| 255 | if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image) |
| 256 | { |
| 257 | expected_value = false; |
| 258 | } |
| 259 | |
| 260 | 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); |
| 261 | ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS); |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 262 | } |
| 263 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 264 | TEST_SUITE(Float) |
| 265 | TEST_SUITE(FP32) |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 266 | |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 267 | FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 268 | combine(combine( |
| 269 | framework::dataset::make("M", 3), |
| 270 | framework::dataset::make("N", 1)), |
| 271 | boundary_handling_cases)) |
| 272 | { |
| 273 | // Validate output |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 274 | if(validate_result) |
| 275 | { |
| 276 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 277 | } |
| 278 | else |
| 279 | { |
| 280 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 281 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 282 | } |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingPartialInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 286 | combine(combine( |
| 287 | framework::dataset::make("M", 64), |
| 288 | framework::dataset::make("N", 43)), |
| 289 | boundary_handling_cases)) |
| 290 | { |
| 291 | // Validate output |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 292 | if(validate_result) |
| 293 | { |
| 294 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 295 | } |
| 296 | else |
| 297 | { |
| 298 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 299 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 300 | } |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXFullInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 304 | combine(combine( |
| 305 | framework::dataset::make("M", 64), |
| 306 | framework::dataset::make("N", 32)), |
| 307 | boundary_handling_cases)) |
| 308 | { |
| 309 | // Validate output |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 310 | if(validate_result) |
| 311 | { |
| 312 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 317 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 318 | } |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | FIXTURE_DATA_TEST_CASE(RunPrecommitBoundaryHandlingFullInXPartialInY, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 322 | combine(combine( |
| 323 | framework::dataset::make("M", 37), |
| 324 | framework::dataset::make("N", 32)), |
| 325 | boundary_handling_cases)) |
| 326 | { |
| 327 | // Validate output |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 328 | if(validate_result) |
| 329 | { |
| 330 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 331 | } |
| 332 | else |
| 333 | { |
| 334 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 335 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 336 | } |
SiCong Li | b972ae6 | 2020-08-03 15:39:45 +0100 | [diff] [blame] | 337 | } |
| 338 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 339 | FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 340 | 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] | 341 | m_values, |
| 342 | n_values), |
| 343 | k_values), |
| 344 | b_values), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 345 | m0_values_precommit), |
| 346 | n0_values_precommit), |
| 347 | k0_values_precommit), |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 348 | h0_values), |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 349 | i_values_rhs), |
| 350 | t_values_rhs), |
Manuel Bottini | 827817e | 2020-11-19 12:12:06 +0000 | [diff] [blame] | 351 | framework::dataset::make("export_to_cl_image_rhs", {false, true})), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 352 | framework::dataset::make("DataType", DataType::F32)), |
| 353 | a_values), |
| 354 | beta_values), |
| 355 | broadcast_bias_values), |
| 356 | act_values)) |
| 357 | { |
| 358 | // 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] | 359 | if(validate_result) |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 360 | { |
| 361 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 362 | } |
| 363 | else |
| 364 | { |
| 365 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 366 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY, |
| 371 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 372 | m_values, |
| 373 | n_values), |
| 374 | k_values), |
| 375 | b_values), |
| 376 | m0_values_nightly), |
| 377 | n0_values_nightly), |
| 378 | k0_values_nightly), |
| 379 | h0_values), |
| 380 | i_values_rhs), |
| 381 | t_values_rhs), |
Manuel Bottini | 827817e | 2020-11-19 12:12:06 +0000 | [diff] [blame] | 382 | framework::dataset::make("export_to_cl_image_rhs", {false, true})), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 383 | framework::dataset::make("DataType", DataType::F32)), |
| 384 | a_values), |
| 385 | beta_values), |
| 386 | broadcast_bias_values), |
| 387 | act_values)) |
| 388 | { |
| 389 | // 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] | 390 | if(validate_result) |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 391 | { |
| 392 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 393 | } |
| 394 | else |
| 395 | { |
| 396 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 397 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 402 | 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] | 403 | m_w_values, |
| 404 | m_h_values), |
| 405 | n_values), |
| 406 | k_values), |
| 407 | b_values), |
| 408 | m0_values_precommit), |
| 409 | n0_values_precommit), |
| 410 | k0_values_precommit), |
| 411 | h0_values), |
| 412 | i_values_rhs), |
| 413 | t_values_rhs), |
Manuel Bottini | 827817e | 2020-11-19 12:12:06 +0000 | [diff] [blame] | 414 | framework::dataset::make("export_to_cl_image_rhs", {false, true})), |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 415 | framework::dataset::make("has_pad_y", {false, true})), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 416 | framework::dataset::make("DataType", DataType::F32)), |
| 417 | a_values), |
| 418 | beta_values), |
| 419 | act_values)) |
| 420 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 421 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 422 | if(validate_result) |
| 423 | { |
| 424 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 425 | } |
| 426 | else |
| 427 | { |
| 428 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 429 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 430 | } |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 434 | 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] | 435 | m_w_values, |
| 436 | m_h_values), |
| 437 | n_values), |
| 438 | k_values), |
| 439 | b_values), |
| 440 | m0_values_nightly), |
| 441 | n0_values_nightly), |
| 442 | k0_values_nightly), |
| 443 | h0_values), |
| 444 | i_values_rhs), |
| 445 | t_values_rhs), |
Manuel Bottini | 827817e | 2020-11-19 12:12:06 +0000 | [diff] [blame] | 446 | framework::dataset::make("export_to_cl_image_rhs", {false, true})), |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 447 | framework::dataset::make("has_pad_y", {false, true})), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 448 | framework::dataset::make("DataType", DataType::F32)), |
| 449 | a_values), |
| 450 | beta_values), |
| 451 | act_values)) |
| 452 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 453 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 454 | if(validate_result) |
| 455 | { |
| 456 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 457 | } |
| 458 | else |
| 459 | { |
| 460 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 461 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 462 | } |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 463 | } |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 464 | TEST_SUITE_END() // FP32 |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 465 | |
| 466 | TEST_SUITE(FP16) |
| 467 | FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT, |
| 468 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 469 | m_values, |
| 470 | n_values), |
| 471 | k_values), |
| 472 | b_values), |
| 473 | m0_values_precommit), |
| 474 | n0_values_precommit), |
| 475 | k0_values_precommit), |
| 476 | h0_values), |
| 477 | i_values_rhs), |
| 478 | t_values_rhs), |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 479 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 480 | framework::dataset::make("DataType", DataType::F16)), |
| 481 | a_values), |
| 482 | beta_values), |
| 483 | broadcast_bias_values), |
| 484 | act_values)) |
| 485 | { |
| 486 | // 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] | 487 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 488 | { |
| 489 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 490 | } |
| 491 | else |
| 492 | { |
| 493 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 494 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY, |
| 499 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 500 | m_values, |
| 501 | n_values), |
| 502 | k_values), |
| 503 | b_values), |
| 504 | m0_values_nightly), |
| 505 | n0_values_nightly), |
| 506 | k0_values_nightly), |
| 507 | h0_values), |
| 508 | i_values_rhs), |
| 509 | t_values_rhs), |
| 510 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 511 | framework::dataset::make("DataType", DataType::F16)), |
| 512 | a_values), |
| 513 | beta_values), |
| 514 | broadcast_bias_values), |
| 515 | act_values)) |
| 516 | { |
| 517 | // 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] | 518 | if(validate_result) |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 519 | { |
| 520 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 521 | } |
| 522 | else |
| 523 | { |
| 524 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 525 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 530 | 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] | 531 | m_w_values, |
| 532 | m_h_values), |
| 533 | n_values), |
| 534 | k_values), |
| 535 | b_values), |
| 536 | m0_values_precommit), |
| 537 | n0_values_precommit), |
| 538 | k0_values_precommit), |
| 539 | h0_values), |
| 540 | i_values_rhs), |
| 541 | t_values_rhs), |
| 542 | framework::dataset::make("export_to_cl_image_rhs", true)), |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 543 | framework::dataset::make("has_pad_y", {false, true})), |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 544 | framework::dataset::make("DataType", DataType::F16)), |
| 545 | a_values), |
| 546 | beta_values), |
| 547 | act_values)) |
| 548 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 549 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 550 | if(validate_result) |
| 551 | { |
| 552 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 553 | } |
| 554 | else |
| 555 | { |
| 556 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 557 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 558 | } |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY, |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 562 | 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] | 563 | m_w_values, |
| 564 | m_h_values), |
| 565 | n_values), |
| 566 | k_values), |
| 567 | b_values), |
| 568 | m0_values_nightly), |
| 569 | n0_values_nightly), |
| 570 | k0_values_nightly), |
| 571 | h0_values), |
| 572 | i_values_rhs), |
| 573 | t_values_rhs), |
| 574 | framework::dataset::make("export_to_cl_image_rhs", true)), |
Gian Marco Iodice | 9ae06d4 | 2020-10-22 16:37:12 +0100 | [diff] [blame] | 575 | framework::dataset::make("has_pad_y", {false, true})), |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 576 | framework::dataset::make("DataType", DataType::F16)), |
| 577 | a_values), |
| 578 | beta_values), |
| 579 | act_values)) |
| 580 | { |
Sheri Zhang | cc3e53c | 2020-11-16 21:17:28 +0000 | [diff] [blame] | 581 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 582 | if(validate_result) |
| 583 | { |
| 584 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 585 | } |
| 586 | else |
| 587 | { |
| 588 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 589 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 590 | } |
Gian Marco Iodice | 6f93134 | 2020-09-15 14:17:41 +0100 | [diff] [blame] | 591 | } |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 592 | TEST_SUITE_END() // FP16 |
| 593 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 594 | TEST_SUITE_END() // Float |
| 595 | TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS |
| 596 | TEST_SUITE_END() // CL |
| 597 | } // namespace validation |
| 598 | } // namespace test |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 599 | } // namespace arm_compute |