GraphRewrite is a container for MatcherPasses that allows to run them on Function in efficient way. More...
#include <graph_rewrite.hpp>
Public Member Functions | |
GraphRewrite (const std::shared_ptr< MatcherPass > &pass) | |
template<typename T , bool Enabled = true, class... Args, typename std::enable_if< std::is_base_of< pass::MatcherPass, T >::value, bool >::type = true> | |
std::shared_ptr< T > | add_matcher (Args &&... args) |
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. More... | |
template<typename T , class... Args, typename std::enable_if< std::is_base_of< pass::GraphRewrite, T >::value, bool >::type = true> | |
void | add_matcher (Args &&... args) |
Register passes from GraphRewrite class that contains sequence of matcher passes registered in its ctor. For example: More... | |
void | add_matcher (const std::shared_ptr< pattern::Matcher > &m, const ngraph::graph_rewrite_callback &callback, const PassPropertyMask &property) |
void | add_matcher (const std::shared_ptr< pattern::Matcher > &m, const ngraph::graph_rewrite_callback &callback) |
bool | run_on_function (std::shared_ptr< ngraph::Function > f) override |
void | set_pass_config (const std::shared_ptr< PassConfig > &pass_config) override |
Set PassConfig for particular transformation instance. More... | |
Public Member Functions inherited from ngraph::pass::PassBase | |
bool | get_property (const PassPropertyMask &prop_mask) const |
Check if this pass has all the pass properties. | |
void | set_name (const std::string &name) |
std::string | get_name () const |
void | set_callback (const param_callback &callback) |
Set callback for particular transformation type. This method set global callback. For more details see PassConfig class documentation. More... | |
std::shared_ptr< PassConfig > | get_pass_config () |
Allows to access PassConfig shared instance. More... | |
bool | m_transformation_callback (const std::shared_ptr< const Node > &node) |
Applies callback for given node. By default callback returns false. This method remains here only for backward compatibility and will be removed after all transformations are moved to transformation_callback() method. More... | |
bool | transformation_callback (const std::shared_ptr< const Node > &node) |
Applies callback for given node. By default callback returns false. More... | |
virtual const type_info_t & | get_type_info () const =0 |
Data Fields | |
NGRAPH_RTTI_DECLARATION | |
Data Fields inherited from ngraph::pass::FunctionPass | |
NGRAPH_RTTI_DECLARATION | |
Protected Attributes | |
bool | m_enable_shape_inference = false |
std::vector< std::shared_ptr< ngraph::pass::MatcherPass > > | m_matchers |
Additional Inherited Members | |
Public Types inherited from ngraph::pass::PassBase | |
using | type_info_t = DiscreteTypeInfo |
Protected Member Functions inherited from ngraph::pass::PassBase | |
void | set_property (const PassPropertyMask &prop, bool value) |
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
|
inline |
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>(); anchor->add_matcher<MatcherPassA>(); anchor->add_matcher<MatcherPassB>(); anchor->set_name("CommonMatchers"); manager.run_passes(f);
For some purposes transformation can be registered and disabled by default.
anchor->add_matcher<MatcherPassB, false>();
|
inline |
Register passes from GraphRewrite class that contains sequence of matcher passes registered in its ctor. For example:
class ngraph::pass::LinFusions: public ngraph::pass::GraphRewrite { public: NGRAPH_RTTI_DECLARATION; Fusions() { add_matcher<ngraph::pass::AddFusion>(); add_matcher<ngraph::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.
|
overridevirtual |
Set PassConfig for particular transformation instance.
pass_config | is a PassConfig shared_ptr |
Reimplemented from ngraph::pass::PassBase.