Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023 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 | */ |
Gunes Bayir | 8918b23 | 2023-03-17 13:52:21 +0000 | [diff] [blame] | 24 | #ifndef ACL_TESTS_DATASETS_SMALLMATMULDATASET |
| 25 | #define ACL_TESTS_DATASETS_SMALLMATMULDATASET |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/core/TensorShape.h" |
| 28 | #include "arm_compute/core/Types.h" |
Gunes Bayir | 8918b23 | 2023-03-17 13:52:21 +0000 | [diff] [blame] | 29 | #include "tests/datasets/MatMulDataset.h" |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | namespace test |
| 34 | { |
| 35 | namespace datasets |
| 36 | { |
Gunes Bayir | 8918b23 | 2023-03-17 13:52:21 +0000 | [diff] [blame] | 37 | class SmallMatMulDataset final : public MatMulDataset |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 38 | { |
| 39 | public: |
Gunes Bayir | 8918b23 | 2023-03-17 13:52:21 +0000 | [diff] [blame] | 40 | SmallMatMulDataset() |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 41 | { |
| 42 | add_config(TensorShape(3U, 4U, 2U, 2U), TensorShape(2U, 3U, 2U, 2U), TensorShape(2U, 4U, 2U, 2U)); |
| 43 | add_config(TensorShape(9U, 6U), TensorShape(5U, 9U), TensorShape(5U, 6U)); |
| 44 | add_config(TensorShape(31U, 1U), TensorShape(23U, 31U), TensorShape(23U, 1U)); |
| 45 | add_config(TensorShape(8U, 4U, 2U), TensorShape(16U, 8U, 2U), TensorShape(16U, 4U, 2U)); |
| 46 | add_config(TensorShape(32U, 2U), TensorShape(17U, 32U), TensorShape(17U, 2U)); |
| 47 | } |
| 48 | }; |
Gunes Bayir | 8918b23 | 2023-03-17 13:52:21 +0000 | [diff] [blame] | 49 | |
Viet-Hoa Do | 9c7c2d2 | 2023-04-11 17:16:27 +0100 | [diff] [blame] | 50 | class SmallerMatMulDataset final : public MatMulDataset |
| 51 | { |
| 52 | public: |
| 53 | SmallerMatMulDataset() |
| 54 | { |
| 55 | add_config(TensorShape(9U, 6U), TensorShape(5U, 9U), TensorShape(5U, 6U)); |
| 56 | add_config(TensorShape(8U, 4U, 2U), TensorShape(16U, 8U, 2U), TensorShape(16U, 4U, 2U)); |
| 57 | add_config(TensorShape(32U, 2U), TensorShape(17U, 32U), TensorShape(17U, 2U)); |
| 58 | } |
| 59 | }; |
| 60 | |
Gunes Bayir | 8918b23 | 2023-03-17 13:52:21 +0000 | [diff] [blame] | 61 | class TinyMatMulDataset final : public MatMulDataset |
| 62 | { |
| 63 | public: |
| 64 | TinyMatMulDataset() |
| 65 | { |
| 66 | add_config(TensorShape(1U), TensorShape(1U), TensorShape(1U)); |
| 67 | add_config(TensorShape(2U, 2U), TensorShape(2U, 2U), TensorShape(2U, 2U)); |
| 68 | } |
| 69 | }; |
| 70 | |
Ramy Elgammal | b531b75 | 2023-03-20 10:19:10 +0000 | [diff] [blame] | 71 | class SmallMatMulDatasetRhsExportToCLImageRhsT final : public MatMulDataset |
| 72 | { |
| 73 | public: |
| 74 | // Some considerations: |
| 75 | // 1) K dimension should be a multiple of 4 |
| 76 | // See (2), (3), and (4) in SmallMatMulDatasetRhsExportToCLImageRhsNT |
| 77 | SmallMatMulDatasetRhsExportToCLImageRhsT() |
| 78 | { |
| 79 | add_config(TensorShape(8U /*K*/, 3U /*M*/, 2U, 1U, 2U), TensorShape(20U /*N*/, 8U /*K*/, 2U, 1U, 2U), TensorShape(20U /*N*/, 3U /*M*/, 2U, 1U, 2U)); |
| 80 | } |
| 81 | }; |
| 82 | |
Gunes Bayir | bbeef72 | 2023-03-20 10:19:10 +0000 | [diff] [blame] | 83 | class SmallMatMulDatasetRhsExportToCLImageRhsNT final : public MatMulDataset |
| 84 | { |
| 85 | public: |
| 86 | // Some considerations: |
| 87 | // (1) N (Dimension 0 of Rhs matrix) dimension should be a multiple of 4 |
| 88 | // (2) Having N=20 enables us to test all possible N0 values, i.e. 4, 8, 16 |
| 89 | // (3) It's important to have more than one loop iterations in the K dimension |
| 90 | // K has been chosen in accordance with K0 |
| 91 | // (4) The 5-th dimension has been chosen as non-unit because export_to_cl_iamge checks |
| 92 | // were using dim1 * dim2 * dim3 to calculate the CLImage height; however, in our case |
| 93 | // the tensor can be > 4D. To stress that case, the fifth dimension is chosen to be non-unit as well |
| 94 | SmallMatMulDatasetRhsExportToCLImageRhsNT() |
| 95 | { |
| 96 | add_config(TensorShape(7U, 3U, 2U, 1U, 2U), TensorShape(20U, 7U, 2U, 1U, 2U), TensorShape(20U, 3U, 2U, 1U, 2U)); |
| 97 | } |
| 98 | }; |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 99 | } // namespace datasets |
| 100 | } // namespace test |
| 101 | } // namespace arm_compute |
Gunes Bayir | 8918b23 | 2023-03-17 13:52:21 +0000 | [diff] [blame] | 102 | #endif /* ACL_TESTS_DATASETS_SMALLMATMULDATASET */ |