Debian Codegraph @

arm_compute/runtime/NEON/functions/NEArgMinMaxLayer.h

raw
1 /*
2 * Copyright (c) 2018-2021, 2023-2024 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 ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEARGMINMAXLAYER_H
25 #define ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEARGMINMAXLAYER_H
26
27 #include "arm_compute/core/Types.h"
28 #include "arm_compute/runtime/MemoryGroup.h"
29 #include "arm_compute/runtime/MemoryManagerOnDemand.h"
30 #include "arm_compute/runtime/NEON/INESimpleFunction.h"
31
32 namespace arm_compute
33 {
34 class ITensor;
35 /** Function to calculate the index of the minimum or maximum values in a
36 * tensor based on an axis.
37 *
38 * This function calls the following kernels:
39 *
40 * -# NEReductionOperationKernel
41 * -# NEFillBorderKernel
42 *
43 * @note The default data type for an uninitialized output tensor is
44 * signed 32-bit integer (S32). It is the user's responsibility to check
45 * that the results do not overflow because the indices are computed
46 * in unsigned 32-bit (U32).
47 */
48 class NEArgMinMaxLayer : public IFunction
49 {
50 public:
51 /** Constructor */
52 NEArgMinMaxLayer(std::shared_ptr<IMemoryManager> memory_manager);
53 NEArgMinMaxLayer() : NEArgMinMaxLayer(MemoryManagerOnDemand::make_default())
54 {
55 }
56 /** Prevent instances of this class from being copied (As this class contains pointers) */
57 NEArgMinMaxLayer(const NEArgMinMaxLayer &) = delete;
58 /** Prevent instances of this class from being copied (As this class contains pointers) */
59 NEArgMinMaxLayer &operator=(const NEArgMinMaxLayer &) = delete;
60 /** Prevent instances of this class from being moved (As this class contains non movable objects) */
61 NEArgMinMaxLayer(NEArgMinMaxLayer &&) = delete;
62 /** Prevent instances of this class from being moved (As this class contains non movable objects) */
63 NEArgMinMaxLayer &operator=(NEArgMinMaxLayer &&) = delete;
64 /** Default destructor */
65 ~NEArgMinMaxLayer();
66 /** Set the input and output tensors.
67 *
68 * Valid data layouts:
69 * - All
70 *
71 * Valid data type configurations:
72 * |src |dst |
73 * |:--------------|:-------------|
74 * |QASYMM8 |U32, S32 |
75 * |QASYMM8_SIGNED |U32, S32 |
76 * |S32 |U32, S32, S64 |
77 * |F16 |U32, S32 |
78 * |F32 |U32, S32 |
79 *
80 * @param[in] input Input source tensor. Data types supported: QASYMM8_SIGNED/QASYMM8/S32/F16/F32.
81 * @param[in] axis Axis to find max/min index.
82 * @param[out] output Output source tensor. Data types supported: U32/S32.
83 * @param[in] op Operation to perform: min or max
84 */
85 void configure(ITensor *input, int axis, ITensor *output, const ReductionOperation &op);
86 /** Static function to check if given info will lead to a valid configuration of @ref NEArgMinMaxLayer
87 *
88 * @param[in] input Input source tensor info. Data types supported: QASYMM8_SIGNED/QASYMM8/S32/F16/F32.
89 * @param[in] axis Axis to find max/min index.
90 * @param[in] output Output source tensor info. Data types supported: U32/S32/S64.
91 * @param[in] op Operation to perform: min or max
92 *
93 * @return a status
94 */
95 static Status validate(const ITensorInfo *input, int axis, const ITensorInfo *output, const ReductionOperation &op);
96
97 // Inherited methods overridden:
98 void run() override;
99
100 private:
101 struct Impl;
102 std::unique_ptr<Impl> _impl;
103 };
104 } // namespace arm_compute
105 #endif // ACL_ARM_COMPUTE_RUNTIME_NEON_FUNCTIONS_NEARGMINMAXLAYER_H