blob: 2f59fc8bfe6a0c26fa40e8cd17817414e7f6835c [file] [log] [blame]
Georgios Pinitas6d9d6f42018-12-24 16:10:47 +00001/*
Michalis Spyrou1732da82020-06-19 12:40:46 +01002 * Copyright (c) 2018-2020 ARM Limited.
Georgios Pinitas6d9d6f42018-12-24 16:10:47 +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_NE_SLICE_H
25#define ARM_COMPUTE_NE_SLICE_H
Georgios Pinitas6d9d6f42018-12-24 16:10:47 +000026
Michalis Spyrou1732da82020-06-19 12:40:46 +010027#include "arm_compute/runtime/IFunction.h"
28#include "arm_compute/runtime/NEON/INEOperator.h"
Georgios Pinitas6d9d6f42018-12-24 16:10:47 +000029
30namespace arm_compute
31{
32// Forward Declarations
33class ITensor;
34
Michalis Spyrou1732da82020-06-19 12:40:46 +010035namespace experimental
36{
Georgios Pinitas6d9d6f42018-12-24 16:10:47 +000037/** Basic function to perform tensor slicing */
Michalis Spyrou1732da82020-06-19 12:40:46 +010038class NESlice : public INEOperator
Georgios Pinitas6d9d6f42018-12-24 16:10:47 +000039{
40public:
41 /** Configure kernel
42 *
43 * @note Supported tensor rank: up to 4
44 * @note Start indices must be non-negative. 0 <= starts[i]
45 * @note End coordinates can be negative, which represents the number of elements before the end of that dimension.
46 * @note End indices are not inclusive unless negative.
47 *
Michalis Spyrou1732da82020-06-19 12:40:46 +010048 * @param[in] input Source tensor info. Data type supported: All
49 * @param[out] output Destination tensor info. Data type supported: Same as @p input
50 * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
51 * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
52 */
53 void configure(const ITensorInfo *input, ITensorInfo *output, const Coordinates &starts, const Coordinates &ends);
54
55 /** Static function to check if given info will lead to a valid configuration of @ref NESlice
56 *
57 * @note Supported tensor rank: up to 4
58 * @note Start indices must be non-negative. 0 <= starts[i]
59 * @note End coordinates can be negative, which represents the number of elements before the end of that dimension.
60 * @note End indices are not inclusive unless negative.
61 *
62 * @param[in] input Source tensor info. Data type supported: All
63 * @param[in] output Destination tensor info. Data type supported: Same as @p input
64 * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
65 * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
66 *
67 * @return A status
68 */
69 static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends);
70
71 // Inherited methods overridden:
72 MemoryRequirements workspace() const override;
73};
74} // namespace experimental
75
76/** Basic function to perform tensor slicing */
77class NESlice : public IFunction
78{
79public:
80 /** Default Constructor */
81 NESlice();
82 /** Default Destructor */
83 ~NESlice();
84 /** Prevent instances of this class from being copied (As this class contains pointers) */
85 NESlice(const NESlice &) = delete;
86 /** Default move constructor */
87 NESlice(NESlice &&);
88 /** Prevent instances of this class from being copied (As this class contains pointers) */
89 NESlice &operator=(const NESlice &) = delete;
90 /** Default move assignment operator */
91 NESlice &operator=(NESlice &&);
92
93 /** Configure kernel
94 *
95 * @note Supported tensor rank: up to 4
96 * @note Start indices must be non-negative. 0 <= starts[i]
97 * @note End coordinates can be negative, which represents the number of elements before the end of that dimension.
98 * @note End indices are not inclusive unless negative.
99 *
Georgios Pinitas33843562019-12-10 13:33:18 +0000100 * @param[in] input Source tensor. Data type supported: All
Georgios Pinitas6d9d6f42018-12-24 16:10:47 +0000101 * @param[out] output Destination tensor. Data type supported: Same as @p input
102 * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
103 * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
104 */
105 void configure(const ITensor *input, ITensor *output, const Coordinates &starts, const Coordinates &ends);
106
107 /** Static function to check if given info will lead to a valid configuration of @ref NESlice
108 *
109 * @note Supported tensor rank: up to 4
110 * @note Start indices must be non-negative. 0 <= starts[i]
111 * @note End coordinates can be negative, which represents the number of elements before the end of that dimension.
112 * @note End indices are not inclusive unless negative.
113 *
Georgios Pinitas33843562019-12-10 13:33:18 +0000114 * @param[in] input Source tensor info. Data type supported: All
Georgios Pinitas6d9d6f42018-12-24 16:10:47 +0000115 * @param[in] output Destination tensor info. Data type supported: Same as @p input
116 * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
117 * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
118 *
119 * @return A status
120 */
121 static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends);
Michalis Spyrou1732da82020-06-19 12:40:46 +0100122
123 // Inherited methods overridden:
124 void run() override;
125
126private:
127 struct Impl;
128 std::unique_ptr<Impl> _impl;
Georgios Pinitas6d9d6f42018-12-24 16:10:47 +0000129};
130} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000131#endif /* ARM_COMPUTE_NE_SLICE_H */