Gian Marco Iodice | e751062 | 2019-06-03 17:28:17 +0100 | [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 | e751062 | 2019-06-03 17:28:17 +0100 | [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 | e751062 | 2019-06-03 17:28:17 +0100 | [diff] [blame] | 24 | #include "arm_compute/core/Types.h" |
| 25 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 26 | #include "src/core/CL/kernels/CLGEMMLowpMatrixMultiplyNativeKernel.h" |
Gian Marco Iodice | e751062 | 2019-06-03 17:28:17 +0100 | [diff] [blame] | 27 | #include "tests/CL/CLAccessor.h" |
| 28 | #include "tests/CL/Helper.h" |
| 29 | #include "tests/framework/Asserts.h" |
| 30 | #include "tests/framework/Macros.h" |
| 31 | #include "tests/framework/datasets/Datasets.h" |
| 32 | #include "tests/validation/Validation.h" |
| 33 | #include "tests/validation/fixtures/GEMMLowpFixture.h" |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace test |
| 38 | { |
| 39 | namespace validation |
| 40 | { |
| 41 | using namespace arm_compute::misc::shape_calculator; |
| 42 | |
| 43 | // Create function for CLGEMMMatrixMultiplyNativeKernel |
| 44 | using CLGEMMLowpMatrixMultiplyNative = CLSynthetizeFunction<CLGEMMLowpMatrixMultiplyNativeKernel>; |
| 45 | |
| 46 | // Fixture for CLGEMMLowpMatrixMultiplyNative |
| 47 | using CLGEMMLowpMatrixMultiplyNativeFixture = GEMMLowpMatrixMultiplyNativeValidationFixture<CLTensor, CLAccessor, CLGEMMLowpMatrixMultiplyNative>; |
| 48 | |
| 49 | // Fixture for CLGEMMMatrixMultiplyNative3D |
| 50 | using CLGEMMLowpMatrixMultiplyNative3DFixture = GEMMLowpMatrixMultiplyNative3DValidationFixture<CLTensor, CLAccessor, CLGEMMLowpMatrixMultiplyNative>; |
| 51 | |
| 52 | namespace |
| 53 | { |
| 54 | // *INDENT-OFF* |
| 55 | // clang-format off |
| 56 | /** M values to test */ |
| 57 | const auto m_values = framework::dataset::make("M", 37); |
| 58 | |
| 59 | /** M_W values to test */ |
| 60 | const auto m_w_values = framework::dataset::make("M_W", 5); |
| 61 | |
| 62 | /** M_H values to test */ |
| 63 | const auto m_h_values = framework::dataset::make("M_H", 7); |
| 64 | |
| 65 | /** N values to test */ |
| 66 | const auto n_values = framework::dataset::make("N", 51); |
| 67 | |
| 68 | /** K values to test */ |
| 69 | const auto k_values = framework::dataset::make("K", 23); |
| 70 | |
| 71 | /** Batch size values to test */ |
| 72 | const auto b_values = framework::dataset::make("batch_size", 1, 3); |
| 73 | |
| 74 | /** M0 values to test - Precommit */ |
| 75 | const auto m0_values_precommit = framework::dataset::make("M0", {4, 6}); |
| 76 | |
| 77 | /** N0 values to test - Precommit */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 78 | const auto n0_values_precommit = framework::dataset::make("N0", { 4 }); |
Gian Marco Iodice | e751062 | 2019-06-03 17:28:17 +0100 | [diff] [blame] | 79 | |
| 80 | /** K0 values to test - Precommit */ |
Gian Marco Iodice | d820db6 | 2019-08-05 14:23:23 +0100 | [diff] [blame] | 81 | const auto k0_values_precommit = framework::dataset::make("K0", { 16 }); |
Gian Marco Iodice | e751062 | 2019-06-03 17:28:17 +0100 | [diff] [blame] | 82 | |
| 83 | /** M0 values to test - Nightly */ |
SiCong Li | 6bc4e96 | 2020-12-03 12:52:28 +0000 | [diff] [blame] | 84 | const auto m0_values_nightly = framework::dataset::make("M0", {1, 2, 7}); |
Gian Marco Iodice | e751062 | 2019-06-03 17:28:17 +0100 | [diff] [blame] | 85 | |
| 86 | /** N0 values to test - Nightly */ |
SiCong Li | 738893e | 2020-05-01 12:55:16 +0100 | [diff] [blame] | 87 | const auto n0_values_nightly = framework::dataset::make("N0", { 1, 2, 3, 4, 8 }); |
Gian Marco Iodice | e751062 | 2019-06-03 17:28:17 +0100 | [diff] [blame] | 88 | |
| 89 | /** K0 values to test - Nightly */ |
SiCong Li | 738893e | 2020-05-01 12:55:16 +0100 | [diff] [blame] | 90 | const auto k0_values_nightly = framework::dataset::make("K0", { 1, 2, 3, 4, 8, 16 }); |
Gian Marco Iodice | e751062 | 2019-06-03 17:28:17 +0100 | [diff] [blame] | 91 | } // namespace |
| 92 | |
| 93 | TEST_SUITE(CL) |
| 94 | TEST_SUITE(GEMMLowpMatrixMultiplyNative) |
| 95 | FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMLowpMatrixMultiplyNativeFixture, framework::DatasetMode::ALL, |
| 96 | combine(combine(combine(combine(combine(combine(m_values, |
| 97 | n_values), |
| 98 | k_values), |
| 99 | b_values), |
| 100 | m0_values_precommit), |
| 101 | n0_values_precommit), |
| 102 | k0_values_precommit)) |
| 103 | { |
| 104 | // Validate output |
| 105 | validate(CLAccessor(_target), _reference); |
| 106 | } |
| 107 | |
SiCong Li | 738893e | 2020-05-01 12:55:16 +0100 | [diff] [blame] | 108 | FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMLowpMatrixMultiplyNativeFixture, framework::DatasetMode::ALL, |
Gian Marco Iodice | e751062 | 2019-06-03 17:28:17 +0100 | [diff] [blame] | 109 | combine(combine(combine(combine(combine(combine(m_values, |
| 110 | n_values), |
| 111 | k_values), |
| 112 | b_values), |
| 113 | m0_values_nightly), |
| 114 | n0_values_nightly), |
| 115 | k0_values_nightly)) |
| 116 | { |
| 117 | // Validate output |
| 118 | validate(CLAccessor(_target), _reference); |
| 119 | } |
| 120 | |
| 121 | FIXTURE_DATA_TEST_CASE(RunSmall3D, CLGEMMLowpMatrixMultiplyNative3DFixture, framework::DatasetMode::ALL, |
| 122 | combine(combine(combine(combine(combine(combine(combine(m_w_values, |
| 123 | m_h_values), |
| 124 | n_values), |
| 125 | k_values), |
| 126 | b_values), |
| 127 | m0_values_precommit), |
| 128 | n0_values_precommit), |
| 129 | k0_values_precommit)) |
| 130 | { |
| 131 | // Validate output |
| 132 | validate(CLAccessor(_target), _reference); |
| 133 | } |
| 134 | |
SiCong Li | 738893e | 2020-05-01 12:55:16 +0100 | [diff] [blame] | 135 | FIXTURE_DATA_TEST_CASE(RunLarge3D, CLGEMMLowpMatrixMultiplyNative3DFixture, framework::DatasetMode::ALL, |
Gian Marco Iodice | e751062 | 2019-06-03 17:28:17 +0100 | [diff] [blame] | 136 | combine(combine(combine(combine(combine(combine(combine(m_w_values, |
| 137 | m_h_values), |
| 138 | n_values), |
| 139 | k_values), |
| 140 | b_values), |
| 141 | m0_values_nightly), |
| 142 | n0_values_nightly), |
| 143 | k0_values_nightly)) |
| 144 | { |
| 145 | // Validate output |
| 146 | validate(CLAccessor(_target), _reference); |
| 147 | } |
| 148 | TEST_SUITE_END() // GEMMLowpMatrixMultiplyNative |
| 149 | TEST_SUITE_END() // CL |
| 150 | } // namespace validation |
| 151 | } // namespace test |
| 152 | } // namespace arm_compute |