blob: db88e0d73553876aa4abf5340695a7c097836148 [file] [log] [blame]
Georgios Pinitas856f66e2021-04-22 21:13:21 +01001/*
2 * Copyright (c) 2018-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 ARM_COMPUTE_CL_GEMM_RESHAPE_LHS_MATRIX_KERNEL_H
25#define ARM_COMPUTE_CL_GEMM_RESHAPE_LHS_MATRIX_KERNEL_H
26
27#include "src/core/common/Macros.h"
Georgios Pinitas7891a732021-08-20 21:39:25 +010028#include "src/gpu/cl/ClCompileContext.h"
29#include "src/gpu/cl/IClKernel.h"
Georgios Pinitas856f66e2021-04-22 21:13:21 +010030
31namespace arm_compute
32{
33namespace opencl
34{
35namespace kernels
36{
37/** OpenCL kernel to reshape the LHS matrix when performing the matrix multiplication.
38 * In particular, this function splits the src matrix in blocks of size M0xK0 (defined through GEMMLHSInfo) and
39 * stores each one in the dst matrix unrolling the values
40 */
41class ClGemmReshapeLhsMatrixKernel : public ICLKernel
42{
43public:
Giorgio Arena4a95bba2021-06-28 11:00:27 +010044 ClGemmReshapeLhsMatrixKernel();
Georgios Pinitas856f66e2021-04-22 21:13:21 +010045 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClGemmReshapeLhsMatrixKernel);
46 /** Initialise the kernel's input and output.
47 *
48 * @param[in] compile_context The compile context to be used.
49 * @param[in] src Input tensor. Data types supported: All
50 * @param[out] dst Output tensor. Data type supported: same as @p src
51 * @param[in] lhs_info LHS matrix information to be used for reshaping. This object contains all the necessary
52 * information to reshape the src tensor. Only the following values are supported:
53 * lhs_info.m0: 2,3,4,5,6,7,8
54 * lhs_info.k0: 2,3,4,8,16
55 * lhs_info.v0: greater than 0
56 * lhs_info.transpose: true, false
57 * lhs_info.interleave: true, false
58 * @param[in] reinterpret_src_as_3d (Optional) True if the src has to be reinterpreted as 3D tensor
59 */
60 void configure(const ClCompileContext &compile_context, ITensorInfo *src, ITensorInfo *dst, const GEMMLHSMatrixInfo &lhs_info, bool reinterpret_src_as_3d = false);
61 /** Static function to check if given info will lead to a valid configuration
62 *
63 * Similar to @ref ClGemmReshapeLhsMatrixKernel::configure()
64 *
65 * @return a status
66 */
67 static Status validate(const ITensorInfo *src, const ITensorInfo *dst, const GEMMLHSMatrixInfo &lhs_info, bool reinterpret_src_as_3d);
68
69 // Inherited methods overridden:
70 void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
Georgios Pinitas856f66e2021-04-22 21:13:21 +010071};
72} // namespace kernels
73} // namespace opencl
74} // namespace arm_compute
75#endif /* ARM_COMPUTE_CL_GEMM_RESHAPE_LHS_MATRIX_KERNEL_H */