Public Member Functions | Data Fields | Protected Member Functions
ngraph::pass::MatcherPass Class Reference

MatcherPass is a basic block for pattern based transformations. It describes pattern and action that is applied if pattern is matched. More...

#include <graph_rewrite.hpp>

Inheritance diagram for ngraph::pass::MatcherPass:
Inheritance graph
[legend]
Collaboration diagram for ngraph::pass::MatcherPass:
Collaboration graph
[legend]

Public Member Functions

 MatcherPass (const MatcherPass &)=delete
 
MatcherPassoperator= (const MatcherPass &)=delete
 
 MatcherPass (const std::string &name, const std::shared_ptr< pattern::Matcher > &m, const handler_callback &handler, const PassPropertyMask &property=PassProperty::CHANGE_DYNAMIC_STATE)
 
bool apply (std::shared_ptr< ngraph::Node > node)
 
template<typename T , class... Args>
std::shared_ptr< T > register_new_node (Args &&... args)
 
const std::vector< std::shared_ptr< ngraph::Node > > & get_new_nodes ()
 
void clear_new_nodes ()
 
std::shared_ptr< pattern::Matcherget_matcher ()
 
- 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...
 
virtual void set_pass_config (const std::shared_ptr< PassConfig > &pass_config)
 Set PassConfig for particular transformation instance. More...
 
std::shared_ptr< PassConfigget_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_tget_type_info () const =0
 

Data Fields

 NGRAPH_RTTI_DECLARATION
 

Protected Member Functions

void register_matcher (const std::shared_ptr< pattern::Matcher > &m, const ngraph::graph_rewrite_callback &callback, const PassPropertyMask &property=PassProperty::CHANGE_DYNAMIC_STATE)
 
- Protected Member Functions inherited from ngraph::pass::PassBase
void set_property (const PassPropertyMask &prop, bool value)
 

Additional Inherited Members

- Public Types inherited from ngraph::pass::PassBase
using type_info_t = DiscreteTypeInfo
 

Detailed Description

MatcherPass is a basic block for pattern based transformations. It describes pattern and action that is applied if pattern is matched.

MatcherPass consists of Matcher and matcher_pass_callback that needs to be implemented and finally registered by using

See also
register_matcher. MatcherPass can be executed on node within
apply method. To run matcher pass on Function use GraphRewrite. In addition MatcherPass provides a way for adding new operations into GraphRewrite execution queue. That means that operations that were created inside transformation callback can be added for matching. To register node use
register_new_node method. GraphRewrite automatically takes registered nodes and put them to execution queue. If multiple nodes were register make sure that they were registered in topological order. Note: when implementing pattern for Matcher make sure that root node is an operation from opset or has ngraph::pattern::op::WrapType. That will help GraphRewrite to execute matcher passes more efficient.

The documentation for this class was generated from the following file: