blob: 27dd81301041f2cb8f4105a1164433beb9071fd9 [file] [log] [blame]
Vidhya Sudhan Loganathan5e96be72018-12-18 14:17:00 +00001/*
Manuel Bottini053e7512018-12-28 15:05:20 +00002 * Copyright (c) 2018-2019 ARM Limited.
Vidhya Sudhan Loganathan5e96be72018-12-18 14:17:00 +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_CLRANGEKERNEL_H
25#define ARM_COMPUTE_CLRANGEKERNEL_H
Vidhya Sudhan Loganathan5e96be72018-12-18 14:17:00 +000026
27#include "arm_compute/core/CL/ICLKernel.h"
28#include "arm_compute/core/Types.h"
29
30namespace arm_compute
31{
32class ICLTensor;
33
Manuel Bottini053e7512018-12-28 15:05:20 +000034/** Kernel class for Range
Vidhya Sudhan Loganathan5e96be72018-12-18 14:17:00 +000035 *
36 * range generates a 1-D tensor containing a sequence of numbers that begins at 'start' and extends by increments
37 * of 'step' up to but not including 'end'.
38 */
39class CLRangeKernel : public ICLKernel
40{
41public:
42 /** Default constructor */
43 CLRangeKernel();
44 /** Prevent instances of this class from being copied (As this class contains pointers) */
45 CLRangeKernel(const CLRangeKernel &) = delete;
46 /** Prevent instances of this class from being copied (As this class contains pointers) */
47 CLRangeKernel &operator=(const CLRangeKernel &) = delete;
48 /** Allow instances of this class to be moved */
49 CLRangeKernel(CLRangeKernel &&) = default;
50 /** Allow instances of this class to be moved */
51 CLRangeKernel &operator=(CLRangeKernel &&) = default;
52 /** Default destructor */
53 ~CLRangeKernel() = default;
Manuel Bottini053e7512018-12-28 15:05:20 +000054 /** Initialize the kernel's output tensor, start, end and step of the sequence.
Vidhya Sudhan Loganathan5e96be72018-12-18 14:17:00 +000055 *
56 * @param[out] output Output tensor. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32.
57 * @param[in] start The starting value of the sequence.
58 * @param[in] end The ending (not including) value of the sequence.
59 * @param[in] step The gap between each pair of values in the sequence.
60 */
61 void configure(ICLTensor *output, float start, float end, float step);
62 /** Static function to check if given info will lead to a valid configuration of @ref CLRangeKernel
63 *
64 * @param[in] output Output tensor info. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32.
65 * @param[in] start The starting value of the sequence.
66 * @param[in] end The ending (not including) value of the sequence.
67 * @param[in] step The gap between each pair of values in the sequence.
68 *
69 * @return a status
70 */
71 static Status validate(const ITensorInfo *output, float start, float end, float step);
72
73 // Inherited methods overridden:
74 void run(const Window &window, cl::CommandQueue &queue) override;
75
76private:
77 float _start; /**< Start of sequence */
78 float _end; /**< End of sequence */
79 float _step; /**< Increment/step value */
80 ICLTensor *_output; /**< Destination tensor */
81};
82} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000083#endif /* ARM_COMPUTE_CLRANGEKERNEL_H */