Files
openvino/docs/Extensibility_UG/graph_rewrite_pass.md
Ilya Churaev 9da124544a Transformation guide (#10628)
* Fixed some comments about transformations

* Changed transformation guide

* Fixed typo

* Moved transformation doc to extensibility

* Moved images to Extensibility_UG

* Added separate document for each pass

* Added see also section

* Fixed comments
2022-03-01 09:03:59 +03:00

1.5 KiB

OpenVINO Graph Rewrite Pass

ov::pass::GraphRewrite serves for running multiple matcher passes on ov::Model in a single graph traversal. Example:

@snippet src/transformations/template_pattern_transformation.cpp matcher_pass:graph_rewrite

In addition, GraphRewrite handles nodes that were registered by MatcherPasses during their execution. This nodes will be added to the beginning of the sequence with nodes for pattern matching.

Note

: when using ov::pass::Manager temporary GraphRewrite is used to execute single MatcherPass.

GraphRewrite has two algorithms for MatcherPasses execution. First algorithm is straightforward. It applies each MatcherPass in registration order to current node.

graph_rewrite_execution

But it is not really efficient when you have a lot of registered passes. So first of all GraphRewrite checks that all MatcherPass patterns has type-based root node (it means that type of this node is not hidden into predicate). And then creates map from registered MatcherPasses. That helps to avoid additional cost of applying each MatcherPass for each node.

graph_rewrite_efficient_search

Note

: GraphRewrite execution algorithm cannot be set manually and depends only on root nodes registered inside MatcherPasses.

See Also