blob: 699f5fe8c1a44a8f87f7982d208bf9985998d7ae [file] [log] [blame]
Gian Marco Iodice352c07d2023-05-03 12:21:38 +01001/*
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 Bayir85cafff2023-12-18 13:29:31 +000024#ifndef ACL_SRC_RUNTIME_HEURISTICS_MATMUL_NATIVE_CLMATMULNATIVEHELPERS_H
25#define ACL_SRC_RUNTIME_HEURISTICS_MATMUL_NATIVE_CLMATMULNATIVEHELPERS_H
Gian Marco Iodice352c07d2023-05-03 12:21:38 +010026
27#include "arm_compute/core/Types.h"
28
29namespace arm_compute
30{
31// Forward declaration
32struct MatMulKernelInfo;
33
34namespace cl_matmul
35{
36using 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 */
53MatMulKernelInfo select_info(const MatMulKernelInfo &info0,
54 const MatMulKernelInfo &info1,
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010055 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 Iodice352c07d2023-05-03 12:21:38 +010061
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 Thomasmathibalanafd38f02023-09-27 17:46:17 +010074MatMulKernelInfo 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 Iodice352c07d2023-05-03 12:21:38 +010081} // namespace cl_matmul
82} // namespace arm_compute
Gunes Bayir85cafff2023-12-18 13:29:31 +000083#endif // ACL_SRC_RUNTIME_HEURISTICS_MATMUL_NATIVE_CLMATMULNATIVEHELPERS_H