transpose.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 "ngraph/axis_vector.hpp"
20 #include "ngraph/node.hpp"
21 #include "ngraph/op/op.hpp"
22 
23 namespace ngraph
24 {
25  namespace op
26  {
27  namespace v1
28  {
29  /// \brief Tensor transpose operation.
30  class NGRAPH_API Transpose : public Op
31  {
32  public:
33  NGRAPH_RTTI_DECLARATION;
34 
35  Transpose() = default;
36  ///
37  /// \brief Constructs a transpose operation.
38  ///
39  /// \param arg Node producing the tensor to be transposed.
40  /// \param input_order Node producing the permutation to apply to the axes
41  /// of the input shape. Must be a vector with shape [n],
42  /// where n is the rank of arg. The tensor's value must
43  /// contain every integer in the range [0, n-1].
44  ///
45  Transpose(const Output<Node>& arg, const Output<Node>& input_order);
46 
47  bool visit_attributes(AttributeVisitor& visitor) override;
48  void validate_and_infer_types() override;
49 
50  virtual std::shared_ptr<Node>
51  clone_with_new_inputs(const OutputVector& new_args) const override;
52 
53  bool evaluate(const HostTensorVector& outputs,
54  const HostTensorVector& inputs) const override;
55  };
56  }
57  using v1::Transpose;
58  }
59 }
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
Tensor transpose operation.
Definition: transpose.hpp:31
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.
Transpose(const Output< Node > &arg, const Output< Node > &input_order)
Constructs a transpose operation.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28