Compute Library
 23.11
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.

32  : _passes()
33 {
34 }

◆ 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 46 of file PassManager.cpp.

47 {
48  if (pass && conditional)
49  {
50  ARM_COMPUTE_LOG_GRAPH_VERBOSE("Appending mutating pass : " << pass->name() << std::endl);
51  _passes.push_back(std::move(pass));
52  }
53 }

References ARM_COMPUTE_LOG_GRAPH_VERBOSE, IGraphMutator::name(), and PassManager::pass().

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

◆ clear()

void clear ( )

Clears all the passes.

Definition at line 55 of file PassManager.cpp.

56 {
57  _passes.clear();
58 }

◆ 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 41 of file PassManager.cpp.

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

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

◆ 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 36 of file PassManager.cpp.

37 {
38  return _passes;
39 }

◆ 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 60 of file PassManager.cpp.

61 {
62  for (auto &pass : _passes)
63  {
64  if (pass)
65  {
66  ARM_COMPUTE_LOG_GRAPH_INFO("Running mutating pass : " << pass->name() << std::endl);
67  pass->mutate(g);
68  }
69  }
70 }

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

◆ 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 84 of file PassManager.cpp.

85 {
86  if (index >= _passes.size())
87  {
88  return;
89  }
90 
91  auto &pass = _passes.at(index);
92  if (pass != nullptr)
93  {
94  ARM_COMPUTE_LOG_GRAPH_INFO("Running mutating pass : " << pass->name() << std::endl);
95  pass->mutate(g);
96  }
97 }

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

◆ 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 72 of file PassManager.cpp.

73 {
74  for (auto &pass : _passes)
75  {
76  if (pass && (pass->type() == type))
77  {
78  ARM_COMPUTE_LOG_GRAPH_INFO("Running mutating pass : " << pass->name() << std::endl);
79  pass->mutate(g);
80  }
81  }
82 }

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

Referenced by GraphManager::finalize_graph().


The documentation for this class was generated from the following files:
ARM_COMPUTE_LOG_GRAPH_INFO
#define ARM_COMPUTE_LOG_GRAPH_INFO(x)
Definition: Logger.h:54
type
decltype(strategy::transforms) typedef type
Definition: gemm_interleaved.hpp:261
ARM_COMPUTE_LOG_GRAPH_VERBOSE
#define ARM_COMPUTE_LOG_GRAPH_VERBOSE(x)
Definition: Logger.h:50
arm_compute::graph::IGraphMutator::name
virtual const char * name()=0
Returns mutator name.
arm_compute::graph::IGraphMutator::type
virtual MutationType type() const =0
Returns mutation type.
arm_compute::graph::IGraphMutator::mutate
virtual void mutate(Graph &g)=0
Walk the graph and perform a specific mutation.
arm_compute::graph::PassManager::pass
IGraphMutator * pass(size_t index)
Accessor of a pass at a given index.
Definition: PassManager.cpp:41