matmul.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/node.hpp"
20 #include "ngraph/op/op.hpp"
21 
22 namespace ngraph
23 {
24  namespace op
25  {
26  namespace v0
27  {
28  /// \brief Operator performing Matrix Multiplication.
29  class NGRAPH_API MatMul : public Op
30  {
31  public:
32  NGRAPH_RTTI_DECLARATION;
33  MatMul() = default;
34  /// \brief Constructs an Matrix Multiplication operation.
35  ///
36  /// \param A Matrix A
37  /// \param B Matrix B
38  /// \param transpose_a If matrix A should be transposed.
39  /// \param transpose_b If matrix B should be transposed.
40  MatMul(const Output<Node>& A,
41  const Output<Node>& B,
42  const bool& transpose_a = 0,
43  const bool& transpose_b = 0);
44 
45  bool visit_attributes(AttributeVisitor& visitor) override;
46  void validate_and_infer_types() override;
47 
48  virtual std::shared_ptr<Node>
49  clone_with_new_inputs(const OutputVector& new_args) const override;
50 
51  bool evaluate(const HostTensorVector& outputs,
52  const HostTensorVector& inputs) const override;
53 
54  bool get_transpose_a() const { return m_transpose_a; }
55  bool get_transpose_b() const { return m_transpose_b; }
56  private:
57  bool m_transpose_a;
58  bool m_transpose_b;
59  };
60  }
61  using v0::MatMul;
62  } // namespace op
63 } // namespace ngraph
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
Operator performing Matrix Multiplication.
Definition: matmul.hpp:30
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
MatMul(const Output< Node > &A, const Output< Node > &B, const bool &transpose_a=0, const bool &transpose_b=0)
Constructs an Matrix Multiplication operation.
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28