capture.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/node.hpp"
8 #include "ngraph/pattern/op/pattern.hpp"
9 
10 namespace ngraph
11 {
12  namespace pattern
13  {
14  namespace op
15  {
16  /// Experimental for support of recurrent matches.
17  ///
18  /// Capture adds the pattern value map to a list of pattern value maps and resets
19  /// matches for pattern nodes not in the static node list. The match always succeeds.
20  class NGRAPH_API Capture : public Pattern
21  {
22  public:
23  static constexpr NodeTypeInfo type_info{"patternCapture", 0};
24  const NodeTypeInfo& get_type_info() const override;
25  Capture(const Output<Node>& arg)
26  : Pattern({arg})
27  {
28  set_output_type(0, arg.get_element_type(), arg.get_partial_shape());
29  }
30 
31  /// \brief static nodes are retained after a capture. All other nodes are dropped
32  std::set<Node*> get_static_nodes() { return m_static_nodes; }
33  void set_static_nodes(const std::set<Node*>& static_nodes)
34  {
35  m_static_nodes = static_nodes;
36  }
37 
38  virtual bool match_value(pattern::Matcher* matcher,
39  const Output<Node>& pattern_value,
40  const Output<Node>& graph_value) override;
41 
42  protected:
43  std::set<Node*> m_static_nodes;
44  };
45  } // namespace op
46  } // namespace pattern
47 } // namespace ngraph
A handle for one of a node's outputs.
Definition: node_output.hpp:33
Definition: matcher.hpp:63
Definition: capture.hpp:21
std::set< Node * > get_static_nodes()
static nodes are retained after a capture. All other nodes are dropped
Definition: capture.hpp:32
const NodeTypeInfo & get_type_info() const override
Definition: pattern.hpp:73
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27