blob: a36ec7ad6538e434fb5fbacb63bed3a1760d6942 [file] [log] [blame]
Sheri Zhang61243902021-01-12 18:25:16 +00001/*
2 * Copyright (c) 2016-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 */
24#ifndef ARM_COMPUTE_CPUADDKERNEL_H
25#define ARM_COMPUTE_CPUADDKERNEL_H
26
27#include "src/core/common/Macros.h"
28#include "src/core/cpu/ICpuKernel.h"
29
30namespace arm_compute
31{
32namespace cpu
33{
34namespace kernels
35{
36/** Interface for the kernel to perform addition between two tensors */
37class CpuAddKernel : public ICpuKernel
38{
39public:
40 CpuAddKernel() = default;
41 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(CpuAddKernel);
42 /** Initialise the kernel's input, dst and border mode.
43 *
44 * Valid configurations (src0,src1) -> dst :
45 *
46 * - (U8,U8) -> U8
47 * - (U8,U8) -> S16
48 * - (S16,U8) -> S16
49 * - (U8,S16) -> S16
50 * - (S16,S16) -> S16
51 * - (S32,S32) -> S32
52 * - (F16,F16) -> F16
53 * - (F32,F32) -> F32
54 * - (QASYMM8,QASYMM8) -> QASYMM8
55 * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED
56 * - (QSYMM16,QSYMM16) -> QSYMM16
57 *
58 * @param[in] src0 First input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32
59 * @param[in] src1 Second input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32
60 * @param[out] dst The dst tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32.
61 * @param[in] policy Overflow policy.
62 */
63 void configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst, ConvertPolicy policy);
64 /** Static function to check if given info will lead to a valid configuration of @ref CpuAddKernel
65 *
66 * @param[in] src0 First input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32
67 * @param[in] src1 Second input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32
68 * @param[in] dst The dst tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32.
69 * @param[in] policy Overflow policy.
70 *
71 * @return a status
72 */
73 static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst, ConvertPolicy policy);
74
75 // Inherited methods overridden:
76 void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override;
77 const char *name() const override;
78
79private:
80 ConvertPolicy _policy{};
81};
82} // namespace kernels
83} // namespace cpu
84} // namespace arm_compute
85#endif /*ARM_COMPUTE_CPUADDKERNEL_H */