Georgios Pinitas | 6d9d6f4 | 2018-12-24 16:10:47 +0000 | [diff] [blame] | 1 | /* |
Sheri Zhang | a47dcc2 | 2021-04-22 14:41:12 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 Arm Limited. |
Georgios Pinitas | 6d9d6f4 | 2018-12-24 16:10:47 +0000 | [diff] [blame] | 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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_NE_SLICE_H |
| 25 | #define ARM_COMPUTE_NE_SLICE_H |
Georgios Pinitas | 6d9d6f4 | 2018-12-24 16:10:47 +0000 | [diff] [blame] | 26 | |
Michalis Spyrou | 1732da8 | 2020-06-19 12:40:46 +0100 | [diff] [blame] | 27 | #include "arm_compute/runtime/IFunction.h" |
| 28 | #include "arm_compute/runtime/NEON/INEOperator.h" |
Georgios Pinitas | 6d9d6f4 | 2018-12-24 16:10:47 +0000 | [diff] [blame] | 29 | |
| 30 | namespace arm_compute |
| 31 | { |
| 32 | // Forward Declarations |
| 33 | class ITensor; |
| 34 | |
Michalis Spyrou | 1732da8 | 2020-06-19 12:40:46 +0100 | [diff] [blame] | 35 | /** Basic function to perform tensor slicing */ |
| 36 | class NESlice : public IFunction |
| 37 | { |
| 38 | public: |
| 39 | /** Default Constructor */ |
| 40 | NESlice(); |
| 41 | /** Default Destructor */ |
| 42 | ~NESlice(); |
| 43 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 44 | NESlice(const NESlice &) = delete; |
| 45 | /** Default move constructor */ |
| 46 | NESlice(NESlice &&); |
| 47 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 48 | NESlice &operator=(const NESlice &) = delete; |
| 49 | /** Default move assignment operator */ |
| 50 | NESlice &operator=(NESlice &&); |
| 51 | |
| 52 | /** Configure kernel |
| 53 | * |
Sheri Zhang | a47dcc2 | 2021-04-22 14:41:12 +0100 | [diff] [blame] | 54 | * Valid data layouts: |
| 55 | * - All |
| 56 | * |
| 57 | * Valid data type configurations: |
| 58 | * |src |dst | |
| 59 | * |:------|:------| |
| 60 | * |All |All | |
| 61 | * |
Michalis Spyrou | 1732da8 | 2020-06-19 12:40:46 +0100 | [diff] [blame] | 62 | * @note Supported tensor rank: up to 4 |
| 63 | * @note Start indices must be non-negative. 0 <= starts[i] |
| 64 | * @note End coordinates can be negative, which represents the number of elements before the end of that dimension. |
| 65 | * @note End indices are not inclusive unless negative. |
| 66 | * |
Georgios Pinitas | 3384356 | 2019-12-10 13:33:18 +0000 | [diff] [blame] | 67 | * @param[in] input Source tensor. Data type supported: All |
Georgios Pinitas | 6d9d6f4 | 2018-12-24 16:10:47 +0000 | [diff] [blame] | 68 | * @param[out] output Destination tensor. Data type supported: Same as @p input |
| 69 | * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 70 | * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 71 | */ |
| 72 | void configure(const ITensor *input, ITensor *output, const Coordinates &starts, const Coordinates &ends); |
| 73 | |
| 74 | /** Static function to check if given info will lead to a valid configuration of @ref NESlice |
| 75 | * |
| 76 | * @note Supported tensor rank: up to 4 |
| 77 | * @note Start indices must be non-negative. 0 <= starts[i] |
| 78 | * @note End coordinates can be negative, which represents the number of elements before the end of that dimension. |
| 79 | * @note End indices are not inclusive unless negative. |
| 80 | * |
Georgios Pinitas | 3384356 | 2019-12-10 13:33:18 +0000 | [diff] [blame] | 81 | * @param[in] input Source tensor info. Data type supported: All |
Georgios Pinitas | 6d9d6f4 | 2018-12-24 16:10:47 +0000 | [diff] [blame] | 82 | * @param[in] output Destination tensor info. Data type supported: Same as @p input |
| 83 | * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 84 | * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 85 | * |
| 86 | * @return A status |
| 87 | */ |
| 88 | static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends); |
Michalis Spyrou | 1732da8 | 2020-06-19 12:40:46 +0100 | [diff] [blame] | 89 | |
| 90 | // Inherited methods overridden: |
| 91 | void run() override; |
| 92 | |
| 93 | private: |
| 94 | struct Impl; |
| 95 | std::unique_ptr<Impl> _impl; |
Georgios Pinitas | 6d9d6f4 | 2018-12-24 16:10:47 +0000 | [diff] [blame] | 96 | }; |
Georgios Pinitas | 856f66e | 2021-04-22 21:13:21 +0100 | [diff] [blame^] | 97 | |
| 98 | namespace experimental |
| 99 | { |
| 100 | /** Basic function to perform tensor slicing */ |
| 101 | class NESlice : public INEOperator |
| 102 | { |
| 103 | public: |
| 104 | /** Configure kernel |
| 105 | * |
| 106 | * Valid data layouts: |
| 107 | * - All |
| 108 | * |
| 109 | * Valid data type configurations: |
| 110 | * |src |dst | |
| 111 | * |:------|:------| |
| 112 | * |All |All | |
| 113 | * |
| 114 | * @note Supported tensor rank: up to 4 |
| 115 | * @note Start indices must be non-negative. 0 <= starts[i] |
| 116 | * @note End coordinates can be negative, which represents the number of elements before the end of that dimension. |
| 117 | * @note End indices are not inclusive unless negative. |
| 118 | * |
| 119 | * @param[in] input Source tensor info. Data type supported: All |
| 120 | * @param[out] output Destination tensor info. Data type supported: Same as @p input |
| 121 | * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 122 | * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 123 | */ |
| 124 | void configure(const ITensorInfo *input, ITensorInfo *output, const Coordinates &starts, const Coordinates &ends); |
| 125 | |
| 126 | /** Static function to check if given info will lead to a valid configuration of @ref NESlice |
| 127 | * |
| 128 | * @note Supported tensor rank: up to 4 |
| 129 | * @note Start indices must be non-negative. 0 <= starts[i] |
| 130 | * @note End coordinates can be negative, which represents the number of elements before the end of that dimension. |
| 131 | * @note End indices are not inclusive unless negative. |
| 132 | * |
| 133 | * @param[in] input Source tensor info. Data type supported: All |
| 134 | * @param[in] output Destination tensor info. Data type supported: Same as @p input |
| 135 | * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 136 | * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input). |
| 137 | * |
| 138 | * @return A status |
| 139 | */ |
| 140 | static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends); |
| 141 | }; |
| 142 | } // namespace experimental |
Georgios Pinitas | 6d9d6f4 | 2018-12-24 16:10:47 +0000 | [diff] [blame] | 143 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 144 | #endif /* ARM_COMPUTE_NE_SLICE_H */ |