blob: 1cf4d68d4cd953490ee448e0528cfd5a1321ec43 [file] [log] [blame]
Sheri Zhangf9ab9f92021-03-16 12:09:15 +00001/*
Matthew Benthamf1aeab92023-05-30 13:35:34 +00002 * Copyright (c) 2021, 2023 Arm Limited.
Sheri Zhangf9ab9f92021-03-16 12:09:15 +00003 *
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 */
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010024#ifndef ARM_COMPUTE_CL_MUL_H
25#define ARM_COMPUTE_CL_MUL_H
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000026
Matthew Benthamf1aeab92023-05-30 13:35:34 +000027#include "arm_compute/core/Types.h"
SiCong Li91295492023-07-21 18:16:13 +010028#include "arm_compute/function_info/ActivationLayerInfo.h"
Matthew Benthamf1aeab92023-05-30 13:35:34 +000029
Georgios Pinitas7891a732021-08-20 21:39:25 +010030#include "src/gpu/cl/ClCompileContext.h"
31#include "src/gpu/cl/IClOperator.h"
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000032
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000033namespace arm_compute
34{
35namespace opencl
36{
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010037/** Basic function to run @ref opencl::kernels::ClMulKernel */
38class ClMul : public IClOperator
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000039{
40public:
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000041 /** Initialise the kernel's sources, dst and convertion policy.
42 *
43 * Valid configurations (src1,src2) -> Output :
44 *
45 * - (U8,U8) -> U8
46 * - (U8,U8) -> S16
47 * - (U8,S16) -> S16
48 * - (S16,U8) -> S16
49 * - (S16,S16) -> S16
50 * - (F16,F16) -> F16
51 * - (F32,F32) -> F32
52 * - (QASYMM8,QASYMM8) -> QASYMM8
53 * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
54 * - (QSYMM16,QSYMM16) -> QSYMM16
55 * - (QSYMM16,QSYMM16) -> S32
56 *
57 * @param[in] compile_context The compile context to be used.
58 * @param[in, out] src1 An src tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
59 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
60 * @param[in, out] src2 An src tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
61 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
62 * @param[out] dst The dst tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
63 * @param[in] scale Scale to apply after multiplication.
64 * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
65 * @param[in] overflow_policy Overflow policy. Supported overflow policies: Wrap, Saturate
66 * @param[in] rounding_policy Rounding policy. Supported rounding modes: to zero, to nearest even.
67 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
68 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010069 void configure(const CLCompileContext &compile_context,
70 ITensorInfo *src1,
71 ITensorInfo *src2,
72 ITensorInfo *dst,
73 float scale,
74 ConvertPolicy overflow_policy,
75 RoundingPolicy rounding_policy,
76 const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010077 /** Static function to check if given info will lead to a valid configuration
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000078 *
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010079 * Similar to @ref ClMul::configure()
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000080 *
81 * @return a status
82 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010083 static Status validate(const ITensorInfo *src1,
84 const ITensorInfo *src2,
85 const ITensorInfo *dst,
86 float scale,
87 ConvertPolicy overflow_policy,
88 RoundingPolicy rounding_policy,
89 const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000090};
91
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010092/** Basic function to run @ref opencl::kernels::ClComplexMulKernel */
93class ClComplexMul : public IClOperator
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000094{
95public:
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000096 /** Initialise the kernel's sources, dst.
97 *
98 * @param[in] compile_context The compile context to be used.
99 * @param[in, out] src1 An src tensor info. Data types supported: F16/F32. Number of channels supported: 2.
100 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
101 * @param[in, out] src2 An src tensor info. Data types supported: same as @p src1. Number of channels supported: same as @p src1.
102 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
103 * @param[out] dst The dst tensor info, Data types supported: same as @p src1. Number of channels supported: same as @p src1.
104 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
105 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100106 void configure(const CLCompileContext &compile_context,
107 ITensorInfo *src1,
108 ITensorInfo *src2,
109 ITensorInfo *dst,
110 const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +0100111 /** Static function to check if given info will lead to a valid configuration
Sheri Zhangf9ab9f92021-03-16 12:09:15 +0000112 *
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +0100113 * Similar to @ref ClComplexMul::configure()
114 *
115 * @return a status
Sheri Zhangf9ab9f92021-03-16 12:09:15 +0000116 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100117 static Status validate(const ITensorInfo *src1,
118 const ITensorInfo *src2,
119 const ITensorInfo *dst,
120 const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sheri Zhangf9ab9f92021-03-16 12:09:15 +0000121};
122} // namespace opencl
123} // namespace arm_compute
Matthew Benthamf1aeab92023-05-30 13:35:34 +0000124#endif /* ARM_COMPUTE_CL_MUL_H */