blob: fa555c2c2ede01b5566aedd54575c18cad1478ab [file] [log] [blame]
Manuel Bottini053e7512018-12-28 15:05:20 +00001/*
Yair Schwarzbaum9e8a7702021-11-08 10:58:06 +02002 * Copyright (c) 2018-2021 Arm Limited.
Manuel Bottini053e7512018-12-28 15:05:20 +00003 *
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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_NERANGEKERNEL_H
25#define ARM_COMPUTE_NERANGEKERNEL_H
Manuel Bottini053e7512018-12-28 15:05:20 +000026
Manuel Bottini053e7512018-12-28 15:05:20 +000027#include "arm_compute/core/Types.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Michalis Spyrouebcebf12020-10-21 00:04:14 +010029#include "src/core/NEON/INEKernel.h"
Manuel Bottini053e7512018-12-28 15:05:20 +000030
31namespace arm_compute
32{
33class ITensor;
34
35/** Kernel class for Range
36 *
37 * range generates a 1-D tensor containing a sequence of numbers that begins at 'start' and extends by increments
38 * of 'step' up to but not including 'end'.
39 */
40class NERangeKernel : public INEKernel
41{
42public:
43 const char *name() const override
44 {
45 return "NERangeKernel";
46 }
47 /** Default constructor */
48 NERangeKernel();
49 /** Prevent instances of this class from being copied (As this class contains pointers) */
50 NERangeKernel(const NERangeKernel &) = delete;
51 /** Prevent instances of this class from being copied (As this class contains pointers) */
52 NERangeKernel &operator=(const NERangeKernel &) = delete;
53 /** Allow instances of this class to be moved */
54 NERangeKernel(NERangeKernel &&) = default;
55 /** Allow instances of this class to be moved */
56 NERangeKernel &operator=(NERangeKernel &&) = default;
57 /** Default destructor */
58 ~NERangeKernel() = default;
59 /** Initialize the kernel's output tensor, start, end and step of the sequence.
60 *
61 * @param[out] output Output tensor. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32.
62 * @param[in] start The starting value of the sequence.
63 * @param[in] end The ending (not including) value of the sequence.
64 * @param[in] step The gap between each pair of values in the sequence.
65 */
66 void configure(ITensor *output, float start, float end, float step);
67 /** Static function to check if given info will lead to a valid configuration of @ref NERangeKernel
68 *
69 * @param[in] output Output tensor info. Data types supported: U8/S8/U16/S16/U32/S32/F16/F32.
70 * @param[in] start The starting value of the sequence.
71 * @param[in] end The ending (not including) value of the sequence.
72 * @param[in] step The gap between each pair of values in the sequence.
73 *
74 * @return a status
75 */
76 static Status validate(const ITensorInfo *output, float start, float end, float step);
77
78 // Inherited methods overridden:
79 void run(const Window &window, const ThreadInfo &info) override;
80
81private:
82 using RangeFunction = void(ITensor *output, float start, float step, const Window &window);
83
Yair Schwarzbaum9e8a7702021-11-08 10:58:06 +020084 float _start; /**< Start of sequence */
85 float _end; /**< End of sequence */
86 float _step; /**< Increment/step value */
87 ITensor *_output; /**< Destination tensor */
Manuel Bottini053e7512018-12-28 15:05:20 +000088};
89} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000090#endif /* ARM_COMPUTE_NERANGEKERNEL_H */