1 /* 2 * Copyright (c) 2016-2020 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_NEARITHMETICADDITION_H 25 #define ARM_COMPUTE_NEARITHMETICADDITION_H 26 27 #include "arm_compute/core/Types.h" 28 #include "arm_compute/runtime/IFunction.h" 29 #include "arm_compute/runtime/NEON/INEOperator.h" 30 31 namespace arm_compute 32 { 33 class ITensor; 34 35 namespace experimental 36 { 37 /** Basic function to run @ref NEArithmeticAdditionKernel */ 38 class NEArithmeticAddition : public INEOperator 39 { 40 public: 41 /** Constructor */ 42 NEArithmeticAddition() = default; 43 /** Prevent instances of this class from being copied (As this class contains pointers) */ 44 NEArithmeticAddition(const NEArithmeticAddition &) = delete; 45 /** Prevent instances of this class from being copied (As this class contains pointers) */ 46 NEArithmeticAddition &operator=(const NEArithmeticAddition &) = delete; 47 /** Prevent instances of this class from being moved (As this class contains non movable objects) */ 48 NEArithmeticAddition(NEArithmeticAddition &&) = delete; 49 /** Prevent instances of this class from being moved (As this class contains non movable objects) */ 50 NEArithmeticAddition &operator=(NEArithmeticAddition &&) = delete; 51 /** Default destructor */ 52 ~NEArithmeticAddition(); 53 /** Initialise the kernel's inputs, output and conversion policy. 54 * 55 * Valid configurations (Input1,Input2) -> Output : 56 * 57 * - (U8,U8) -> U8 58 * - (U8,U8) -> S16 59 * - (S16,U8) -> S16 60 * - (U8,S16) -> S16 61 * - (S16,S16) -> S16 62 * - (S32,S32) -> S32 63 * - (F16,F16) -> F16 64 * - (F32,F32) -> F32 65 * - (QASYMM8,QASYMM8) -> QASYMM8 66 * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED 67 * - (QSYMM16,QSYMM16) -> QSYMM16 68 * 69 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 70 * @param[in] input2 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 71 * @param[out] output Output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 72 * @param[in] policy Policy to use to handle overflow. 73 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. 74 */ 75 void configure(const ITensorInfo *input1, const ITensorInfo *input2, ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); 76 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticAddition 77 * 78 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 79 * @param[in] input2 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 80 * @param[in] output Output tensor info. Data types supported: U8/SQASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 81 * @param[in] policy Policy to use to handle overflow 82 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. 83 * 84 * @return a status 85 */ 86 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); 87 }; 88 } // namespace experimental 89 90 /** Basic function to run @ref NEArithmeticAdditionKernel */ 91 class NEArithmeticAddition : public IFunction 92 { 93 public: 94 /** Default Constructor */ 95 NEArithmeticAddition(); 96 /** Default Destructor */ 97 ~NEArithmeticAddition(); 98 /** Prevent instances of this class from being copied (As this class contains pointers) */ 99 NEArithmeticAddition(const NEArithmeticAddition &) = delete; 100 /** Default move constructor */ 101 NEArithmeticAddition(NEArithmeticAddition &&); 102 /** Prevent instances of this class from being copied (As this class contains pointers) */ 103 NEArithmeticAddition &operator=(const NEArithmeticAddition &) = delete; 104 /** Default move assignment operator */ 105 NEArithmeticAddition &operator=(NEArithmeticAddition &&); 106 /** Initialise the kernel's inputs, output and conversion policy. 107 * 108 * Valid configurations (Input1,Input2) -> Output : 109 * 110 * - (U8,U8) -> U8 111 * - (U8,U8) -> S16 112 * - (S16,U8) -> S16 113 * - (U8,S16) -> S16 114 * - (S16,S16) -> S16 115 * - (S32,S32) -> S32 116 * - (F16,F16) -> F16 117 * - (F32,F32) -> F32 118 * - (QASYMM8,QASYMM8) -> QASYMM8 119 * - (QASYMM8_SIGNED,QASYMM8_SIGNED) -> QASYMM8_SIGNED 120 * - (QSYMM16,QSYMM16) -> QSYMM16 121 * 122 * @param[in] input1 First tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 123 * @param[in] input2 Second tensor input. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 124 * @param[out] output Output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 125 * @param[in] policy Policy to use to handle overflow. 126 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. 127 */ 128 void configure(const ITensor *input1, const ITensor *input2, ITensor *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); 129 /** Static function to check if given info will lead to a valid configuration of @ref NEArithmeticAddition 130 * 131 * @param[in] input1 First tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 132 * @param[in] input2 Second tensor input info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 133 * @param[in] output Output tensor info. Data types supported: U8/SQASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/S32/F32 134 * @param[in] policy Policy to use to handle overflow 135 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported. 136 * 137 * @return a status 138 */ 139 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ConvertPolicy policy, const ActivationLayerInfo &act_info = ActivationLayerInfo()); 140 141 // Inherited methods overridden: 142 void run() override; 143 144 private: 145 struct Impl; 146 std::unique_ptr<Impl> _impl; 147 }; 148 } // namespace arm_compute 149 #endif /*ARM_COMPUTE_NEARITHMETICADDITION_H */ 150