Compute Library
 21.02
NEArgMinMaxLayer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-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_NEARGMINMAXLAYER_H
25 #define ARM_COMPUTE_NEARGMINMAXLAYER_H
26 
28 
29 #include "arm_compute/core/Types.h"
32 
33 namespace arm_compute
34 {
35 class ITensor;
36 
37 /** Function to calculate the index of the minimum or maximum values in a
38  * tensor based on an axis.
39  *
40  * This function calls the following Neon kernels:
41  *
42  * -# @ref NEReductionOperationKernel
43  * -# @ref NEFillBorderKernel
44  *
45  * @note The default data type for an uninitialized output tensor is
46  * signed 32-bit integer (S32). It is the user's responsibility to check
47  * that the results do not overflow because the indices are computed
48  * in unsigned 32-bit (U32).
49  */
51 {
52 public:
53  /** Constructor */
54  NEArgMinMaxLayer(std::shared_ptr<IMemoryManager> memory_manager = nullptr);
55  /** Prevent instances of this class from being copied (As this class contains pointers) */
56  NEArgMinMaxLayer(const NEArgMinMaxLayer &) = delete;
57  /** Prevent instances of this class from being copied (As this class contains pointers) */
58  NEArgMinMaxLayer &operator=(const NEArgMinMaxLayer &) = delete;
59  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
61  /** Prevent instances of this class from being moved (As this class contains non movable objects) */
63  /** Default destructor */
65  /** Set the input and output tensors.
66  *
67  * @param[in] input Input source tensor. Data types supported: QASYMM8_SIGNED/QASYMM8/S32/F16/F32.
68  * @param[in] axis Axis to find max/min index.
69  * @param[out] output Output source tensor. Data types supported: U32/S32.
70  * @param[in] op Operation to perform: min or max
71  */
72  void configure(ITensor *input, int axis, ITensor *output, const ReductionOperation &op);
73  /** Static function to check if given info will lead to a valid configuration of @ref NEArgMinMaxLayer
74  *
75  * @param[in] input Input source tensor info. Data types supported: QASYMM8_SIGNED/QASYMM8/S32/F16/F32.
76  * @param[in] axis Axis to find max/min index.
77  * @param[in] output Output source tensor info. Data types supported: U32/S32.
78  * @param[in] op Operation to perform: min or max
79  *
80  * @return a status
81  */
82  static Status validate(const ITensorInfo *input, int axis, const ITensorInfo *output, const ReductionOperation &op);
83 
84  // Inherited methods overridden:
85  void run() override;
86 
87 private:
88  std::unique_ptr<NEReductionOperation> _reduction_function;
89 };
90 } // namespace arm_compute
91 #endif /* ARM_COMPUTE_NEARGMINMAXLAYER_H */
Base class for all functions.
Definition: IFunction.h:30
ReductionOperation
Available reduction operations.
Definition: Types.h:521
static Status validate(const ITensorInfo *input, int axis, const ITensorInfo *output, const ReductionOperation &op)
Static function to check if given info will lead to a valid configuration of NEArgMinMaxLayer.
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Interface for Neon tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
Function to calculate the index of the minimum or maximum values in a tensor based on an axis...
void configure(ITensor *input, int axis, ITensor *output, const ReductionOperation &op)
Set the input and output tensors.
~NEArgMinMaxLayer()
Default destructor.
void run() override
Run the kernels contained in the function.
NEArgMinMaxLayer & operator=(const NEArgMinMaxLayer &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
NEArgMinMaxLayer(std::shared_ptr< IMemoryManager > memory_manager=nullptr)
Constructor.