Class ov::pass::pattern::Matcher

class Matcher

Matcher looks for node patterns in a computation graph. The patterns are described by an automaton that is described by an extended computation graph. The matcher executes by attempting to match the start node of the pattern to a computation graph value (output of a Node). In addition to determing if a match occurs, a pattern node may add graph nodes to a list of matched nodes, associate nodes with graph values, and start submatches. Submatches add match state changes to the enclosing match if the submatch succeeds; otherwise the state is reverted.

The default match behavior of a pattern node with a graph nodes is that the computation graph value is added to the end of the matched value list and the match succeeds if the node/pattern types match and the input values match. In the case of a commutative node, the inputs can match in any order. If the matcher is in strict mode, the graph value element type and shape must also match.

Pattern nodes that have different match behavior are in ov::pass::pattern::op and have descriptions of their match behavior.

Public Functions

inline Matcher(const Output<Node> &pattern_node, const std::string &name, bool strict_mode)

Constructs a Matcher object.

Parameters
  • pattern_node – is a pattern sub graph that will be matched against input graphs

  • name – is a string which is used for logging and disabling a matcher

  • strict_mode – forces a matcher to consider shapes and ET of nodes

bool match(const Output<Node> &graph_value)

Matches a pattern to graph_node.

Parameters

graph_value – is an input graph to be matched against

bool match(const Output<Node> &graph_value, const PatternMap &previous_matches)

Matches a pattern to graph_node.

Parameters
  • graph_value – is an input graph to be matched against

  • previous_matches – contains previous mappings from labels to nodes to use

size_t add_node(Output<Node> node)

Low-level helper to match recurring patterns.

Parameters
  • graph – is a graph to be matched against

  • pattern – is a recurring pattern

  • rpattern – specifies a node to recur from next

  • patterns – a map from labels to matches

MatcherState start_match()

Try a match.