blob: 2eebaf9ee448fca18009f52116cfd290ccfe53b0 [file] [log] [blame]
Gian Marco Iodice06b184a2017-08-29 16:05:25 +01001/*
Michalis Spyrouf4643372019-11-29 16:17:13 +00002 * Copyright (c) 2017-2019 ARM Limited.
Gian Marco Iodice06b184a2017-08-29 16:05:25 +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 */
24
Michalis Spyrouf4643372019-11-29 16:17:13 +000025#ifndef ARM_COMPUTE_NEMINMAXLAYERKERNEL_H
26#define ARM_COMPUTE_NEMINMAXLAYERKERNEL_H
Gian Marco Iodice06b184a2017-08-29 16:05:25 +010027
28#include "arm_compute/core/NEON/INEKernel.h"
Pablo Tello9e40cf72017-09-15 16:14:55 +010029#include "support/Mutex.h"
Gian Marco Iodice06b184a2017-08-29 16:05:25 +010030
31#include <cstdint>
Gian Marco Iodice06b184a2017-08-29 16:05:25 +010032
33namespace arm_compute
34{
35class ITensor;
36
37/** Interface for the kernel to perform min max search on a 3D tensor. */
38class NEMinMaxLayerKernel : public INEKernel
39{
40public:
Anthony Barbiere8a49832018-01-18 10:04:05 +000041 const char *name() const override
42 {
43 return "NEMinMaxLayerKernel";
44 }
Gian Marco Iodice06b184a2017-08-29 16:05:25 +010045 /** Default constructor */
46 NEMinMaxLayerKernel();
47 /** Prevent instances of this class from being copied (As this class contains pointers) */
48 NEMinMaxLayerKernel(const NEMinMaxLayerKernel &) = delete;
49 /** Prevent instances of this class from being copied (As this class contains pointers) */
50 NEMinMaxLayerKernel &operator=(const NEMinMaxLayerKernel &) = delete;
51 /** Allow instances of this class to be moved */
52 NEMinMaxLayerKernel(NEMinMaxLayerKernel &&) = default;
53 /** Allow instances of this class to be moved */
54 NEMinMaxLayerKernel &operator=(NEMinMaxLayerKernel &&) = default;
55 /** Default destructor */
56 ~NEMinMaxLayerKernel() = default;
57
58 /** Initialise the kernel's input and outputs.
59 *
60 * @note output[0] = minimum
61 * @note output[1] = maximum
62 *
63 * @param[in] input Input tensor with at least 3 dimensions. The dimensions over the third will be interpreted as batches. Data type supported: F32.
64 * @param[out] output Output tensor with shape [2, batches, ...] which stores the minimum and maximum value for each 3D input tensor.
65 * The dimensions over the second must match the batched dimensions of the input tensor. Data types supported: F32
66 */
67 void configure(const ITensor *input, ITensor *output);
Alex Gilday60954c62018-03-05 16:22:48 +000068 /** Static function to check if given info will lead to a valid configuration of @ref CLMinMaxLayerKernel
69 *
70 * @param[in] input Input tensor info. Data types supported: F32.
71 * @param[in] output Output tensor info with shape [2, batches, ...] which stores the minimum and maximum values for each 3D input tensor.
72 * The dimensions over the second must match the batched dimensions of the input tensor. Data types supported: F32.
73 *
74 * @return a status
75 */
76 static Status validate(const ITensorInfo *input, const ITensorInfo *output);
Gian Marco Iodice06b184a2017-08-29 16:05:25 +010077 /** Resets global minimum and maximum. */
78 void reset();
79
80 // Inherited methods overridden:
81 void run(const Window &window, const ThreadInfo &info) override;
82
83private:
84 void update_min_max(float *out_ptr, float min, float max);
85 const ITensor *_input;
86 ITensor *_output;
Pablo Tello9e40cf72017-09-15 16:14:55 +010087 Mutex _mtx;
Gian Marco Iodice06b184a2017-08-29 16:05:25 +010088};
Gian Marco Iodice356f6432017-09-22 11:32:21 +010089} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000090#endif /* ARM_COMPUTE_NEMINMAXLAYERKERNEL_H */