1 /* 2 * Copyright (c) 2018-2020 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_CLRANGEKERNEL_H 25 #define ARM_COMPUTE_CLRANGEKERNEL_H 26 27 #include "arm_compute/core/Types.h" 28 #include "src/core/CL/ICLKernel.h" 29 30 namespace arm_compute 31 { 32 class ICLTensor; 33 34 /** Kernel class for Range 35 * 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 */ 39 class CLRangeKernel : public ICLKernel 40 { 41 public: 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; 54 /** Initialize the kernel's output tensor, start, end and step of the sequence. 55 * 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 /** Initialize the kernel's output tensor, start, end and step of the sequence. 63 * 64 * @param[in] compile_context The compile context to be used. 65 * @param[out] output Output tensor. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32. 66 * @param[in] start The starting value of the sequence. 67 * @param[in] end The ending (not including) value of the sequence. 68 * @param[in] step The gap between each pair of values in the sequence. 69 */ 70 void configure(const CLCompileContext &compile_context, ICLTensor *output, float start, float end, float step); 71 /** Static function to check if given info will lead to a valid configuration of @ref CLRangeKernel 72 * 73 * @param[in] output Output tensor info. Data types supported: U8/S8/QASYMM8/U16/S16/U32/S32/F16/F32. 74 * @param[in] start The starting value of the sequence. 75 * @param[in] end The ending (not including) value of the sequence. 76 * @param[in] step The gap between each pair of values in the sequence. 77 * 78 * @return a status 79 */ 80 static Status validate(const ITensorInfo *output, float start, float end, float step); 81 82 // Inherited methods overridden: 83 void run(const Window &window, cl::CommandQueue &queue) override; 84 85 private: 86 float _start; /**< Start of sequence */ 87 float _end; /**< End of sequence */ 88 float _step; /**< Increment/step value */ 89 ICLTensor *_output; /**< Destination tensor */ 90 }; 91 } // namespace arm_compute 92 #endif /* ARM_COMPUTE_CLRANGEKERNEL_H */ 93