class ov::pass::GraphRewrite


GraphRewrite is a container for MatcherPasses that allows to run them on Function in efficient way. More…

#include <graph_rewrite.hpp>

class GraphRewrite: public ov::pass::ModelPass
    // construction


    // methods

    "ov::pass::GraphRewrite" OPENVINO_RTTI();

    template <, , , >
    std::shared_ptr<T>Args&&... add_matcher();

    template <, , >
    voidArgs&&... add_matcher();

    std::shared_ptr<MatcherPass>const std::shared_ptr<MatcherPass>& add_matcher();
    virtual boolconst std::shared_ptr<ov::Model>& run_on_model();
    virtual voidconst std::shared_ptr<PassConfig>& set_pass_config();

// direct descendants

class BackwardGraphRewrite;
class BidirectionalSequenceDecomposition;
class CompressFloatConstants;
class ConcatReduceFusion;
class ConvertNmsGatherPathToUnsigned;
class ConvertReduceToPooling;
class ConvertReduceToReshape;
class ConvertSequenceToTensorIterator;
class ConvertTensorIteratorToSequence;
class FuseFilteringBoxesBySize;
class GeluFusion;
class HSigmoidFusion;
class HSwishFusion;
class InitMasks;
class LinOpSequenceFusion;
class MVNFusion;
class NopElimination;
class PReluFusion;
class PadFusion;
class PropagateMasks;
class PullThroughReduce;
class SwishFusion;
class TransposeSinking;
class TypeRelaxedReplacer;
class TSGeneralBackward;
class TSGeneralForward;

Inherited Members

    // typedefs

    typedef DiscreteTypeInfo type_info_t;

    // methods

    boolconst PassPropertyMask& get_property() const;
    voidconst std::string& set_name();
    std::string get_name() const;
    voidconst param_callback& set_callback();
    virtual voidconst std::shared_ptr<PassConfig>& set_pass_config();
    std::shared_ptr<PassConfig> get_pass_config();
    boolconst std::shared_ptr<const Node>& transformation_callback();
    virtual const type_info_t& get_type_info() const = 0;
    "ov::pass::ModelPass" OPENVINO_RTTI();
    virtual boolconst std::shared_ptr<ov::Model>& run_on_model() = 0;

Detailed Documentation

GraphRewrite is a container for MatcherPasses that allows to run them on Function in efficient way.

Graph rewrite pass is used for matcher passes execution on Function. To register MatcherPass use

See also:

add_matcher<T>(args) method where T is a MatcherPass class. As a default algorithm graph rewrite pass traverse Function in topological order and applies registered matcher passes for each node. But if all registered matcher passes have type based root node in Matcher pattern then efficient mechanism is used to execute them. Matcher pattern root is type based if it’s operation from opset or pattern::op::WrapType. Note: when implementing pattern for Matcher make sure that root node is an operation from opset or has ov::pattern::op::WrapType. That will help GraphRewrite to execute matcher passes more efficient.


template <, , , >
std::shared_ptr<T>Args&&... add_matcher()

Register given transformation class type to GraphRewrite execution list All registered transformations will be executed in a single graph traversal. Example below show the basic usage of pass::GraphRewrite.

pass::Manager manager;
auto anchor = manager.register_pass<GraphRewrite>();

For some purposes transformation can be registered and disabled by default.

anchor->add_matcher<MatcherPassB, false>();


shared_ptr to the transformation instance

template <, , >
voidArgs&&... add_matcher()

Register passes from GraphRewrite class that contains sequence of matcher passes registered in its ctor. For example:

class ov::pass::LinFusions: public ov::pass::GraphRewrite { public: OPENVINO_RTTI(“LinFusion”); Fusions() {add_matcher<ov::pass::AddFusion>(); add_matcher<ov::pass::MulFusion>(); } };

pass::Manager manager; auto anchor = manager.register_pass<GraphRewrite>(); anchor-> add_matcher<LinFusions>(); anchor-> add_matcher<OtherFusions>(); anchor->set_name(“CommonFusions”); manager.run_passes(f);

In this case all matcher passes from LinFusions pass will be united with other registered matchers.

virtual voidconst std::shared_ptr<PassConfig>& set_pass_config()

Set PassConfig for particular transformation instance.



is a PassConfig shared_ptr