Gian Marco Iodice | 06b184a | 2017-08-29 16:05:25 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 | |
| 25 | #ifndef __ARM_COMPUTE_NEMINMAXLAYERKERNEL_H__ |
| 26 | #define __ARM_COMPUTE_NEMINMAXLAYERKERNEL_H__ |
| 27 | |
| 28 | #include "arm_compute/core/NEON/INEKernel.h" |
Pablo Tello | 9e40cf7 | 2017-09-15 16:14:55 +0100 | [diff] [blame] | 29 | #include "support/Mutex.h" |
Gian Marco Iodice | 06b184a | 2017-08-29 16:05:25 +0100 | [diff] [blame] | 30 | |
| 31 | #include <cstdint> |
Gian Marco Iodice | 06b184a | 2017-08-29 16:05:25 +0100 | [diff] [blame] | 32 | |
| 33 | namespace arm_compute |
| 34 | { |
| 35 | class ITensor; |
| 36 | |
| 37 | /** Interface for the kernel to perform min max search on a 3D tensor. */ |
| 38 | class NEMinMaxLayerKernel : public INEKernel |
| 39 | { |
| 40 | public: |
| 41 | /** Default constructor */ |
| 42 | NEMinMaxLayerKernel(); |
| 43 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 44 | NEMinMaxLayerKernel(const NEMinMaxLayerKernel &) = delete; |
| 45 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 46 | NEMinMaxLayerKernel &operator=(const NEMinMaxLayerKernel &) = delete; |
| 47 | /** Allow instances of this class to be moved */ |
| 48 | NEMinMaxLayerKernel(NEMinMaxLayerKernel &&) = default; |
| 49 | /** Allow instances of this class to be moved */ |
| 50 | NEMinMaxLayerKernel &operator=(NEMinMaxLayerKernel &&) = default; |
| 51 | /** Default destructor */ |
| 52 | ~NEMinMaxLayerKernel() = default; |
| 53 | |
| 54 | /** Initialise the kernel's input and outputs. |
| 55 | * |
| 56 | * @note output[0] = minimum |
| 57 | * @note output[1] = maximum |
| 58 | * |
| 59 | * @param[in] input Input tensor with at least 3 dimensions. The dimensions over the third will be interpreted as batches. Data type supported: F32. |
| 60 | * @param[out] output Output tensor with shape [2, batches, ...] which stores the minimum and maximum value for each 3D input tensor. |
| 61 | * The dimensions over the second must match the batched dimensions of the input tensor. Data types supported: F32 |
| 62 | */ |
| 63 | void configure(const ITensor *input, ITensor *output); |
| 64 | /** Resets global minimum and maximum. */ |
| 65 | void reset(); |
| 66 | |
| 67 | // Inherited methods overridden: |
| 68 | void run(const Window &window, const ThreadInfo &info) override; |
| 69 | |
| 70 | private: |
| 71 | void update_min_max(float *out_ptr, float min, float max); |
| 72 | const ITensor *_input; |
| 73 | ITensor *_output; |
Pablo Tello | 9e40cf7 | 2017-09-15 16:14:55 +0100 | [diff] [blame] | 74 | Mutex _mtx; |
Gian Marco Iodice | 06b184a | 2017-08-29 16:05:25 +0100 | [diff] [blame] | 75 | }; |
Gian Marco Iodice | 356f643 | 2017-09-22 11:32:21 +0100 | [diff] [blame] | 76 | } // namespace arm_compute |
Pablo Tello | 9e40cf7 | 2017-09-15 16:14:55 +0100 | [diff] [blame] | 77 | #endif /* __ARM_COMPUTE_NEMINMAXLAYERKERNEL_H__ */ |