blob: 6086bc9d524638392db17cccc3eb3b9a016b281e [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 */
69 void configure(const CLCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, float scale,
70 ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010071 /** Static function to check if given info will lead to a valid configuration
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000072 *
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010073 * Similar to @ref ClMul::configure()
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000074 *
75 * @return a status
76 */
77 static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, float scale,
78 ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000079};
80
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010081/** Basic function to run @ref opencl::kernels::ClComplexMulKernel */
82class ClComplexMul : public IClOperator
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000083{
84public:
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000085 /** Initialise the kernel's sources, dst.
86 *
87 * @param[in] compile_context The compile context to be used.
88 * @param[in, out] src1 An src tensor info. Data types supported: F16/F32. Number of channels supported: 2.
89 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
90 * @param[in, out] src2 An src tensor info. Data types supported: same as @p src1. Number of channels supported: same as @p src1.
91 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
92 * @param[out] dst The dst tensor info, Data types supported: same as @p src1. Number of channels supported: same as @p src1.
93 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
94 */
95 void configure(const CLCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010096 /** Static function to check if given info will lead to a valid configuration
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000097 *
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010098 * Similar to @ref ClComplexMul::configure()
99 *
100 * @return a status
Sheri Zhangf9ab9f92021-03-16 12:09:15 +0000101 */
102 static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sheri Zhangf9ab9f92021-03-16 12:09:15 +0000103};
104} // namespace opencl
105} // namespace arm_compute
Matthew Benthamf1aeab92023-05-30 13:35:34 +0000106#endif /* ARM_COMPUTE_CL_MUL_H */