concat.hpp
1 //*****************************************************************************
2 // Copyright 2017-2020 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 
21 #include "ngraph/op/op.hpp"
22 
23 namespace ngraph
24 {
25  namespace op
26  {
27  namespace v0
28  {
29  /// \brief Concatenation operation.
30  class NGRAPH_API Concat : public Op
31  {
32  public:
33  NGRAPH_RTTI_DECLARATION;
34 
35  /// \brief Constructs a concatenation operation.
36  Concat() = default;
37  /// \brief Constructs a concatenation operation.
38  ///
39  /// \param args The outputs producing the input tensors.
40  /// \param axis The axis along which to concatenate the input tensors.
41  Concat(const OutputVector& args, int64_t axis);
42 
43  /// \brief Constructs a concatenation operation.
44  ///
45  /// \param args The nodes producing the input tensors.
46  /// \param axis The axis along which to concatenate the input tensors.
47  Concat(const NodeVector& args, int64_t axis);
48 
49  bool visit_attributes(AttributeVisitor& visitor) override;
50  void validate_and_infer_types() override;
51 
52  virtual std::shared_ptr<Node>
53  clone_with_new_inputs(const OutputVector& new_args) const override;
54 
55  /// \return The concatenation axis.
56  int64_t get_concatenation_axis() const { return m_concat_axis; }
57  void set_concatenation_axis(int64_t concatenation_axis)
58  {
59  m_concat_axis = concatenation_axis;
60  }
61  /// \return The concatenation axis.
62  int64_t get_axis() const { return m_axis; }
63  void set_axis(int64_t axis) { m_axis = axis; }
64  bool evaluate(const HostTensorVector& outputs,
65  const HostTensorVector& inputs) const override;
66 
67  protected:
68  /// \ brief m_axis stores default value for all iterations
69  int64_t m_axis;
70  /// \brief m_concat_axis stores m_axis plus the number of rank for each iteration
71  int64_t m_concat_axis = -1;
72  };
73  }
74  using v0::Concat;
75  }
76 }
ngraph::op::v0::Concat
Concatenation operation.
Definition: concat.hpp:31
ngraph::op::v0::Concat::m_axis
int64_t m_axis
\ brief m_axis stores default value for all iterations
Definition: concat.hpp:69
ngraph::op::v0::Concat::validate_and_infer_types
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
ngraph::op::v0::Concat::get_axis
int64_t get_axis() const
Definition: concat.hpp:62
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::v0::Concat::Concat
Concat()=default
Constructs a concatenation operation.
ngraph::op::v0::Concat::Concat
Concat(const NodeVector &args, int64_t axis)
Constructs a concatenation operation.
ngraph::op::v0::Concat::Concat
Concat(const OutputVector &args, int64_t axis)
Constructs a concatenation operation.
ngraph::op::v0::Concat::get_concatenation_axis
int64_t get_concatenation_axis() const
Definition: concat.hpp:56
ngraph::op::Op
Root of all actual ops.
Definition: op.hpp:29