Compute Library
 21.11
CLPixelWiseMultiplication.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-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_CLPIXELWISEMULTIPLICATION_H
25 #define ARM_COMPUTE_CLPIXELWISEMULTIPLICATION_H
26 
29 
30 namespace arm_compute
31 {
32 // Forward declaration
33 class CLCompileContext;
34 class ICLTensor;
35 class ITensorInfo;
36 
37 /** Basic function to run @ref opencl::ClMul. */
39 {
40 public:
41  /** Default Constructor */
43  /** Default Destructor */
45  /** Prevent instances of this class from being copied (As this class contains pointers) */
47  /** Default move constructor */
49  /** Prevent instances of this class from being copied (As this class contains pointers) */
51  /** Default move assignment operator */
53  /** Initialise the kernel's inputs, output and convertion policy.
54  *
55  * Valid data layouts:
56  * - All
57  *
58  * Valid data type configurations:
59  * |src0 |src1 |dst |
60  * |:--------------|:--------------|:--------------|
61  * |QASYMM8 |QASYMM8 |QASYMM8 |
62  * |QASYMM8_SIGNED |QASYMM8_SIGNED |QASYMM8_SIGNED |
63  * |QSYMM16 |QSYMM16 |QASYMM16 |
64  * |QSYMM16 |QSYMM16 |S32 |
65  * |U8 |U8 |U8 |
66  * |U8 |U8 |S16 |
67  * |U8 |S16 |S16 |
68  * |S16 |U8 |S16 |
69  * |S16 |S16 |S16 |
70  * |F16 |F16 |F16 |
71  * |F32 |F32 |F32 |
72  * |S32 |S32 |S32 |
73  *
74  * @param[in, out] input1 An input tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32/S32
75  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
76  * @param[in, out] input2 An input tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32/S32
77  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
78  * @param[out] output The output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32/S32
79  * @param[in] scale Scale to apply after multiplication.
80  * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
81  * @param[in] overflow_policy Overflow policy. Supported overflow policies: Wrap, Saturate
82  * @param[in] rounding_policy Rounding policy. Supported rounding modes: to zero, to nearest even.
83  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
84  */
85  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, float scale,
86  ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
87  /** Initialise the kernel's inputs, output and convertion policy.
88  *
89  * @param[in] compile_context The compile context to be used.
90  * @param[in, out] input1 An input tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32/S32
91  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
92  * @param[in, out] input2 An input tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32/S32
93  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
94  * @param[out] output The output tensor. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32/S32
95  * @param[in] scale Scale to apply after multiplication.
96  * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
97  * @param[in] overflow_policy Overflow policy. Supported overflow policies: Wrap, Saturate
98  * @param[in] rounding_policy Rounding policy. Supported rounding modes: to zero, to nearest even.
99  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
100  */
101  void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, float scale,
102  ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
103  /** Static function to check if given info will lead to a valid configuration of @ref CLPixelWiseMultiplication
104  *
105  * @param[in] input1 An input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
106  * @param[in] input2 An input tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
107  * @param[in] output The output tensor info. Data types supported: U8/QASYMM8/QASYMM8_SIGNED/S16/QSYMM16/F16/F32.
108  * @param[in] scale Scale to apply after multiplication.
109  * Scale must be positive and its value must be either 1/255 or 1/2^n where n is between 0 and 15.
110  * @param[in] overflow_policy Overflow policy. Supported overflow policies: Wrap, Saturate
111  * @param[in] rounding_policy Rounding policy. Supported rounding modes: to zero, to nearest even.
112  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
113  *
114  * @return a status
115  */
116  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale,
117  ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info = ActivationLayerInfo());
118 
119  // Inherited methods overridden:
120  void run() override;
121 
122 private:
123  struct Impl;
124  std::unique_ptr<Impl> _impl;
125 };
126 
127 /** Basic function to run @ref opencl::ClComplexMul. */
129 {
130 public:
131  /** Default Constructor */
133  /** Default Destructor */
135  /** Prevent instances of this class from being copied (As this class contains pointers) */
137  /** Default move constructor */
139  /** Prevent instances of this class from being copied (As this class contains pointers) */
141  /** Default move assignment operator */
143  /** Initialise the kernel's inputs, output.
144  *
145  * @param[in, out] input1 An input tensor. Data types supported: F16/F32. Number of channels supported: 2.
146  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
147  * @param[in, out] input2 An input tensor. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
148  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
149  * @param[out] output The output tensor, Data types supported: same as @p input1. Number of channels supported: same as @p input1.
150  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
151  */
152  void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
153  /** Initialise the kernel's inputs, output.
154  *
155  * @param[in] compile_context The compile context to be used.
156  * @param[in, out] input1 An input tensor. Data types supported: F16/F32. Number of channels supported: 2.
157  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
158  * @param[in, out] input2 An input tensor. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
159  * The input tensor is [in, out] because its TensorInfo might be modified inside the kernel in case of broadcasting of dimension 0.
160  * @param[out] output The output tensor, Data types supported: same as @p input1. Number of channels supported: same as @p input1.
161  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
162  */
163  void configure(const CLCompileContext &compile_context, ICLTensor *input1, ICLTensor *input2, ICLTensor *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
164  /** Static function to check if given info will lead to a valid configuration of @ref CLComplexPixelWiseMultiplication
165  *
166  * @param[in] input1 An input tensor info. Data types supported: F16/F32. Number of channels supported: 2.
167  * @param[in] input2 An input tensor info. Data types supported: same as @p input1. Number of channels supported: same as @p input1.
168  * @param[in] output The output tensor info, Data types supported: same as @p input1. Number of channels supported: same as @p input1.
169  * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
170  */
171  static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const ActivationLayerInfo &act_info = ActivationLayerInfo());
172 
173  // Inherited methods overridden:
174  void run() override;
175 
176 private:
177  struct Impl;
178  std::unique_ptr<Impl> _impl;
179 };
180 } // namespace arm_compute
181 #endif /*ARM_COMPUTE_CLPIXELWISEMULTIPLICATION_H */
Base class for all functions.
Definition: IFunction.h:30
void run() override
Run the kernels contained in the function.
Basic function to run opencl::ClComplexMul.
void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Initialise the kernel&#39;s inputs, output and convertion policy.
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
CLPixelWiseMultiplication & operator=(const CLPixelWiseMultiplication &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
Activation Layer Information class.
Definition: Types.h:1509
Copyright (c) 2017-2021 Arm Limited.
RoundingPolicy
Rounding method.
Definition: Rounding.h:30
Basic function to run opencl::ClMul.
CLCompileContext class.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
ConvertPolicy
Policy to handle integer overflow.
Definition: Types.h:391
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration of CLPixelWiseMultiplicatio...
~CLPixelWiseMultiplication()
Default Destructor.