blob: 778176293f09acde0692cf4af2bac9f41775b9f0 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2016, 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#ifndef __ARM_COMPUTE_NETHRESHOLDKERNEL_H__
25#define __ARM_COMPUTE_NETHRESHOLDKERNEL_H__
26
27#include "arm_compute/core/NEON/INEKernel.h"
28#include "arm_compute/core/Types.h"
29
30#include <cstdint>
31
32namespace arm_compute
33{
34class ITensor;
35
36/** Interface for the thresholding kernel
37 *
38 */
39class NEThresholdKernel : public INEKernel
40{
41public:
42 /** Constructor
43 * Initialize all the pointers to nullptr and parameters to zero.
44 */
45 NEThresholdKernel();
46 /** Prevent instances of this class from being copied (As this class contains pointers) */
47 NEThresholdKernel(const NEThresholdKernel &) = delete;
48 /** Prevent instances of this class from being copied (As this class contains pointers) */
49 NEThresholdKernel &operator=(const NEThresholdKernel &) = delete;
50 /** Initialise the kernel's input, output and threshold parameters.
51 *
52 * @param[in] input An input tensor. Data type supported: U8
53 * @param[out] output The output tensor. Data type supported: U8.
54 * @param[in] threshold Threshold. When the threhold type is RANGE, this is used as the lower threshold.
55 * @param[in] false_value value to set when the condition is not respected.
56 * @param[in] true_value value to set when the condition is respected.
57 * @param[in] type Thresholding type. Either RANGE or BINARY.
58 * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE.
59 */
60 void configure(const ITensor *input, ITensor *output, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper);
61
62 // Inherited methods overridden:
63 void run(const Window &window) override;
64
65private:
66 /** run binary thresholding on the given window */
67 void run_binary(const Window &window);
68 /** run range thresholding on the given window */
69 void run_range(const Window &window);
70
71 void (NEThresholdKernel::*_func)(const Window &window);
72
73 const ITensor *_input; /**< Input */
74 ITensor *_output; /**< Output */
75 uint8_t _threshold;
76 uint8_t _false_value;
77 uint8_t _true_value;
78 uint8_t _upper;
79};
80}
81#endif /*__ARM_COMPUTE_NETHRESHOLDKERNEL_H__ */