matmul.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 "ngraph/node.hpp"
20 #include "ngraph/op/op.hpp"
21 #include "ngraph/op/util/fused_op.hpp"
22 
23 NGRAPH_SUPPRESS_DEPRECATED_START
24 
25 namespace ngraph
26 {
27  namespace op
28  {
29  namespace v0
30  {
31  /// \brief Operator performing Matrix Multiplication.
32  class NGRAPH_API MatMul : public ngraph::op::util::FusedOp
33  {
34  public:
35  NGRAPH_RTTI_DECLARATION;
36  MatMul() = default;
37  /// \brief Constructs an Matrix Multiplication operation.
38  ///
39  /// \param A Matrix A
40  /// \param B Matrix B
41  /// \param transpose_a If matrix A should be transposed.
42  /// \param transpose_b If matrix B should be transposed.
43  MatMul(const Output<Node>& A,
44  const Output<Node>& B,
45  const bool& transpose_a = 0,
46  const bool& transpose_b = 0);
47 
48  bool visit_attributes(AttributeVisitor& visitor) override;
49  virtual void pre_validate_and_infer_types() override;
50 
51  virtual OutputVector decompose_op() const override;
52 
53  virtual std::shared_ptr<Node>
54  clone_with_new_inputs(const OutputVector& new_args) const override;
55 
56  bool evaluate(const HostTensorVector& outputs,
57  const HostTensorVector& inputs) const override;
58 
59  bool get_transpose_a() const { return m_transpose_a; }
60  bool get_transpose_b() const { return m_transpose_b; }
61  private:
62  bool m_transpose_a;
63  bool m_transpose_b;
64  };
65  }
66  using v0::MatMul;
67  } // namespace op
68 } // namespace ngraph
69 
70 NGRAPH_SUPPRESS_DEPRECATED_END
ngraph::op::v0::MatMul
Operator performing Matrix Multiplication.
Definition: matmul.hpp:33
ngraph::op::v0::MatMul::MatMul
MatMul(const Output< Node > &A, const Output< Node > &B, const bool &transpose_a=0, const bool &transpose_b=0)
Constructs an Matrix Multiplication operation.
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