Compute Library
 21.05
NESlice.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2021 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_NE_SLICE_H
25 #define ARM_COMPUTE_NE_SLICE_H
26 
29 
30 namespace arm_compute
31 {
32 // Forward Declarations
33 class ITensor;
34 
35 namespace experimental
36 {
37 /** Basic function to perform tensor slicing */
38 class NESlice : public INEOperator
39 {
40 public:
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  *
48  * @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 } // namespace experimental
72 
73 /** Basic function to perform tensor slicing */
74 class NESlice : public IFunction
75 {
76 public:
77  /** Default Constructor */
78  NESlice();
79  /** Default Destructor */
80  ~NESlice();
81  /** Prevent instances of this class from being copied (As this class contains pointers) */
82  NESlice(const NESlice &) = delete;
83  /** Default move constructor */
84  NESlice(NESlice &&);
85  /** Prevent instances of this class from being copied (As this class contains pointers) */
86  NESlice &operator=(const NESlice &) = delete;
87  /** Default move assignment operator */
89 
90  /** Configure kernel
91  *
92  * Valid data layouts:
93  * - All
94  *
95  * Valid data type configurations:
96  * |src |dst |
97  * |:------|:------|
98  * |All |All |
99  *
100  * @note Supported tensor rank: up to 4
101  * @note Start indices must be non-negative. 0 <= starts[i]
102  * @note End coordinates can be negative, which represents the number of elements before the end of that dimension.
103  * @note End indices are not inclusive unless negative.
104  *
105  * @param[in] input Source tensor. Data type supported: All
106  * @param[out] output Destination tensor. Data type supported: Same as @p input
107  * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
108  * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
109  */
110  void configure(const ITensor *input, ITensor *output, const Coordinates &starts, const Coordinates &ends);
111 
112  /** Static function to check if given info will lead to a valid configuration of @ref NESlice
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[in] 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  * @return A status
125  */
126  static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends);
127 
128  // Inherited methods overridden:
129  void run() override;
130 
131 private:
132  struct Impl;
133  std::unique_ptr<Impl> _impl;
134 };
135 } // namespace arm_compute
136 #endif /* ARM_COMPUTE_NE_SLICE_H */
NESlice & operator=(const NESlice &)=delete
Prevent instances of this class from being copied (As this class contains pointers)
Base class for all functions.
Definition: IFunction.h:30
Basic interface for functions which have a single async CPU kernel.
Definition: INEOperator.h:43
Basic function to perform tensor slicing.
Definition: NESlice.h:74
Basic function to perform tensor slicing.
Definition: NESlice.h:38
Store the tensor's metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Interface for CPU tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
void configure(const ITensor *input, ITensor *output, const Coordinates &starts, const Coordinates &ends)
Configure kernel.
Definition: NESlice.cpp:85
~NESlice()
Default Destructor.
Coordinates of an item.
Definition: Coordinates.h:37
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends)
Static function to check if given info will lead to a valid configuration of NESlice.
Definition: NESlice.cpp:48
NESlice()
Default Constructor.
Definition: NESlice.cpp:72
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Coordinates &starts, const Coordinates &ends)
Static function to check if given info will lead to a valid configuration of NESlice.
Definition: NESlice.cpp:80
void run() override
Run the kernels contained in the function.
Definition: NESlice.cpp:93
void configure(const ITensorInfo *input, ITensorInfo *output, const Coordinates &starts, const Coordinates &ends)
Configure kernel.
Definition: NESlice.cpp:36