Compute Library
 21.11
NEReductionOperationKernel.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-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_NEREDUCTIONOPERATIONKERNEL_H
25 #define ARM_COMPUTE_NEREDUCTIONOPERATIONKERNEL_H
26 
28 
29 namespace arm_compute
30 {
31 class ITensor;
32 
33 /** Kernel to perform a reduction operation
34  *
35  * @note For ARG_MIN/ARG_MAX reduction, the default data type for an uninitialized
36  * output tensor is signed 32-bit integer (S32). It is the user's responsibility
37  * to check that the results do not overflow because the indices are computed
38  * in unsigned 32-bit (U32).
39  */
41 {
42 public:
43  const char *name() const override
44  {
45  return "NEReductionOperationKernel";
46  }
47  /** Default constructor */
49  /** Prevent instances of this class from being copied (As this class contains pointers) */
51  /** Prevent instances of this class from being copied (As this class contains pointers) */
53  /** Allow instances of this class to be moved */
55  /** Allow instances of this class to be moved */
57  /** Default destructor */
58  ~NEReductionOperationKernel() = default;
59 
60  /** Set the source, destination of the kernel
61  *
62  * @param[in] input Source tensor. Data type supported: QASYMM8_SIGNED/QASYMM8/F16/F32/S32.
63  * @param[out] output Destination tensor.Data types and data layouts supported: same as @p input, S32 for ARG_MIX/ARG_MAX.
64  * Output will have the same number of dimensions as input.
65  * @param[in] axis Axis along which to reduce. Supported reduction axis : 0
66  * @param[in] op Reduction operation to perform.
67  */
68  void configure(const ITensor *input, ITensor *output, unsigned int axis, ReductionOperation op);
69 
70  /** Static function to check if given info will lead to a valid configuration of @ref NEReductionOperationKernel.
71  *
72  * @param[in] input Source tensor info. Data type supported: QASYMM8_SIGNED/QASYMM8/F16/F32/S32.
73  * @param[in] output Destination tensor info.Data types and data layouts supported: same as @p input, S32 for ARG_MIX/ARG_MAX.
74  * Output will have the same number of dimensions as input.
75  * @param[in] axis Axis along which to reduce. Supported reduction axis : 0
76  * @param[in] op Reduction operation to perform.
77  *
78  * @return a status
79  */
80  static Status validate(const ITensorInfo *input, const ITensorInfo *output, unsigned int axis, ReductionOperation op);
81 
82  // Inherited methods overridden:
83  void run(const Window &window, const ThreadInfo &info) override;
84 
85 private:
86  const ITensor *_input;
87  ITensor *_output;
88  unsigned int _reduction_axis;
90 };
91 } // namespace arm_compute
92 #endif /*ARM_COMPUTE_NEREDUCTIONOPERATIONKERNEL_H */
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
ReductionOperation
Available reduction operations.
Definition: Types.h:463
Common interface for all kernels implemented in C++.
Definition: ICPPKernel.h:38
Store the tensor's metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Interface for CPU tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, unsigned int axis, ReductionOperation op)
Static function to check if given info will lead to a valid configuration of NEReductionOperationKern...
const char * name() const override
Name of the kernel.
Kernel to perform a reduction operation.
void configure(const ITensor *input, ITensor *output, unsigned int axis, ReductionOperation op)
Set the source, destination of the kernel.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
Definition: CPPTypes.h:158
~NEReductionOperationKernel()=default
Default destructor.
NEReductionOperationKernel & operator=(const NEReductionOperationKernel &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
Describe a multidimensional execution window.
Definition: Window.h:39