Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +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_ELEMENTWISE_OPERATIONS_H |
| 25 | #define ARM_COMPUTE_CL_ELEMENTWISE_OPERATIONS_H |
| 26 | |
Georgios Pinitas | 7891a73 | 2021-08-20 21:39:25 +0100 | [diff] [blame] | 27 | #include "src/gpu/cl/ClCompileContext.h" |
| 28 | #include "src/gpu/cl/IClOperator.h" |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 29 | |
| 30 | namespace arm_compute |
| 31 | { |
| 32 | namespace opencl |
| 33 | { |
| 34 | /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for division |
| 35 | * |
| 36 | * @note The tensor data type for the inputs must be F16/F32. |
| 37 | * @note The function performs an arithmetic division between two tensors. |
| 38 | */ |
| 39 | class ClElementwiseDivision : public IClOperator |
| 40 | { |
| 41 | public: |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 42 | /** Configure function for a given list of arguments. |
| 43 | * |
| 44 | * @param[in] compile_context The compile context to be used. |
| 45 | * @param[in] src1 First source tensor info. Data types supported: F16/F32. |
| 46 | * @param[in] src2 Second source tensor info. same as @p src1. |
| 47 | * @param[out] dst Destination tensor info. Data types supported: same as @p src1. |
| 48 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 49 | */ |
| 50 | void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 51 | /** Static function to check if given info will lead to a valid configuration |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 52 | * |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 53 | * Similar to @ref ClElementwiseDivision::configure() |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 54 | * |
| 55 | * @return a status |
| 56 | */ |
| 57 | static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 58 | }; |
| 59 | |
| 60 | /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for max |
| 61 | * |
| 62 | * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32. |
| 63 | * @note The function performs a max operation between two tensors. |
| 64 | */ |
| 65 | class ClElementwiseMax : public IClOperator |
| 66 | { |
| 67 | public: |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 68 | /** Configure function for a given list of arguments. |
| 69 | * |
| 70 | * @param[in] compile_context The compile context to be used. |
| 71 | * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
| 72 | * @param[in] src2 Second source tensor info. Data types supported: same as @p src1. |
| 73 | * @param[out] dst Destination tensor info. Data types supported: same as @p src1. |
| 74 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 75 | */ |
| 76 | void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 77 | /** Static function to check if given info will lead to a valid configuration |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 78 | * |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 79 | * Similar to @ref ClElementwiseMax::configure() |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 80 | * |
| 81 | * @return a status |
| 82 | */ |
| 83 | static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 84 | }; |
| 85 | |
| 86 | /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for min |
| 87 | * |
| 88 | * @note The tensor data type for the inputs must be U8/QASYMM8/S16/QSYMM16/S32/U32/F16/F32. |
| 89 | * @note The function performs a max operation between two tensors. |
| 90 | */ |
| 91 | class ClElementwiseMin : public IClOperator |
| 92 | { |
| 93 | public: |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 94 | /** Configure function for a given list of arguments. |
| 95 | * |
| 96 | * @param[in] compile_context The compile context to be used. |
| 97 | * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/S32/U32/F16/F32. |
| 98 | * @param[in] src2 Second source tensor info. Data types supported: same as @p src1. |
| 99 | * @param[out] dst Destination tensor info. Data types supported: same as @p src1. |
| 100 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 101 | */ |
| 102 | void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 103 | /** Static function to check if given info will lead to a valid configuration |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 104 | * |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 105 | * Similar to @ref ClElementwiseMin::configure() |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 106 | * |
| 107 | * @return a status |
| 108 | */ |
| 109 | static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 110 | }; |
| 111 | |
| 112 | /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for squared difference |
| 113 | * |
| 114 | * @note The tensor data type for the inputs must be QASYMM8/U8/S16/QSYMM16/F16/F32. |
| 115 | * @note The function performs a squared different operation between two tensors (i.e., out[i] = (in1[i] - in2[i])^2 |
| 116 | */ |
| 117 | class ClElementwiseSquaredDiff : public IClOperator |
| 118 | { |
| 119 | public: |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 120 | /** Configure function for a given list of arguments. |
| 121 | * |
| 122 | * @param[in] compile_context The compile context to be used. |
| 123 | * @param[in] src1 First source tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32. |
| 124 | * @param[in] src2 Second source tensor info. Data types supported: same as @p src1. |
| 125 | * @param[out] dst Destination tensor info. Data types supported: same as @p src1. |
| 126 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 127 | */ |
| 128 | void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 129 | /** Static function to check if given info will lead to a valid configuration |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 130 | * |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 131 | * Similar to @ref ClElementwiseSquaredDiff::configure() |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 132 | * |
| 133 | * @return a status |
| 134 | */ |
| 135 | static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 136 | }; |
| 137 | |
| 138 | /** Basic function to run @ref opencl::kernels::ClArithmeticKernel for power |
| 139 | * |
| 140 | * @note The tensor data type for the inputs must be F16/F32. |
| 141 | * @note The function performs an elementwise power of in1 to in2 (i.e., out[i] = in1[i] ^ in2[i]) |
| 142 | */ |
| 143 | class ClElementwisePower : public IClOperator |
| 144 | { |
| 145 | public: |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 146 | /** Configure function for a given list of arguments. |
| 147 | * |
| 148 | * @param[in] compile_context The compile context to be used. |
| 149 | * @param[in] src1 First source tensor info. Data types supported: F16/F32. |
| 150 | * @param[in] src2 Second source tensor info. Data types supported: F16/F32. |
| 151 | * @param[out] dst Destination tensor info. Data types supported:F16/F32. |
| 152 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
| 153 | */ |
| 154 | void configure(const ClCompileContext &compile_context, ITensorInfo *src1, ITensorInfo *src2, ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 155 | /** Static function to check if given info will lead to a valid configuration |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 156 | * |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 157 | * Similar to @ref ClElementwisePower::configure() |
Michele Di Giorgio | 237be03 | 2021-01-25 15:44:02 +0000 | [diff] [blame] | 158 | * |
| 159 | * @return a status |
| 160 | */ |
| 161 | static Status validate(const ITensorInfo *src1, const ITensorInfo *src2, const ITensorInfo *dst, const ActivationLayerInfo &act_info = ActivationLayerInfo()); |
| 162 | }; |
| 163 | } // namespace opencl |
| 164 | } // namespace arm_compute |
| 165 | #endif /* ARM_COMPUTE_CL_ELEMENTWISE_OPERATIONS_H */ |