1 //*****************************************************************************
2 // Copyright 2017-2020 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //*****************************************************************************
19 #include "ngraph/coordinate.hpp"
20 #include "ngraph/op/op.hpp"
21 #include "ngraph/strides.hpp"
29 /// \brief Takes a slice of an input tensor, i.e., the sub-tensor that resides within a
30 /// bounding box, optionally with stride.
31 class NGRAPH_DEPRECATED(
32 "This operation is deprecated and will be removed soon. Please do not use it.")
33 NGRAPH_API Slice : public Op
35 NGRAPH_SUPPRESS_DEPRECATED_START
37 static constexpr NodeTypeInfo type_info{"Slice", 0};
38 const NodeTypeInfo& get_type_info() const override { return type_info; }
39 /// \brief Constructs a tensor slice operation
41 /// \brief Constructs a tensor slice operation.
43 /// \param arg The tensor to be sliced.
44 /// \param lower_bounds The axiswise lower bounds of the slice (inclusive).
45 /// \param upper_bounds The axiswise upper bounds of the slice (exclusive).
46 /// \param strides The slicing strides; for example, strides of `{n,m}` means to
48 /// every nth row and every mth column of the input matrix.
49 Slice(const Output<Node>& arg,
50 const Coordinate& lower_bounds,
51 const Coordinate& upper_bounds,
52 const Strides& strides);
53 /// \brief Constructs a tensor slice operation with unit strides; i.e., every
55 /// inside the bounding box will be copied to the output slice.
57 /// \param arg The tensor to be sliced.
58 /// \param lower_bounds The axiswise lower bounds of the slice (inclusive).
59 /// \param upper_bounds The axiswise upper bounds of the slice (exclusive).
60 Slice(const Output<Node>& arg,
61 const Coordinate& lower_bounds,
62 const Coordinate& upper_bounds);
64 virtual std::shared_ptr<Node>
65 clone_with_new_inputs(const OutputVector& new_args) const override;
66 void validate_and_infer_types() override;
68 /// \return The inclusive lower-bound coordinates.
69 const Coordinate& get_lower_bounds() const { return m_lower_bounds; }
70 /// \return The exclusive upper-bound coordinates.
71 const Coordinate& get_upper_bounds() const { return m_upper_bounds; }
72 /// \return The slicing strides.
73 const Strides& get_strides() const { return m_strides; }
74 bool evaluate(const HostTensorVector& outputs,
75 const HostTensorVector& inputs) const override;
78 Coordinate m_lower_bounds;
79 Coordinate m_upper_bounds;
81 NGRAPH_SUPPRESS_DEPRECATED_END
84 // default opset version
85 NGRAPH_SUPPRESS_DEPRECATED_START
87 NGRAPH_SUPPRESS_DEPRECATED_END