Gunes Bayir | 9d0c4de | 2023-04-13 18:22:58 +0100 | [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 | */ |
| 24 | #ifndef ACL_SRC_GPU_CL_KERNELS_CLMATMULLOWPNATIVEKERNEL |
| 25 | #define ACL_SRC_GPU_CL_KERNELS_CLMATMULLOWPNATIVEKERNEL |
| 26 | |
SiCong Li | 9129549 | 2023-07-21 18:16:13 +0100 | [diff] [blame] | 27 | #include "arm_compute/function_info/ActivationLayerInfo.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame^] | 28 | |
Gunes Bayir | 9d0c4de | 2023-04-13 18:22:58 +0100 | [diff] [blame] | 29 | #include "src/core/common/Macros.h" |
| 30 | #include "src/gpu/cl/ClCompileContext.h" |
| 31 | #include "src/gpu/cl/IClKernel.h" |
| 32 | |
| 33 | namespace arm_compute |
| 34 | { |
| 35 | // Forward declerations |
| 36 | struct MatMulKernelInfo; |
| 37 | namespace opencl |
| 38 | { |
| 39 | namespace kernels |
| 40 | { |
| 41 | class ClMatMulLowpNativeKernel : public IClKernel |
| 42 | { |
| 43 | public: |
| 44 | ClMatMulLowpNativeKernel(); |
| 45 | ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClMatMulLowpNativeKernel); |
| 46 | /** Initialise the kernel's input and output. |
| 47 | * |
Mohammed Suhail Munshi | 94abde4 | 2023-05-25 16:48:43 +0100 | [diff] [blame] | 48 | * @param[in] compile_context The compile context to be used. |
Mohammed Suhail Munshi | 8e2dede | 2023-06-27 14:25:58 +0100 | [diff] [blame] | 49 | * @param[in] lhs Input tensor info for the LHS matrix. Data type supported: QASYMM8_SIGNED/QASYMM8. |
Mohammed Suhail Munshi | 94abde4 | 2023-05-25 16:48:43 +0100 | [diff] [blame] | 50 | * Dimensions above 2 are collapsed onto dimension 2 and represent the batch. |
Mohammed Suhail Munshi | 8e2dede | 2023-06-27 14:25:58 +0100 | [diff] [blame] | 51 | * @param[in] rhs Input tensor info for the RHS matrix. Data type supported: same as @p lhs. |
Mohammed Suhail Munshi | 94abde4 | 2023-05-25 16:48:43 +0100 | [diff] [blame] | 52 | * Dimensions above 2 are collapsed onto dimension 2 and represent the batch. |
Mohammed Suhail Munshi | 8e2dede | 2023-06-27 14:25:58 +0100 | [diff] [blame] | 53 | * @param[in] bias Bias tensor info. Can be nullptr. Data type supported: S32. |
Mohammed Suhail Munshi | 94abde4 | 2023-05-25 16:48:43 +0100 | [diff] [blame] | 54 | * @param[out] dst Output tensor info. Data type supported: same as @p lhs |
| 55 | * @param[in] matmul_kernel_info Attributes for Batch MatMul Kernel |
Mohammed Suhail Munshi | 8e2dede | 2023-06-27 14:25:58 +0100 | [diff] [blame] | 56 | * @param[in] act_info (Optional) Class containing information about fused activation function. |
Gunes Bayir | 9d0c4de | 2023-04-13 18:22:58 +0100 | [diff] [blame] | 57 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame^] | 58 | void configure(const ClCompileContext &compile_context, |
| 59 | ITensorInfo *lhs, |
| 60 | ITensorInfo *rhs, |
| 61 | ITensorInfo *bias, |
| 62 | ITensorInfo *dst, |
| 63 | const MatMulKernelInfo &matmul_kernel_info, |
Mohammed Suhail Munshi | 94abde4 | 2023-05-25 16:48:43 +0100 | [diff] [blame] | 64 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Gunes Bayir | 9d0c4de | 2023-04-13 18:22:58 +0100 | [diff] [blame] | 65 | /** Static function to check if given info will lead to a valid configuration |
| 66 | * |
| 67 | * Similar to @ref ClMatMulLowpNativeKernel::configure() |
| 68 | * |
| 69 | * @return a status |
| 70 | */ |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame^] | 71 | static Status validate(const ITensorInfo *lhs, |
| 72 | const ITensorInfo *rhs, |
| 73 | const ITensorInfo *bias, |
| 74 | const ITensorInfo *dst, |
| 75 | const MatMulKernelInfo &matmul_kernel_info, |
Mohammed Suhail Munshi | 8e2dede | 2023-06-27 14:25:58 +0100 | [diff] [blame] | 76 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Gunes Bayir | 9d0c4de | 2023-04-13 18:22:58 +0100 | [diff] [blame] | 77 | |
| 78 | // Inherited methods overridden: |
| 79 | void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override; |
| 80 | }; |
| 81 | } // namespace kernels |
| 82 | } // namespace opencl |
| 83 | } // namespace arm_compute |
| 84 | #endif /* ACL_SRC_GPU_CL_KERNELS_CLMATMULLOWPNATIVEKERNEL */ |