split.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 Intel Corporation
3 //
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
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
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 //*****************************************************************************
16 
17 #pragma once
18 
19 #include <memory>
20 #include <vector>
21 
22 #include "ngraph/node.hpp"
23 #include "ngraph/op/util/fused_op.hpp"
24 
25 namespace ngraph
26 {
27  namespace op
28  {
29  namespace v1
30  {
31  /// \brief Splits the input tensor into a list of equal sized tensors
32  class NGRAPH_API Split : public ngraph::op::Op
33  {
34  public:
35  NGRAPH_RTTI_DECLARATION;
36 
37  /// \brief Constructs a split operation.
38  Split() = default;
39  /// \brief Constructs a split operation.
40  /// \param data The tensor to be split.
41  /// \param axis The index of an axis in "data" along which to perform
42  /// the split.
43  /// \param num_splits The number of pieces that the data tensor should be
44  /// split into.
45  Split(const Output<Node>& data, const Output<Node>& axis, const size_t num_splits);
46 
47  bool visit_attributes(AttributeVisitor& visitor) override;
48  void validate_and_infer_types() override;
49  virtual std::shared_ptr<Node>
50  clone_with_new_inputs(const OutputVector& new_args) const override;
51 
52  size_t get_num_splits() const { return m_num_splits; }
53  void set_num_splits(const size_t num_splits) { m_num_splits = num_splits; }
54  bool evaluate(const HostTensorVector& outputs,
55  const HostTensorVector& inputs) const override;
56 
57  protected:
58  size_t m_num_splits;
59  };
60  }
61  }
62 }
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:71
A handle for one of a node's outputs.
Definition: node_output.hpp:42
Root of all actual ops.
Definition: op.hpp:29
Splits the input tensor into a list of equal sized tensors.
Definition: split.hpp:33
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....
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:28