blob: 1cf5bcacec157afe0b987bd8c6982886c906332f [file] [log] [blame]
Georgios Pinitas77589b52018-08-21 14:41:35 +01001/*
Giorgio Arena4a95bba2021-06-28 11:00:27 +01002 * Copyright (c) 2018-2021 Arm Limited.
Georgios Pinitas77589b52018-08-21 14:41:35 +01003 *
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_CL_STRIDED_SLICE_KERNEL_H
25#define ARM_COMPUTE_CL_STRIDED_SLICE_KERNEL_H
Georgios Pinitas77589b52018-08-21 14:41:35 +010026
Georgios Pinitas77589b52018-08-21 14:41:35 +010027#include "arm_compute/core/Types.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010029#include "src/core/CL/ICLKernel.h"
Georgios Pinitas77589b52018-08-21 14:41:35 +010030
31#include <cstdint>
32
33namespace arm_compute
34{
Georgios Pinitas77589b52018-08-21 14:41:35 +010035/** Interface for the kernel to perform tensor strided slicing */
36class CLStridedSliceKernel : public ICLKernel
37{
38public:
Giorgio Arena4a95bba2021-06-28 11:00:27 +010039 /** Default constructor */
40 CLStridedSliceKernel();
41
Manuel Bottini4c6bd512020-04-08 10:15:51 +010042 /** Configure kernel
43 *
44 * @note Supported tensor rank: up to 4
45 *
46 * @param[in] compile_context The compile context to be used.
Michalis Spyrouf20d6d62020-07-16 17:46:51 +010047 * @param[in] input Source tensor info. Data type supported: All.
48 * @param[out] output Destination tensor info. Data type supported: Same as @p input
Manuel Bottini4c6bd512020-04-08 10:15:51 +010049 * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
50 * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
51 * @param[in] strides The strides of the dimensions of the input tensor to be sliced. The length must be of rank(input).
52 * @param[in] begin_mask If the ith bit of begin_mask is set, starts[i] is ignored and the fullest possible range in that dimension is used instead.
53 * @param[in] end_mask If the ith bit of end_mask is set, ends[i] is ignored and the fullest possible range in that dimension is used instead.
54 * @param[in] shrink_axis_mask If the ith bit of shrink_axis_mask is set, it implies that the ith specification shrinks the dimensionality by 1.
55 * A slice of size 1 starting from starts[i] in the dimension must be preserved.
56 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010057 void configure(const CLCompileContext &compile_context,
58 const ITensorInfo *input,
59 ITensorInfo *output,
60 const Coordinates &starts,
61 const Coordinates &ends,
62 const BiStrides &strides,
63 int32_t begin_mask,
64 int32_t end_mask,
65 int32_t shrink_axis_mask);
Georgios Pinitas77589b52018-08-21 14:41:35 +010066
67 /** Static function to check if given info will lead to a valid configuration of @ref CLStridedSliceKernel
68 *
69 * @note Supported tensor rank: up to 4
70 *
Manuel Bottini8481d832019-12-10 15:28:40 +000071 * @param[in] input Source tensor. Data type supported: All.
Georgios Pinitas77589b52018-08-21 14:41:35 +010072 * @param[in] output Destination tensor. Data type supported: Same as @p input
73 * @param[in] starts The starts of the dimensions of the input tensor to be sliced. The length must be of rank(input).
74 * @param[in] ends The ends of the dimensions of the input tensor to be sliced. The length must be of rank(input).
75 * @param[in] strides The strides of the dimensions of the input tensor to be sliced. The length must be of rank(input).
76 * @param[in] begin_mask If the ith bit of begin_mask is set, starts[i] is ignored and the fullest possible range in that dimension is used instead.
77 * @param[in] end_mask If the ith bit of end_mask is set, ends[i] is ignored and the fullest possible range in that dimension is used instead.
78 * @param[in] shrink_axis_mask If the ith bit of shrink_axis_mask is set, it implies that the ith specification shrinks the dimensionality by 1.
79 * A slice of size 1 starting from starts[i] in the dimension must be preserved.
80 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010081 static Status validate(const ITensorInfo *input,
82 const ITensorInfo *output,
83 const Coordinates &starts,
84 const Coordinates &ends,
85 const BiStrides &strides,
86 int32_t begin_mask,
87 int32_t end_mask,
88 int32_t shrink_axis_mask);
Georgios Pinitas77589b52018-08-21 14:41:35 +010089
90 // Inherited methods overridden:
Georgios Pinitas0499dff2020-07-31 22:21:38 +010091 void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
Georgios Pinitas77589b52018-08-21 14:41:35 +010092};
93} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000094#endif /*ARM_COMPUTE_CL_STRIDED_SLICE_KERNEL_H */