Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [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 | */ |
Jakub Sujak | 1ed6a14 | 2023-04-13 21:14:42 +0100 | [diff] [blame] | 24 | #ifndef ACL_SRC_GPU_CL_KERNELS_CLMATMULNATIVEKERNEL |
| 25 | #define ACL_SRC_GPU_CL_KERNELS_CLMATMULNATIVEKERNEL |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 26 | |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 27 | #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 | |
| 32 | namespace arm_compute |
| 33 | { |
| 34 | namespace opencl |
| 35 | { |
| 36 | namespace kernels |
| 37 | { |
Jakub Sujak | 1ed6a14 | 2023-04-13 21:14:42 +0100 | [diff] [blame] | 38 | class ClMatMulNativeKernel : public IClKernel |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 39 | { |
| 40 | public: |
Jakub Sujak | 1ed6a14 | 2023-04-13 21:14:42 +0100 | [diff] [blame] | 41 | ClMatMulNativeKernel(); |
| 42 | ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClMatMulNativeKernel); |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 43 | /** Initialise the kernel's input and output. |
| 44 | * |
Mohammed Suhail Munshi | 94abde4 | 2023-05-25 16:48:43 +0100 | [diff] [blame] | 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. |
| 50 | * @param[out] dst Output tensor info. Data type supported: same as @p lhs |
| 51 | * @param[in] matmul_kernel_info Attributes for Batch MatMul Kernel |
| 52 | * @param[in] act_info Specifies activation function to use after Matrix multiplication. Default is Identity function. |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 53 | */ |
Mohammed Suhail Munshi | 94abde4 | 2023-05-25 16:48:43 +0100 | [diff] [blame] | 54 | void configure(const ClCompileContext &compile_context, ITensorInfo *lhs, ITensorInfo *rhs, ITensorInfo *dst, const MatMulKernelInfo &matmul_kernel_info, |
| 55 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 56 | /** Static function to check if given info will lead to a valid configuration |
| 57 | * |
Jakub Sujak | 1ed6a14 | 2023-04-13 21:14:42 +0100 | [diff] [blame] | 58 | * Similar to @ref ClMatMulNativeKernel::configure() |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 59 | * |
| 60 | * @return a status |
| 61 | */ |
Mohammed Suhail Munshi | 94abde4 | 2023-05-25 16:48:43 +0100 | [diff] [blame] | 62 | static Status validate(const ITensorInfo *lhs, const ITensorInfo *rhs, const ITensorInfo *dst, const MatMulKernelInfo &matmul_kernel_info, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 63 | |
| 64 | // Inherited methods overridden: |
| 65 | void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override; |
Gunes Bayir | bbeef72 | 2023-03-20 10:19:10 +0000 | [diff] [blame] | 66 | |
| 67 | private: |
Ramy Elgammal | f26ea2f | 2023-03-24 11:42:03 +0000 | [diff] [blame] | 68 | bool _export_rhs_to_cl_image{ false }; |
Ramy Elgammal | 2b6ebfe | 2023-03-09 21:15:37 +0000 | [diff] [blame] | 69 | }; |
| 70 | } // namespace kernels |
| 71 | } // namespace opencl |
| 72 | } // namespace arm_compute |
Jakub Sujak | 1ed6a14 | 2023-04-13 21:14:42 +0100 | [diff] [blame] | 73 | #endif /* ACL_SRC_GPU_CL_KERNELS_CLMATMULNATIVEKERNEL */ |