Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 1 | /* |
Matthew Bentham | f1aeab9 | 2023-05-30 13:35:34 +0000 | [diff] [blame] | 2 | * Copyright (c) 2021, 2023 Arm Limited. |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 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_CL_ADD_H |
| 25 | #define ARM_COMPUTE_CL_ADD_H |
| 26 | |
SiCong Li | 9129549 | 2023-07-21 18:16:13 +0100 | [diff] [blame^] | 27 | #include "arm_compute/function_info/ActivationLayerInfo.h" |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 28 | #include "src/gpu/cl/ClCompileContext.h" |
| 29 | #include "src/gpu/cl/IClOperator.h" |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 30 | |
| 31 | namespace arm_compute |
| 32 | { |
| 33 | namespace opencl |
| 34 | { |
| 35 | /** Basic function to run arithmetic addition |
| 36 | * |
| 37 | * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 38 | * @note The function performs an arithmetic addition between two tensors. |
| 39 | */ |
| 40 | class ClAdd : public IClOperator |
| 41 | { |
| 42 | public: |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 43 | /** Configure function for a given list of arguments. |
| 44 | * |
| 45 | * Valid configurations (src1,src2) -> dst : |
| 46 | * |
| 47 | * - (U8,U8) -> U8 |
| 48 | * - (U8,U8) -> S16 |
| 49 | * - (S16,U8) -> S16 |
| 50 | * - (U8,S16) -> S16 |
| 51 | * - (S16,S16) -> S16 |
| 52 | * - (S32,S32) -> S32 |
| 53 | * - (F16,F16) -> F16 |
| 54 | * - (F32,F32) -> F32 |
| 55 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 56 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 57 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 58 | * |
| 59 | * @param[in] compile_context The compile context to be used. |
Michele Di Giorgio | 4cfab18 | 2021-01-25 11:49:03 +0000 | [diff] [blame] | 60 | * @param[in, out] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 61 | * The source tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | 4cfab18 | 2021-01-25 11:49:03 +0000 | [diff] [blame] | 62 | * @param[in, out] src2 Second source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 63 | * The source tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
Michele Di Giorgio | 4cfab18 | 2021-01-25 11:49:03 +0000 | [diff] [blame] | 64 | * @param[out] dst Destination tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 65 | * @param[in] policy Policy to use to handle overflow. |
| 66 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 67 | */ |
| 68 | void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, ConvertPolicy policy, |
| 69 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 70 | /** Static function to check if given info will lead to a valid configuration |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 71 | * |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 72 | * Similar to @ref ClAdd::configure() |
Michele Di Giorgio | 1e0208a | 2021-01-22 15:42:59 +0000 | [diff] [blame] | 73 | * |
| 74 | * @return a status |
| 75 | */ |
| 76 | static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, ConvertPolicy policy, |
| 77 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 78 | }; |
| 79 | } // namespace opencl |
| 80 | } // namespace arm_compute |
| 81 | #endif /* ARM_COMPUTE_CL_ADD_H */ |