blob: 2b310329319ad465d87128074d62b257b08c6d98 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgio9428a182020-03-30 14:10:20 +01002 * Copyright (c) 2016-2020 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +01003 *
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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_NEPIXELWISEMULTIPLICATION_H
25#define ARM_COMPUTE_NEPIXELWISEMULTIPLICATION_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/Types.h"
28#include "arm_compute/runtime/NEON/INESimpleFunction.h"
29
30namespace arm_compute
31{
32class ITensor;
33
34/** Basic function to run @ref NEPixelWiseMultiplicationKernel */
35class NEPixelWiseMultiplication : public INESimpleFunction
36{
37public:
38 /** Initialise the kernel's inputs, output and convertion policy.
39 *
Manuel Bottini79fa9a22019-02-22 17:54:22 +000040 * @note For @p scale equal to 1/255 only round to nearest even (implemented as round half up) is supported.
41 * For all other scale values only round to zero (implemented as round towards minus infinity) is supported.
42 *
Pablo Tello52ea9c22019-12-10 11:28:53 +000043 * @param[in, out] input1 An input tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32
Manuel Bottini79fa9a22019-02-22 17:54:22 +000044 * This input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
Pablo Tello52ea9c22019-12-10 11:28:53 +000045 * @param[in, out] input2 An input tensor. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), QASYMM8_SIGNED (only if @p input1 is QASYMM8_SIGNED), S16, QSYMM16 (only if @p input1 is QSYMM16), F16 (only if @p input1 is F16), F32 (only if @p input1 is F32).
Manuel Bottini79fa9a22019-02-22 17:54:22 +000046 * This input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
Michele Di Giorgio9428a182020-03-30 14:10:20 +010047 * @param[out] output Output tensor. Data types supported:
48 * - U8, only if both inputs are U8.
49 * - QASYMM8, only if both inputs are QASYMM8.
50 * - QASYMM8_SIGNED, only if @p input1 is QASYMM8_SIGNED.
51 * - S16.
52 * - QSYMM16, only if both inputs are QSYMM16.
53 * - S32, only if both inputs are QSYMM16.
54 * - F16, only if @p input1 is F16.
55 * - F32, only if both inputs are F32.
Michalis Spyrou861f0db2018-02-26 16:47:58 +000056 * @param[in] scale Scale to apply after multiplication.
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010057 * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
Pablo Tello52ea9c22019-12-10 11:28:53 +000058 * @param[in] overflow_policy Overflow policy. ConvertPolicy cannot be WRAP if datatype is QASYMM8, QASYMM8_SIGNED or QSYMM16.
Michalis Spyrou861f0db2018-02-26 16:47:58 +000059 * @param[in] rounding_policy Rounding policy.
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000060 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010061 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000062 void configure(ITensor *input1, ITensor *input2, ITensor *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
63 const ActivationLayerInfo &act_info = ActivationLayerInfo());
Ioan-Cristian Szabo754e9522017-11-28 18:29:43 +000064 /** Static function to check if given info will lead to a valid configuration of @ref NEPixelWiseMultiplication
65 *
Manuel Bottini79fa9a22019-02-22 17:54:22 +000066 * @note For @p scale equal to 1/255 only round to nearest even (implemented as round half up) is supported.
67 * For all other scale values only round to zero (implemented as round towards minus infinity) is supported.
68 *
Pablo Tello52ea9c22019-12-10 11:28:53 +000069 * @param[in] input1 An input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32
70 * @param[in] input2 An input tensor info. Data types supported: U8, QASYMM8 (only if @p input1 is QASYMM8), QASYMM8_SIGNED (only if @p input1 is QASYMM8_SIGNED), S16, QSYMM16 (only if both inputs are QSYMM16), F16 (only if @p input1 is F16), F32 (only if @p input1 is F32).
Michele Di Giorgio9428a182020-03-30 14:10:20 +010071 * @param[in] output Output tensor info. Data types supported:
72 * - U8, only if both inputs are U8.
73 * - QASYMM8, only if both inputs are QASYMM8.
74 * - QASYMM8_SIGNED, only if @p input1 is QASYMM8_SIGNED.
75 * - S16.
76 * - QSYMM16, only if both inputs are QSYMM16.
77 * - S32, only if both inputs are QSYMM16.
78 * - F16, only if @p input1 is F16.
79 * - F32, only if both inputs are F32.
Manuel Bottini79fa9a22019-02-22 17:54:22 +000080 * @param[in] scale Scale to apply after multiplication.
81 * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
Pablo Tello52ea9c22019-12-10 11:28:53 +000082 * @param[in] overflow_policy Overflow policy. ConvertPolicy cannot be WRAP if datatype is QASYMM8, QASYMM8_SIGNED or QSYMM16.
Ioan-Cristian Szabo754e9522017-11-28 18:29:43 +000083 * @param[in] rounding_policy Rounding policy.
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000084 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
Ioan-Cristian Szabo754e9522017-11-28 18:29:43 +000085 *
Georgios Pinitas631c41a2017-12-06 11:53:03 +000086 * @return a status
Ioan-Cristian Szabo754e9522017-11-28 18:29:43 +000087 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000088 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy,
89 const ActivationLayerInfo &act_info = ActivationLayerInfo());
Anthony Barbier6ff3b192017-09-04 18:44:23 +010090};
giuros01154bc1c2019-03-26 17:44:40 +000091
92/** Basic function to run @ref NEComplexPixelWiseMultiplicationKernel. */
93class NEComplexPixelWiseMultiplication : public INESimpleFunction
94{
95public:
96 /** Initialise the kernel's inputs, output.
97 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +000098 * @param[in, out] input1 An input tensor. Data types supported: F32. Number of channels supported: 2 (complex tensor).
99 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
100 * @param[in, out] input2 An input tensor. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
101 * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
102 * @param[out] output The output tensor. Data types supported: same as @p input1. Number of channels: same as @p input1.
103 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros01154bc1c2019-03-26 17:44:40 +0000104 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000105 void configure(ITensor *input1, ITensor *input2, ITensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01154bc1c2019-03-26 17:44:40 +0000106 /** Static function to check if given info will lead to a valid configuration of @ref NEComplexPixelWiseMultiplication
107 *
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000108 * @param[in] input1 An input tensor info. Data types supported: F32. Number of channels supported: 2 (complex tensor).
109 * @param[in] input2 An input tensor info. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
110 * @param[in] output The output tensor info. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
111 * @param[in] act_info (Optional) Activation layer information in case of a fused activation. Currently not supported.
giuros01154bc1c2019-03-26 17:44:40 +0000112 */
Giorgio Arena8b2a7d32020-02-11 17:21:31 +0000113 static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
giuros01154bc1c2019-03-26 17:44:40 +0000114};
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100115}
Michalis Spyrouf4643372019-11-29 16:17:13 +0000116#endif /*ARM_COMPUTE_NEPIXELWISEMULTIPLICATION_H */