Michele Di Giorgio | 4cfab18 | 2021-01-25 11:49:03 +0000 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 24 | #ifndef ARM_COMPUTE_CL_SUB_H |
| 25 | #define ARM_COMPUTE_CL_SUB_H |
| 26 | |
| 27 | #include "src/core/gpu/cl/ClCompileContext.h" |
| 28 | #include "src/runtime/gpu/cl/IClOperator.h" |
| 29 | |
| 30 | namespace arm_compute |
| 31 | { |
| 32 | namespace opencl |
| 33 | { |
| 34 | /** Basic function to run arithmetic subtraction |
| 35 | * |
| 36 | * @note The tensor data type for the inputs must be U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 37 | * @note The function performs an arithmetic subtraction between two tensors. |
| 38 | */ |
| 39 | class ClSub : public IClOperator |
| 40 | { |
| 41 | public: |
| 42 | /** Default Constructor */ |
| 43 | ClSub() = default; |
| 44 | /** Configure function for a given list of arguments. |
| 45 | * |
| 46 | * Valid configurations (src1,src2) -> dst : |
| 47 | * |
| 48 | * - (U8,U8) -> U8 |
| 49 | * - (U8,U8) -> S16 |
| 50 | * - (S16,U8) -> S16 |
| 51 | * - (U8,S16) -> S16 |
| 52 | * - (S16,S16) -> S16 |
| 53 | * - (S32,S32) -> S32 |
| 54 | * - (F16,F16) -> F16 |
| 55 | * - (F32,F32) -> F32 |
| 56 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 57 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 58 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 59 | * |
| 60 | * @param[in] compile_context The compile context to be used. |
| 61 | * @param[in, out] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 62 | * The source tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 63 | * @param[in, out] src2 Second source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 64 | * The source tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0. |
| 65 | * @param[out] dst Destination tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 66 | * @param[in] policy Policy to use to handle overflow. |
| 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, ConvertPolicy policy, |
| 70 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 71 | /** Static function to check if given info will lead to a valid configuration of @ref ClSub |
| 72 | * |
| 73 | * Valid configurations (src1,src2) -> dst : |
| 74 | * |
| 75 | * - (U8,U8) -> U8 |
| 76 | * - (U8,U8) -> S16 |
| 77 | * - (S16,U8) -> S16 |
| 78 | * - (U8,S16) -> S16 |
| 79 | * - (S16,S16) -> S16 |
| 80 | * - (S32,S32) -> S32 |
| 81 | * - (F16,F16) -> F16 |
| 82 | * - (F32,F32) -> F32 |
| 83 | * - (QASYMM8,QASYMM8) -> QASYMM8 |
| 84 | * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED |
| 85 | * - (QSYMM16,QSYMM16) -> QSYMM16 |
| 86 | * |
| 87 | * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 88 | * @param[in] src2 Second source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 89 | * @param[in] dst Destination tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/F16/F32. |
| 90 | * @param[in] policy Policy to use to handle overflow. |
| 91 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 92 | * |
| 93 | * @return a status |
| 94 | */ |
| 95 | static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, ConvertPolicy policy, |
| 96 | const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 97 | }; |
| 98 | } // namespace opencl |
| 99 | } // namespace arm_compute |
| 100 | #endif /* ARM_COMPUTE_CL_SUB_H */ |