variadic_split.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/coordinate.hpp"
8 #include "ngraph/op/op.hpp"
9 #include "ngraph/strides.hpp"
10 
11 namespace ngraph
12 {
13  namespace op
14  {
15  namespace v1
16  {
17  /// \brief VariadicSplit operation splits an input tensor into pieces along some axis.
18  /// The pieces may have variadic lengths depending on "split_lengths" attribute.
19  class NGRAPH_API VariadicSplit : public Op
20  {
21  public:
22  NGRAPH_RTTI_DECLARATION;
23 
24  /// \brief Constructs a variadic split operation.
25  VariadicSplit() = default;
26  /// \brief Constructs a variadic split operation.
27  ///
28  /// \param data The tensor to be split.
29  /// \param axis The index of an axis in "data" along which to perform the
30  /// split.
31  /// \param split_lengths A list containing the sizes of each output tensor
32  /// along the split "axis". Size of "split_lengths" should be equal to the number of
33  ///
34  /// outputs. The sum of split_lengths must match data.shape[axis]
36  const Output<Node>& axis,
37  const Output<Node>& split_lengths);
38 
39  bool visit_attributes(AttributeVisitor& visitor) override;
40 
41  void validate_and_infer_types() override;
42  virtual std::shared_ptr<Node>
43  clone_with_new_inputs(const OutputVector& new_args) const override;
44  size_t get_default_output_index() const override { return no_default_index(); }
45  bool evaluate(const HostTensorVector& outputs,
46  const HostTensorVector& inputs) const override;
47  bool has_evaluate() const override;
48 
49  private:
50  bool evaluate_variadic_split(const HostTensorVector& outputs,
51  const HostTensorVector& inputs) const;
52  };
53  } // namespace v1
54 
55  using v1::VariadicSplit;
56  } // namespace op
57 } // namespace ngraph
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:59
A handle for one of a node's outputs.
Definition: node_output.hpp:33
Root of all actual ops.
Definition: op.hpp:17
VariadicSplit operation splits an input tensor into pieces along some axis. The pieces may have varia...
Definition: variadic_split.hpp:20
bool has_evaluate() const override
Allows to get information about availability of evaluate method for the current operation.
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
VariadicSplit()=default
Constructs a variadic split operation.
size_t get_default_output_index() const override
Returns the output of the default output, or throws if there is none.
Definition: variadic_split.hpp:44
VariadicSplit(const Output< Node > &data, const Output< Node > &axis, const Output< Node > &split_lengths)
Constructs a variadic split operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16