Compute Library
 21.08
PassManager Class Referencefinal

Pass manager. More...

#include <PassManager.h>

Public Member Functions

 PassManager ()
 Constructor. More...
 
 PassManager (const PassManager &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 PassManager (PassManager &&)=default
 Default move constructor. More...
 
PassManageroperator= (const PassManager &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
PassManageroperator= (PassManager &&)=default
 Default move assignment operator. More...
 
const std::vector< std::unique_ptr< IGraphMutator > > & passes () const
 Mutation passes accessors. More...
 
IGraphMutatorpass (size_t index)
 Accessor of a pass at a given index. More...
 
void append (std::unique_ptr< IGraphMutator > pass, bool conditional=true)
 Appends a mutation pass. More...
 
void clear ()
 Clears all the passes. More...
 
void run_all (Graph &g)
 Runs all the mutation passes on a given graph. More...
 
void run_type (Graph &g, IGraphMutator::MutationType type)
 Runs a mutation passes of a specific type on a given graph. More...
 
void run_index (Graph &g, size_t index)
 Runs a specific mutation pass on a given graph. More...
 

Detailed Description

Pass manager.

Responsible for performing the mutating graph passes with a given order

Definition at line 43 of file PassManager.h.

Constructor & Destructor Documentation

◆ PassManager() [1/3]

Constructor.

Definition at line 32 of file PassManager.cpp.

33  : _passes()
34 {
35 }

◆ PassManager() [2/3]

PassManager ( const PassManager )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ PassManager() [3/3]

PassManager ( PassManager &&  )
default

Default move constructor.

Member Function Documentation

◆ append()

void append ( std::unique_ptr< IGraphMutator pass,
bool  conditional = true 
)

Appends a mutation pass.

Parameters
[in]passPass to append
[in]conditional(Optional) Append pass if true else false. Defaults to true.

Definition at line 47 of file PassManager.cpp.

References ARM_COMPUTE_LOG_GRAPH_VERBOSE.

Referenced by arm_compute::graph::create_default_pass_manager().

48 {
49  if(pass && conditional)
50  {
51  ARM_COMPUTE_LOG_GRAPH_VERBOSE("Appending mutating pass : " << pass->name() << std::endl);
52  _passes.push_back(std::move(pass));
53  }
54 }
IGraphMutator * pass(size_t index)
Accessor of a pass at a given index.
Definition: PassManager.cpp:42
virtual const char * name()=0
Returns mutator name.
#define ARM_COMPUTE_LOG_GRAPH_VERBOSE(x)
Definition: Logger.h:50

◆ clear()

void clear ( )

Clears all the passes.

Definition at line 56 of file PassManager.cpp.

57 {
58  _passes.clear();
59 }

◆ operator=() [1/2]

PassManager& operator= ( const PassManager )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

PassManager& operator= ( PassManager &&  )
default

Default move assignment operator.

◆ pass()

IGraphMutator * pass ( size_t  index)

Accessor of a pass at a given index.

Parameters
[in]indexIndex of the requested pass
Returns
A pointer to the given pass if exists else nullptr

Definition at line 42 of file PassManager.cpp.

Referenced by PassManager::run_all(), PassManager::run_index(), and PassManager::run_type().

43 {
44  return (index >= _passes.size()) ? nullptr : _passes.at(index).get();
45 }

◆ passes()

const std::vector< std::unique_ptr< IGraphMutator > > & passes ( ) const

Mutation passes accessors.

Returns
Returns the vector with the mutation passes that are to be executed on a graph

Definition at line 37 of file PassManager.cpp.

38 {
39  return _passes;
40 }

◆ run_all()

void run_all ( Graph g)

Runs all the mutation passes on a given graph.

Parameters
[in,out]gGraph to run the mutations on

Definition at line 61 of file PassManager.cpp.

References ARM_COMPUTE_LOG_GRAPH_INFO, IGraphMutator::mutate(), IGraphMutator::name(), and PassManager::pass().

62 {
63  for(auto &pass : _passes)
64  {
65  if(pass)
66  {
67  ARM_COMPUTE_LOG_GRAPH_INFO("Running mutating pass : " << pass->name() << std::endl);
68  pass->mutate(g);
69  }
70  }
71 }
IGraphMutator * pass(size_t index)
Accessor of a pass at a given index.
Definition: PassManager.cpp:42
#define ARM_COMPUTE_LOG_GRAPH_INFO(x)
Definition: Logger.h:54
virtual void mutate(Graph &g)=0
Walk the graph and perform a specific mutation.
virtual const char * name()=0
Returns mutator name.

◆ run_index()

void run_index ( Graph g,
size_t  index 
)

Runs a specific mutation pass on a given graph.

Parameters
[in,out]gGraph to run the mutation on
[in]indexIndex of the mutation to execute

Definition at line 85 of file PassManager.cpp.

References ARM_COMPUTE_LOG_GRAPH_INFO, IGraphMutator::mutate(), IGraphMutator::name(), and PassManager::pass().

86 {
87  if(index >= _passes.size())
88  {
89  return;
90  }
91 
92  auto &pass = _passes.at(index);
93  if(pass != nullptr)
94  {
95  ARM_COMPUTE_LOG_GRAPH_INFO("Running mutating pass : " << pass->name() << std::endl);
96  pass->mutate(g);
97  }
98 }
IGraphMutator * pass(size_t index)
Accessor of a pass at a given index.
Definition: PassManager.cpp:42
#define ARM_COMPUTE_LOG_GRAPH_INFO(x)
Definition: Logger.h:54
virtual void mutate(Graph &g)=0
Walk the graph and perform a specific mutation.
virtual const char * name()=0
Returns mutator name.

◆ run_type()

void run_type ( Graph g,
IGraphMutator::MutationType  type 
)

Runs a mutation passes of a specific type on a given graph.

Parameters
[in,out]gGraph to run the mutation on
[in]typeType of the mutations to execute

Definition at line 73 of file PassManager.cpp.

References ARM_COMPUTE_LOG_GRAPH_INFO, IGraphMutator::mutate(), IGraphMutator::name(), PassManager::pass(), IGraphMutator::type(), and type.

Referenced by GraphManager::finalize_graph().

74 {
75  for(auto &pass : _passes)
76  {
77  if(pass && (pass->type() == type))
78  {
79  ARM_COMPUTE_LOG_GRAPH_INFO("Running mutating pass : " << pass->name() << std::endl);
80  pass->mutate(g);
81  }
82  }
83 }
IGraphMutator * pass(size_t index)
Accessor of a pass at a given index.
Definition: PassManager.cpp:42
decltype(strategy::transforms) typedef type
#define ARM_COMPUTE_LOG_GRAPH_INFO(x)
Definition: Logger.h:54
virtual void mutate(Graph &g)=0
Walk the graph and perform a specific mutation.
virtual const char * name()=0
Returns mutator name.
virtual MutationType type() const =0
Returns mutation type.

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