Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 ARM Limited. |
| 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/CLGEMMLowpMatrixMultiplyReshapedKernel.h" |
| 25 | #include "arm_compute/core/CL/kernels/CLGEMMReshapeLHSMatrixKernel.h" |
| 26 | #include "arm_compute/core/CL/kernels/CLGEMMReshapeRHSMatrixKernel.h" |
| 27 | #include "arm_compute/core/Types.h" |
| 28 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
| 29 | #include "tests/CL/CLAccessor.h" |
| 30 | #include "tests/CL/Helper.h" |
| 31 | #include "tests/framework/Asserts.h" |
| 32 | #include "tests/framework/Macros.h" |
| 33 | #include "tests/framework/datasets/Datasets.h" |
| 34 | #include "tests/validation/Validation.h" |
| 35 | #include "tests/validation/fixtures/GEMMLowpFixture.h" |
| 36 | |
| 37 | namespace arm_compute |
| 38 | { |
| 39 | namespace test |
| 40 | { |
| 41 | namespace validation |
| 42 | { |
| 43 | using namespace arm_compute::misc::shape_calculator; |
| 44 | |
| 45 | // Create function for CLGEMMReshapeLHSMatrixKernel |
| 46 | using CLGEMMReshapeLHSMatrix = CLSynthetizeFunction<CLGEMMReshapeLHSMatrixKernel>; |
| 47 | |
| 48 | // Create function for CLGEMMReshapeRHSMatrixKernel |
| 49 | using CLGEMMReshapeRHSMatrix = CLSynthetizeFunction<CLGEMMReshapeRHSMatrixKernel>; |
| 50 | |
| 51 | // Create function for CLGEMMMatrixMultiplyReshapedKernel |
| 52 | using CLGEMMLowpMatrixMultiplyReshaped = CLSynthetizeFunction<CLGEMMLowpMatrixMultiplyReshapedKernel>; |
| 53 | |
| 54 | // Fixture for CLGEMMLowpMatrixMultiplyReshaped |
| 55 | using CLGEMMLowpMatrixMultiplyReshapedFixture = GEMMLowpMatrixMultiplyReshapedValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped>; |
| 56 | |
| 57 | // Fixture for CLGEMMMatrixMultiplyReshaped3D |
| 58 | using CLGEMMLowpMatrixMultiplyReshaped3DFixture = |
| 59 | GEMMLowpMatrixMultiplyReshaped3DValidationFixture<CLTensor, CLAccessor, CLGEMMReshapeLHSMatrix, CLGEMMReshapeRHSMatrix, CLGEMMLowpMatrixMultiplyReshaped>; |
| 60 | |
| 61 | namespace |
| 62 | { |
| 63 | // *INDENT-OFF* |
| 64 | // clang-format off |
| 65 | /** M values to test */ |
| 66 | const auto m_values = framework::dataset::make("M", 37); |
| 67 | |
| 68 | /** M_W values to test */ |
| 69 | const auto m_w_values = framework::dataset::make("M_W", 5); |
| 70 | |
| 71 | /** M_H values to test */ |
| 72 | const auto m_h_values = framework::dataset::make("M_H", 7); |
| 73 | |
| 74 | /** N values to test */ |
| 75 | const auto n_values = framework::dataset::make("N", 51); |
| 76 | |
| 77 | /** K values to test */ |
| 78 | const auto k_values = framework::dataset::make("K", 23); |
| 79 | |
| 80 | /** Batch size values to test */ |
| 81 | const auto b_values = framework::dataset::make("batch_size", 1, 3); |
| 82 | |
| 83 | /** M0 values to test - Precommit */ |
| 84 | const auto m0_values_precommit = framework::dataset::make("M0", {4, 6}); |
| 85 | |
| 86 | /** N0 values to test - Precommit */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 87 | const auto n0_values_precommit = framework::dataset::make("N0", { 4 }); |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 88 | |
| 89 | /** K0 values to test - Precommit */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 90 | const auto k0_values_precommit = framework::dataset::make("K0", { 16 }); |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 91 | |
| 92 | /** V0 values to test - Precommit */ |
| 93 | const auto v0_values_precommit = framework::dataset::make("V0", 1, 3); |
| 94 | |
| 95 | /** H0 values to test - Precommit */ |
| 96 | const auto h0_values_precommit = framework::dataset::make("H0", 1, 3); |
| 97 | |
| 98 | /** M0 values to test - Nightly */ |
| 99 | const auto m0_values_nightly = framework::dataset::make("M0", 2, 7); |
| 100 | |
| 101 | /** N0 values to test - Nightly */ |
| 102 | const auto n0_values_nightly = framework::dataset::make("N0", { 2, 3, 4, 8 }); |
| 103 | |
| 104 | /** K0 values to test - Nightly */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 105 | const auto k0_values_nightly = framework::dataset::make("K0", { 2, 3, 4, 8, 16 }); |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 106 | |
| 107 | /** V0 values to test - Nightly */ |
| 108 | const auto v0_values_nightly = framework::dataset::make("V0", 1, 4); |
| 109 | |
| 110 | /** H0 values to test - Nightly */ |
| 111 | const auto h0_values_nightly = framework::dataset::make("H0", 1, 4); |
| 112 | |
| 113 | /** Interleave values to test with LHS matrix */ |
| 114 | const auto i_values_lhs = framework::dataset::make("interleave_lhs", { true, false }); |
| 115 | |
| 116 | /** Interleave values to test with RHS matrix */ |
| 117 | const auto i_values_rhs = framework::dataset::make("interleave_rhs", { true, false }); |
| 118 | } // namespace |
| 119 | |
| 120 | TEST_SUITE(CL) |
| 121 | TEST_SUITE(GEMMLowpMatrixMultiplyReshaped) |
| 122 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMLowpMatrixMultiplyReshapedFixture, framework::DatasetMode::ALL, |
| 123 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 124 | m_values, |
| 125 | n_values), |
| 126 | k_values), |
| 127 | b_values), |
| 128 | m0_values_precommit), |
| 129 | n0_values_precommit), |
| 130 | k0_values_precommit), |
| 131 | v0_values_precommit), |
| 132 | h0_values_precommit), |
| 133 | i_values_lhs), |
| 134 | i_values_rhs)) |
| 135 | { |
| 136 | // Validate output |
| 137 | validate(CLAccessor(_target), _reference); |
| 138 | } |
| 139 | |
| 140 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMLowpMatrixMultiplyReshapedFixture, framework::DatasetMode::NIGHTLY, |
| 141 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 142 | m_values, |
| 143 | n_values), |
| 144 | k_values), |
| 145 | b_values), |
| 146 | m0_values_nightly), |
| 147 | n0_values_nightly), |
| 148 | k0_values_nightly), |
| 149 | v0_values_nightly), |
| 150 | h0_values_nightly), |
| 151 | i_values_lhs), |
| 152 | i_values_rhs)) |
| 153 | { |
| 154 | // Validate output |
| 155 | validate(CLAccessor(_target), _reference); |
| 156 | } |
| 157 | |
| 158 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMLowpMatrixMultiplyReshaped3DFixture, framework::DatasetMode::ALL, |
| 159 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 160 | m_w_values, |
| 161 | m_h_values), |
| 162 | n_values), |
| 163 | k_values), |
| 164 | b_values), |
| 165 | m0_values_precommit), |
| 166 | n0_values_precommit), |
| 167 | k0_values_precommit), |
| 168 | v0_values_precommit), |
| 169 | h0_values_precommit), |
| 170 | i_values_lhs), |
| 171 | i_values_rhs)) |
| 172 | { |
| 173 | // Validate output |
| 174 | validate(CLAccessor(_target), _reference); |
| 175 | } |
| 176 | |
| 177 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMLowpMatrixMultiplyReshaped3DFixture, framework::DatasetMode::NIGHTLY, |
| 178 | combine(combine(combine(combine(combine(combine(combine(combine(combine(combine(combine( |
| 179 | m_w_values, |
| 180 | m_h_values), |
| 181 | n_values), |
| 182 | k_values), |
| 183 | b_values), |
| 184 | m0_values_nightly), |
| 185 | n0_values_nightly), |
| 186 | k0_values_nightly), |
| 187 | v0_values_nightly), |
| 188 | h0_values_nightly), |
| 189 | i_values_lhs), |
| 190 | i_values_rhs)) |
| 191 | { |
| 192 | // Validate output |
| 193 | validate(CLAccessor(_target), _reference); |
| 194 | } |
Gian Marco Iodice | 62251f7 | 2019-03-11 16:07:12 +0000 | [diff] [blame] | 195 | TEST_SUITE_END() // GEMMLowpMatrixMultiplyReshaped |
Gian Marco Iodice | db63b9c | 2019-01-17 09:47:04 +0000 | [diff] [blame] | 196 | TEST_SUITE_END() // CL |
| 197 | } // namespace validation |
| 198 | } // namespace test |
| 199 | } // namespace arm_compute |