Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2019-2020 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 | */ |
| 24 | #include "arm_compute/core/CL/kernels/CLGEMMMatrixMultiplyReshapedOnlyRHSKernel.h" |
| 25 | #include "arm_compute/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h" |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 26 | #include "arm_compute/core/KernelDescriptors.h" |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/Types.h" |
| 28 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
| 29 | #include "arm_compute/runtime/CL/CLTensor.h" |
| 30 | #include "arm_compute/runtime/CL/CLTensorAllocator.h" |
| 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 | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 77 | const auto beta_values = framework::dataset::make("beta", {-0.35f, 0.0f} ); |
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 */ |
| 95 | const auto b_values = framework::dataset::make("batch_size", 1, 3); |
| 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 | { |
| 100 | ActivationLayerInfo(), |
| 101 | ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU, 8.f, 2.f), |
| 102 | }); |
| 103 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 104 | /** M0 values to test - precommit */ |
| 105 | const auto m0_values_precommit = framework::dataset::make("M0", { 4 }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 106 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 107 | /** N0 values to test - precommit*/ |
| 108 | const auto n0_values_precommit = framework::dataset::make("N0", { 4 }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 109 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 110 | /** K0 values to test - precommit*/ |
| 111 | const auto k0_values_precommit = framework::dataset::make("K0", { 4 }); |
| 112 | |
| 113 | /** M0 values to test - nightly */ |
| 114 | const auto m0_values_nightly = framework::dataset::make("M0", { 8 }); |
| 115 | |
| 116 | /** N0 values to test - nightly */ |
| 117 | const auto n0_values_nightly = framework::dataset::make("N0", { 16 }); |
| 118 | |
| 119 | /** K0 values to test - nightly */ |
| 120 | const auto k0_values_nightly = framework::dataset::make("K0", { 16 }); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 121 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 122 | /** H0 values to test */ |
| 123 | const auto h0_values = framework::dataset::make("H0", 1, 3); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 124 | |
| 125 | /** Interleave values to test with RHS matrix */ |
| 126 | const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false }); |
| 127 | |
| 128 | /** Transpose values to test with RHS matrix */ |
Gian Marco Iodice | ba5e096 | 2019-03-11 12:17:44 +0000 | [diff] [blame] | 129 | 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] | 130 | |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 131 | /** Broadcast bias from vector to matrix */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 132 | const auto broadcast_bias_values = framework::dataset::make("broadcast_bias", { false, true } ); |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 133 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 134 | /** Configuration test */ |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 135 | bool validate_configuration(unsigned int m_value, unsigned int n_value, unsigned int k_value, unsigned int b_value, |
| 136 | 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] | 137 | 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] | 138 | 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] | 139 | { |
| 140 | const unsigned int M = m_value; |
| 141 | const unsigned int N = n_value; |
| 142 | const unsigned int K = k_value; |
| 143 | |
| 144 | GEMMLHSMatrixInfo lhs_info; |
| 145 | lhs_info.m0 = m0_value; |
| 146 | lhs_info.k0 = k0_value; |
| 147 | |
| 148 | GEMMRHSMatrixInfo rhs_info; |
| 149 | rhs_info.n0 = n0_value; |
| 150 | rhs_info.k0 = k0_value; |
| 151 | rhs_info.h0 = h0_value; |
| 152 | rhs_info.interleave = i_value_rhs; |
Gian Marco Iodice | ba5e096 | 2019-03-11 12:17:44 +0000 | [diff] [blame] | 153 | rhs_info.transpose = t_value_rhs; |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 154 | rhs_info.export_to_cl_image = export_to_cl_image; |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 155 | |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 156 | GEMMKernelInfo kernel_info; |
| 157 | kernel_info.m = M; |
| 158 | kernel_info.n = N; |
| 159 | kernel_info.k = K; |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 160 | kernel_info.depth_output_gemm3d = depth_output_gemm3d; |
| 161 | kernel_info.reinterpret_input_as_3d = input_as_3d; |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 162 | kernel_info.broadcast_bias = broadcast_bias; |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 163 | kernel_info.activation_info = act_info; |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 164 | |
| 165 | const TensorShape lhs_shape(K, M, b_value); |
| 166 | const TensorShape rhs_shape(N, K, b_value); |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 167 | 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] | 168 | rhs_info); |
| 169 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 170 | const TensorShape dst_shape = compute_mm_shape(TensorInfo(lhs_shape, 1, dt_input0), |
| 171 | TensorInfo(rhs_shape_reshaped, 1, dt_input1), |
Gian Marco Iodice | 7026b30 | 2019-06-26 17:18:11 +0100 | [diff] [blame] | 172 | kernel_info); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 173 | |
Gian Marco Iodice | e16c890 | 2019-06-14 16:11:10 +0100 | [diff] [blame] | 174 | const TensorShape bias_shape(N, |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 175 | 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] | 176 | broadcast_bias? 1 : b_value); |
| 177 | |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 178 | // Create tensor info |
| 179 | TensorInfo lhs = TensorInfo(lhs_shape, 1, dt_input0); |
| 180 | TensorInfo rhs_reshaped = TensorInfo(rhs_shape_reshaped, 1, dt_input1); |
| 181 | TensorInfo bias = TensorInfo(bias_shape, 1, dt_input2); |
| 182 | TensorInfo dst = TensorInfo(dst_shape, 1, dt_output); |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 183 | |
| 184 | // Create and configure function |
| 185 | CLGEMMMatrixMultiplyReshapedOnlyRHS gemm; |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 186 | 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] | 187 | } |
| 188 | } // namespace |
| 189 | |
| 190 | TEST_SUITE(CL) |
| 191 | TEST_SUITE(GEMMMatrixMultiplyReshapedOnlyRHS) |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 192 | |
| 193 | /** Validate tests |
| 194 | * |
| 195 | * A series of validation tests on configurations which according to the API specification |
| 196 | * the function should fail against. |
| 197 | * |
| 198 | * Checks performed in order: |
| 199 | * - Mismachting data type: input1, input2 and output need to have same data type as input0. Support data type: F32/F16. |
| 200 | * - Unsupported M0: MO can only be 1,2,3,4,5,6,7,8 |
| 201 | * - Unsupported N0: NO can only be 2,3,4,8,16 |
| 202 | * - Unsupported K0: KO can only be 2,3,4,8,16 |
| 203 | * - Unsupported bias addition: bias broadcast mode is 0 if the input or output has to be reinterpreted as 3D |
| 204 | * - Incorrect bias diemension when bias broadcast mode is 1 and beta is not 0.0f, should be (n, 1), not (n, m) |
| 205 | * - 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] | 206 | * - Correct support for creating an OpenCL image object from buffer |
| 207 | * - Incorrect support for creating an OpenCL image object from buffer. N0 is 2 but it can only be 4,8 and 16 |
| 208 | * - Incorrect support for creating an OpenCL image object from buffer. Data type is F16 but it can only be F32 |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 209 | */ |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 210 | DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip(zip( |
| 211 | framework::dataset::make("batch_size", { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1 }), |
| 212 | framework::dataset::make("M0", { 4, 9, 4, 4, 4, 4, 4, 4, 4, 4 })), |
| 213 | framework::dataset::make("N0", { 4, 4, 18, 4, 4, 4, 4, 8, 2, 8 })), |
| 214 | framework::dataset::make("K0", { 4, 4, 4, 1, 4, 4, 4, 4, 4, 4 })), |
| 215 | framework::dataset::make("broadcast_bias", { false, false, false, false, false, true, true, false, false, false })), |
| 216 | framework::dataset::make("input_as_3d", { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 })), |
| 217 | framework::dataset::make("depth_output_gemm3d", { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 })), |
| 218 | framework::dataset::make("export_to_cl_image", { false, false, false, false, false, false, false, true, true, true })), |
| 219 | 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})), |
| 220 | 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})), |
| 221 | 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})), |
| 222 | 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})), |
| 223 | framework::dataset::make("Beta", { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f , 1.0f})), |
| 224 | framework::dataset::make("Expected", { false, false, false, false, false, false, false, true, false, false })), |
| 225 | 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] | 226 | { |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 227 | bool expected_value = expected; |
| 228 | |
| 229 | // Change expected to false if the target platform does not support the OpenCL cl_khr_image2d_from_buffer extension |
| 230 | if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()) && export_to_cl_image) |
| 231 | { |
| 232 | expected_value = false; |
| 233 | } |
| 234 | |
| 235 | 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); |
| 236 | ARM_COMPUTE_EXPECT(status == expected_value, framework::LogLevel::ERRORS); |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 237 | } |
| 238 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 239 | TEST_SUITE(Float) |
| 240 | TEST_SUITE(FP32) |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 241 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 242 | FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 243 | 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] | 244 | m_values, |
| 245 | n_values), |
| 246 | k_values), |
| 247 | b_values), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 248 | m0_values_precommit), |
| 249 | n0_values_precommit), |
| 250 | k0_values_precommit), |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 251 | h0_values), |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 252 | i_values_rhs), |
| 253 | t_values_rhs), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 254 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 255 | framework::dataset::make("DataType", DataType::F32)), |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 256 | a_values), |
| 257 | beta_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 258 | broadcast_bias_values), |
| 259 | act_values)) |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 260 | { |
| 261 | // Validate output |
| 262 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 263 | } |
| 264 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 265 | FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY, |
| 266 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 267 | m_values, |
| 268 | n_values), |
| 269 | k_values), |
| 270 | b_values), |
| 271 | m0_values_nightly), |
| 272 | n0_values_nightly), |
| 273 | k0_values_nightly), |
| 274 | h0_values), |
| 275 | i_values_rhs), |
| 276 | t_values_rhs), |
| 277 | framework::dataset::make("export_to_cl_image_rhs", false)), |
| 278 | framework::dataset::make("DataType", DataType::F32)), |
| 279 | a_values), |
| 280 | beta_values), |
| 281 | broadcast_bias_values), |
| 282 | act_values)) |
| 283 | { |
| 284 | // Validate output |
| 285 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 286 | } |
| 287 | |
| 288 | FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 289 | 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] | 290 | m_w_values, |
| 291 | m_h_values), |
| 292 | n_values), |
| 293 | k_values), |
| 294 | b_values), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 295 | m0_values_precommit), |
| 296 | n0_values_precommit), |
| 297 | k0_values_precommit), |
Sheri Zhang | 1a37810 | 2020-04-30 12:59:39 +0100 | [diff] [blame] | 298 | h0_values), |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 299 | i_values_rhs), |
| 300 | t_values_rhs), |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 301 | framework::dataset::make("export_to_cl_image_rhs", false)), |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 302 | framework::dataset::make("DataType", DataType::F32)), |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 303 | a_values), |
Gian Marco Iodice | ca1f460 | 2019-07-16 15:46:48 +0100 | [diff] [blame] | 304 | beta_values), |
| 305 | act_values)) |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 306 | { |
| 307 | // Validate output |
| 308 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 309 | } |
| 310 | |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 311 | FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY, |
| 312 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 313 | m_w_values, |
| 314 | m_h_values), |
| 315 | n_values), |
| 316 | k_values), |
| 317 | b_values), |
| 318 | m0_values_nightly), |
| 319 | n0_values_nightly), |
| 320 | k0_values_nightly), |
| 321 | h0_values), |
| 322 | i_values_rhs), |
| 323 | t_values_rhs), |
| 324 | framework::dataset::make("export_to_cl_image_rhs", false)), |
| 325 | framework::dataset::make("DataType", DataType::F32)), |
| 326 | a_values), |
| 327 | beta_values), |
| 328 | act_values)) |
| 329 | { |
| 330 | // Validate output |
| 331 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 332 | } |
| 333 | |
| 334 | TEST_SUITE(ExportToCLImage) |
| 335 | FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 336 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 337 | m_values, |
| 338 | n_values), |
| 339 | k_values), |
| 340 | b_values), |
| 341 | m0_values_precommit), |
| 342 | n0_values_precommit), |
| 343 | k0_values_precommit), |
| 344 | h0_values), |
| 345 | i_values_rhs), |
| 346 | t_values_rhs), |
| 347 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 348 | framework::dataset::make("DataType", DataType::F32)), |
| 349 | a_values), |
| 350 | beta_values), |
| 351 | broadcast_bias_values), |
| 352 | act_values)) |
| 353 | { |
| 354 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 355 | if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) |
| 356 | { |
| 357 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 358 | } |
| 359 | else |
| 360 | { |
| 361 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 362 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<float>, framework::DatasetMode::NIGHTLY, |
| 367 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 368 | m_values, |
| 369 | n_values), |
| 370 | k_values), |
| 371 | b_values), |
| 372 | m0_values_nightly), |
| 373 | n0_values_nightly), |
| 374 | k0_values_nightly), |
| 375 | h0_values), |
| 376 | i_values_rhs), |
| 377 | t_values_rhs), |
| 378 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 379 | framework::dataset::make("DataType", DataType::F32)), |
| 380 | a_values), |
| 381 | beta_values), |
| 382 | broadcast_bias_values), |
| 383 | act_values)) |
| 384 | { |
| 385 | // Validate output only if the target platform supports the OpenCL cl_khr_image2d_from_buffer extension |
| 386 | if(image2d_from_buffer_supported(CLKernelLibrary::get().get_device())) |
| 387 | { |
| 388 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 389 | } |
| 390 | else |
| 391 | { |
| 392 | ARM_COMPUTE_TEST_INFO("cl_khr_image2d_from_buffer not supported. TEST skipped"); |
| 393 | framework::ARM_COMPUTE_PRINT_INFO(); |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::PRECOMMIT, |
| 398 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 399 | m_w_values, |
| 400 | m_h_values), |
| 401 | n_values), |
| 402 | k_values), |
| 403 | b_values), |
| 404 | m0_values_precommit), |
| 405 | n0_values_precommit), |
| 406 | k0_values_precommit), |
| 407 | h0_values), |
| 408 | i_values_rhs), |
| 409 | t_values_rhs), |
| 410 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 411 | framework::dataset::make("DataType", DataType::F32)), |
| 412 | a_values), |
| 413 | beta_values), |
| 414 | act_values)) |
| 415 | { |
| 416 | // Validate output |
| 417 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 418 | } |
| 419 | |
| 420 | FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<float>, framework::DatasetMode::NIGHTLY, |
| 421 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 422 | m_w_values, |
| 423 | m_h_values), |
| 424 | n_values), |
| 425 | k_values), |
| 426 | b_values), |
| 427 | m0_values_nightly), |
| 428 | n0_values_nightly), |
| 429 | k0_values_nightly), |
| 430 | h0_values), |
| 431 | i_values_rhs), |
| 432 | t_values_rhs), |
| 433 | framework::dataset::make("export_to_cl_image_rhs", true)), |
| 434 | framework::dataset::make("DataType", DataType::F32)), |
| 435 | a_values), |
| 436 | beta_values), |
| 437 | act_values)) |
| 438 | { |
| 439 | // Validate output |
| 440 | validate(CLAccessor(_target), _reference, rel_tolerance_f32, 0.f, abs_tolerance_f32); |
| 441 | } |
| 442 | TEST_SUITE_END() // ExportToCLImage |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 443 | TEST_SUITE_END() // FP32 |
Gian Marco Iodice | 781cba7 | 2020-06-19 16:56:57 +0100 | [diff] [blame] | 444 | |
| 445 | TEST_SUITE(FP16) |
| 446 | FIXTURE_DATA_TEST_CASE(RunPrecommit, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::PRECOMMIT, |
| 447 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 448 | m_values, |
| 449 | n_values), |
| 450 | k_values), |
| 451 | b_values), |
| 452 | m0_values_precommit), |
| 453 | n0_values_precommit), |
| 454 | k0_values_precommit), |
| 455 | h0_values), |
| 456 | i_values_rhs), |
| 457 | t_values_rhs), |
| 458 | framework::dataset::make("export_to_cl_image_rhs", false)), |
| 459 | framework::dataset::make("DataType", DataType::F16)), |
| 460 | a_values), |
| 461 | beta_values), |
| 462 | broadcast_bias_values), |
| 463 | act_values)) |
| 464 | { |
| 465 | // Validate output |
| 466 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 467 | } |
| 468 | |
| 469 | FIXTURE_DATA_TEST_CASE(RunNightly, CLGEMMMatrixMultiplyReshapedOnlyRHSFixture<half>, framework::DatasetMode::NIGHTLY, |
| 470 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 471 | m_values, |
| 472 | n_values), |
| 473 | k_values), |
| 474 | b_values), |
| 475 | m0_values_nightly), |
| 476 | n0_values_nightly), |
| 477 | k0_values_nightly), |
| 478 | h0_values), |
| 479 | i_values_rhs), |
| 480 | t_values_rhs), |
| 481 | framework::dataset::make("export_to_cl_image_rhs", false)), |
| 482 | framework::dataset::make("DataType", DataType::F16)), |
| 483 | a_values), |
| 484 | beta_values), |
| 485 | broadcast_bias_values), |
| 486 | act_values)) |
| 487 | { |
| 488 | // Validate output |
| 489 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 490 | } |
| 491 | |
| 492 | FIXTURE_DATA_TEST_CASE(RunPrecommit3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::PRECOMMIT, |
| 493 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 494 | m_w_values, |
| 495 | m_h_values), |
| 496 | n_values), |
| 497 | k_values), |
| 498 | b_values), |
| 499 | m0_values_precommit), |
| 500 | n0_values_precommit), |
| 501 | k0_values_precommit), |
| 502 | h0_values), |
| 503 | i_values_rhs), |
| 504 | t_values_rhs), |
| 505 | framework::dataset::make("export_to_cl_image_rhs", false)), |
| 506 | framework::dataset::make("DataType", DataType::F16)), |
| 507 | a_values), |
| 508 | beta_values), |
| 509 | act_values)) |
| 510 | { |
| 511 | // Validate output |
| 512 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 513 | } |
| 514 | |
| 515 | FIXTURE_DATA_TEST_CASE(RunNightly3D, CLGEMMMatrixMultiplyReshapedOnlyRHS3DFixture<half>, framework::DatasetMode::NIGHTLY, |
| 516 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 517 | m_w_values, |
| 518 | m_h_values), |
| 519 | n_values), |
| 520 | k_values), |
| 521 | b_values), |
| 522 | m0_values_nightly), |
| 523 | n0_values_nightly), |
| 524 | k0_values_nightly), |
| 525 | h0_values), |
| 526 | i_values_rhs), |
| 527 | t_values_rhs), |
| 528 | framework::dataset::make("export_to_cl_image_rhs", false)), |
| 529 | framework::dataset::make("DataType", DataType::F16)), |
| 530 | a_values), |
| 531 | beta_values), |
| 532 | act_values)) |
| 533 | { |
| 534 | // Validate output |
| 535 | validate(CLAccessor(_target), _reference, rel_tolerance_f16, 0.f, abs_tolerance_f16); |
| 536 | } |
| 537 | |
| 538 | TEST_SUITE_END() // FP16 |
| 539 | |
Gian Marco Iodice | adc5395 | 2019-02-15 11:10:31 +0000 | [diff] [blame] | 540 | TEST_SUITE_END() // Float |
| 541 | TEST_SUITE_END() // GEMMMatrixMulipltyReshapedOnlyRHS |
| 542 | TEST_SUITE_END() // CL |
| 543 | } // namespace validation |
| 544 | } // namespace test |
Georgios Pinitas | b0f342e | 2019-05-21 13:32:43 +0100 | [diff] [blame] | 545 | } // namespace arm_compute |