• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_CL_MLGO_COMMON_H
25 #define SRC_RUNTIME_CL_MLGO_COMMON_H
26 
27 #include "arm_compute/core/Types.h"
28 #include "arm_compute/runtime/CL/CLTypes.h"
29 
30 namespace arm_compute
31 {
32 namespace mlgo
33 {
34 /** Types of Heuristic (tree) */
35 enum class HeuristicType
36 {
37     GEMM_Type,                     /**< About the type of gemm */
38     GEMM_Config_Native,            /**< About the gemm config for native kernel */
39     GEMM_Config_Reshaped_Only_RHS, /**< About the gemm config for reshaped only rhs kernel */
40     GEMM_Config_Reshaped           /**< About the gemm config for reshaped kernel */
41 };
42 
43 using GEMMType = CLGEMMKernelType;
44 
45 /** GEMM Configuration for Native kernel */
46 struct GEMMConfigNative
47 {
48     unsigned int m0{ 1 }; /**< Number of rows processed by the matrix multiplication */
49     unsigned int n0{ 1 }; /**< Number of columns processed by the matrix multiplication */
50     unsigned int k0{ 1 }; /**< Number of partial accumulations performed by the matrix multiplication */
51 };
52 
53 /** GEMM Configuration for Reshaped Only RHS kernel */
54 struct GEMMConfigReshapedOnlyRHS
55 {
56     unsigned int m0{ 1 };                  /**< Number of rows processed by the matrix multiplication */
57     unsigned int n0{ 1 };                  /**< Number of columns processed by the matrix multiplication */
58     unsigned int k0{ 1 };                  /**< Number of partial accumulations performed by the matrix multiplication */
59     unsigned int h0{ 1 };                  /**< Number of horizontal blocks of size (k0xn0) stored on the same output row */
60     bool         interleave_rhs{ false };  /**< True if the h0 (k0xn0) blocks have to be interleaved in the output row */
61     bool         transpose_rhs{ false };   /**< True if the (k0xn0) block has to be transposed before been stored */
62     bool         export_cl_image{ false }; /**< True if the reshaped rhs has to be exported to cl_image. n0 must be equal to 4 */
63 };
64 
65 /** GEMM Configuration for Reshaped kernel */
66 struct GEMMConfigReshaped
67 {
68     unsigned int m0{ 1 };                  /**< Number of rows processed by the matrix multiplication */
69     unsigned int n0{ 1 };                  /**< Number of columns processed by the matrix multiplication */
70     unsigned int k0{ 1 };                  /**< Number of partial accumulations performed by the matrix multiplication */
71     unsigned int v0{ 1 };                  /**< Number of vertical blocks of size (m0xk0) stored on the same output row */
72     unsigned int h0{ 1 };                  /**< Number of horizontal blocks of size (k0xn0) stored on the same output row */
73     bool         interleave_lhs{ false };  /**< True if the v0 (m0xk0) blocks have to be interleaved in the output row */
74     bool         interleave_rhs{ false };  /**< True if the h0 (k0xn0) blocks have to be interleaved in the output row */
75     bool         transpose_rhs{ false };   /**< True if the (k0xn0) block has to be transposed before been stored */
76     bool         export_cl_image{ false }; /**< True if the reshaped rhs has to be exported to cl_image. n0 must be equal to 4 */
77 };
78 
79 } // namespace mlgo
80 } // namespace arm_compute
81 #endif // SRC_RUNTIME_CL_MLGO_COMMON_H