split.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include <memory>
8 #include <vector>
9 
10 #include "ngraph/node.hpp"
11 #include "ngraph/op/util/fused_op.hpp"
12 
13 namespace ngraph
14 {
15  namespace op
16  {
17  namespace v1
18  {
19  /// \brief Splits the input tensor into a list of equal sized tensors
20  class NGRAPH_API Split : public ngraph::op::Op
21  {
22  public:
23  NGRAPH_RTTI_DECLARATION;
24 
25  /// \brief Constructs a split operation.
26  Split() = default;
27  /// \brief Constructs a split operation.
28  /// \param data The tensor to be split.
29  /// \param axis The index of an axis in "data" along which to perform
30  /// the split.
31  /// \param num_splits The number of pieces that the data tensor should be
32  /// split into.
33  Split(const Output<Node>& data, const Output<Node>& axis, const size_t num_splits);
34 
35  bool visit_attributes(AttributeVisitor& visitor) override;
36  void validate_and_infer_types() override;
37  virtual std::shared_ptr<Node>
38  clone_with_new_inputs(const OutputVector& new_args) const override;
39 
40  size_t get_num_splits() const { return m_num_splits; }
41  void set_num_splits(const size_t num_splits) { m_num_splits = num_splits; }
42  bool evaluate(const HostTensorVector& outputs,
43  const HostTensorVector& inputs) const override;
44  bool has_evaluate() const override;
45 
46  protected:
47  size_t m_num_splits;
48  };
49  } // namespace v1
50  } // namespace op
51 } // 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
Splits the input tensor into a list of equal sized tensors.
Definition: split.hpp:21
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
Split()=default
Constructs a split operation.
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
bool has_evaluate() const override
Allows to get information about availability of evaluate method for the current operation.
Split(const Output< Node > &data, const Output< Node > &axis, const size_t num_splits)
Constructs a split operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16