blob: f706256e31aa792c9b3ac58c4dd8defb9414a6ed [file] [log] [blame]
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +00001/*
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 */
Jakub Sujak1ed6a142023-04-13 21:14:42 +010024#ifndef ACL_SRC_GPU_CL_KERNELS_CLMATMULNATIVEKERNEL
25#define ACL_SRC_GPU_CL_KERNELS_CLMATMULNATIVEKERNEL
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +000026
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +000027#include "arm_compute/core/KernelDescriptors.h"
28#include "src/core/common/Macros.h"
29#include "src/gpu/cl/ClCompileContext.h"
30#include "src/gpu/cl/IClKernel.h"
31
32namespace arm_compute
33{
34namespace opencl
35{
36namespace kernels
37{
Jakub Sujak1ed6a142023-04-13 21:14:42 +010038class ClMatMulNativeKernel : public IClKernel
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +000039{
40public:
Jakub Sujak1ed6a142023-04-13 21:14:42 +010041 ClMatMulNativeKernel();
42 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClMatMulNativeKernel);
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +000043 /** Initialise the kernel's input and output.
44 *
45 * @param[in] compile_context The compile context to be used.
46 * @param[in] lhs Input tensor for the LHS matrix. Data type supported: F32/F16.
47 * Dimensions above 2 are collapsed onto dimension 2 and represent the batch.
48 * @param[in] rhs Input tensor for the RHS matrix. Data type supported: same as @p lhs.
49 * Dimensions above 2 are collapsed onto dimension 2 and represent the batch.
Jakub Sujake9b3ee22023-04-17 12:08:48 +010050 * @param[out] dst Output tensor info. Data type supported: same as @p lhs
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +000051 * @param[in] matmul_info Attributes for Batch MatMul Kernel
52 */
Jakub Sujake9b3ee22023-04-17 12:08:48 +010053 void configure(const ClCompileContext &compile_context, ITensorInfo *lhs, ITensorInfo *rhs, ITensorInfo *dst, const MatMulKernelInfo &matmul_info);
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +000054 /** Static function to check if given info will lead to a valid configuration
55 *
Jakub Sujak1ed6a142023-04-13 21:14:42 +010056 * Similar to @ref ClMatMulNativeKernel::configure()
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +000057 *
58 * @return a status
59 */
Jakub Sujake9b3ee22023-04-17 12:08:48 +010060 static Status validate(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *dst, const MatMulKernelInfo &matmul_info);
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +000061
62 // Inherited methods overridden:
63 void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
Gunes Bayirbbeef722023-03-20 10:19:10 +000064
65private:
Ramy Elgammalf26ea2f2023-03-24 11:42:03 +000066 bool _export_rhs_to_cl_image{ false };
Ramy Elgammal2b6ebfe2023-03-09 21:15:37 +000067};
68} // namespace kernels
69} // namespace opencl
70} // namespace arm_compute
Jakub Sujak1ed6a142023-04-13 21:14:42 +010071#endif /* ACL_SRC_GPU_CL_KERNELS_CLMATMULNATIVEKERNEL */