blob: 6a158c910d81c9d485a91aed7ca2466b9454dc9a [file] [log] [blame]
Sheri Zhangf9ab9f92021-03-16 12:09:15 +00001/*
2 * Copyright (c) 2021 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 */
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
Georgios Pinitas7891a732021-08-20 21:39:25 +010027#include "src/gpu/cl/ClCompileContext.h"
28#include "src/gpu/cl/IClOperator.h"
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000029
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000030namespace arm_compute
31{
32namespace opencl
33{
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010034/** Basic function to run @ref opencl::kernels::ClMulKernel */
35class ClMul : public IClOperator
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000036{
37public:
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000038 /** Initialise the kernel's sources, dst and convertion policy.
39 *
40 * Valid configurations (src1,src2) -> Output :
41 *
42 * - (U8,U8) -> U8
43 * - (U8,U8) -> S16
44 * - (U8,S16) -> S16
45 * - (S16,U8) -> S16
46 * - (S16,S16) -> S16
47 * - (F16,F16) -> F16
48 * - (F32,F32) -> F32
49 * - (QASYMM8,QASYMM8) -> QASYMM8
50 * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
51 * - (QSYMM16,QSYMM16) -> QSYMM16
52 * - (QSYMM16,QSYMM16) -> S32
53 *
54 * @param[in] compile_context The compile context to be used.
55 * @param[in, out] src1 An src tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
56 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
57 * @param[in, out] src2 An src tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
58 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
59 * @param[out] dst The dst tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
60 * @param[in] scale Scale to apply after multiplication.
61 * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
62 * @param[in] overflow_policy Overflow policy. Supported overflow policies: Wrap, Saturate
63 * @param[in] rounding_policy Rounding policy. Supported rounding modes: to zero, to nearest even.
64 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
65 */
66 void configure(const CLCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, float scale,
67 ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010068 /** Static function to check if given info will lead to a valid configuration
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000069 *
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010070 * Similar to @ref ClMul::configure()
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000071 *
72 * @return a status
73 */
74 static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, float scale,
75 ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000076};
77
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010078/** Basic function to run @ref opencl::kernels::ClComplexMulKernel */
79class ClComplexMul : public IClOperator
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000080{
81public:
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000082 /** Initialise the kernel's sources, dst.
83 *
84 * @param[in] compile_context The compile context to be used.
85 * @param[in, out] src1 An src tensor info. Data types supported: F16/F32. Number of channels supported: 2.
86 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
87 * @param[in, out] src2 An src tensor info. Data types supported: same as @p src1. Number of channels supported: same as @p src1.
88 * The src tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
89 * @param[out] dst The dst tensor info, Data types supported: same as @p src1. Number of channels supported: same as @p src1.
90 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
91 */
92 void configure(const CLCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010093 /** Static function to check if given info will lead to a valid configuration
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000094 *
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +010095 * Similar to @ref ClComplexMul::configure()
96 *
97 * @return a status
Sheri Zhangf9ab9f92021-03-16 12:09:15 +000098 */
99 static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Sheri Zhangf9ab9f92021-03-16 12:09:15 +0000100};
101} // namespace opencl
102} // namespace arm_compute
Georgios Pinitas0dc0d8e2021-04-30 03:18:37 +0100103#endif /* ARM_COMPUTE_CL_MUL_H */