Gian Marco Iodice | 352c07d | 2023-05-03 12:21:38 +0100 | [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 | */ |
| 24 | #ifndef SRC_RUNTIME_HEURISTICS_MATMUL_NATIVE_CLMATMULNATIVEHELPERS |
| 25 | #define SRC_RUNTIME_HEURISTICS_MATMUL_NATIVE_CLMATMULNATIVEHELPERS |
| 26 | |
| 27 | #include "arm_compute/core/Types.h" |
| 28 | |
| 29 | namespace arm_compute |
| 30 | { |
| 31 | // Forward declaration |
| 32 | struct MatMulKernelInfo; |
| 33 | |
| 34 | namespace cl_matmul |
| 35 | { |
| 36 | using MatMulNativeConfigsMatrix = std::vector<std::vector<int32_t>>; |
| 37 | |
| 38 | /** This function accepts two MatMulKernelInfo objects where only the first can be with cl_image2d support enabled. |
| 39 | * The aim of this function is to check whether the first MatMulKernelInfo object is valid. If not, the function will |
| 40 | * return the second MatMulKernelInfo object. Otherwise, the first one. |
| 41 | * |
| 42 | * @param[in] info0 MatMulKernelInfo with cl_image2d support |
| 43 | * @param[in] info1 MatMulKernelInfo to fall-back if cl_image2d cannot be used |
| 44 | * @param[in] m Number of rows (M) of the LHS matrix |
| 45 | * @param[in] n Number of columns (N) in the RHS matrix not reshaped |
| 46 | * @param[in] k Number of rows (K) in the RHS matrix not reshaped |
| 47 | * @param[in] b Batch size |
| 48 | * @param[in] data_type Data type |
| 49 | * @param[in] rhs_lock_padding Flag used to know whether the RHS paddings are locked |
| 50 | * |
| 51 | * @return @ref MatMulKernelInfo |
| 52 | */ |
| 53 | MatMulKernelInfo select_info(const MatMulKernelInfo &info0, |
| 54 | const MatMulKernelInfo &info1, |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 55 | unsigned int m, |
| 56 | unsigned int n, |
| 57 | unsigned int k, |
| 58 | unsigned int b, |
| 59 | DataType data_type, |
| 60 | bool rhs_lock_padding); |
Gian Marco Iodice | 352c07d | 2023-05-03 12:21:38 +0100 | [diff] [blame] | 61 | |
| 62 | /** Find the preferred configurations for the MatMul Native kernel using the MatMulNativeConfigsMatrix provided by the user |
| 63 | * |
| 64 | * @param[in] configs List of best configurations for a limited number of MatMul shapes |
| 65 | * @param[in] adj_lhs Adjoint LHS flag value |
| 66 | * @param[in] adj_rhs Adjoint RHS flag value |
| 67 | * @param[in] m Number of rows (M) of the LHS matrix |
| 68 | * @param[in] n Number of columns (N) in the RHS matrix not reshaped |
| 69 | * @param[in] k Number of rows (K) in the RHS matrix not reshaped |
| 70 | * @param[in] b Batch size |
| 71 | * |
| 72 | * @return @ref MatMulKernelInfo |
| 73 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 74 | MatMulKernelInfo find_info(const MatMulNativeConfigsMatrix &configs, |
| 75 | bool adj_lhs, |
| 76 | bool adj_rhs, |
| 77 | unsigned int m, |
| 78 | unsigned int n, |
| 79 | unsigned int k, |
| 80 | unsigned int b); |
Gian Marco Iodice | 352c07d | 2023-05-03 12:21:38 +0100 | [diff] [blame] | 81 | } // namespace cl_matmul |
| 82 | } // namespace arm_compute |
| 83 | #endif /* SRC_RUNTIME_HEURISTICS_MATMUL_NATIVE_CLMATMULNATIVEHELPERS */ |