ArmNN
 24.02
OptimizeForConnectionImpl< BaseType, ChildType, Wrapped > Class Template Reference

Wrapper Optimization class that calls Wrapped::Run for every connection BaseType -> ChildType. More...

#include <Optimization.hpp>

Inheritance diagram for OptimizeForConnectionImpl< BaseType, ChildType, Wrapped >:
[legend]
Collaboration diagram for OptimizeForConnectionImpl< BaseType, ChildType, Wrapped >:
[legend]

Public Member Functions

void Run (Graph &graph, BaseType &base) const
 

Protected Member Functions

 ~OptimizeForConnectionImpl ()=default
 

Detailed Description

template<typename BaseType, typename ChildType, typename Wrapped>
class armnn::OptimizeForConnectionImpl< BaseType, ChildType, Wrapped >

Wrapper Optimization class that calls Wrapped::Run for every connection BaseType -> ChildType.

  • Wrapped class mustn't remove the base layer. The optimizer will remove it if left unconnected after applying each optimization.
  • Wrapped class mustn't affect existing connections in the same output. It might add new ones.
  • Children layers are removed if left unconnected after applying the wrapped optimization.

Definition at line 79 of file Optimization.hpp.

Constructor & Destructor Documentation

◆ ~OptimizeForConnectionImpl()

~OptimizeForConnectionImpl ( )
protecteddefault

Member Function Documentation

◆ Run()

void Run ( Graph graph,
BaseType &  base 
) const
inline

Definition at line 84 of file Optimization.hpp.

85  {
86  for (auto output = base.BeginOutputSlots(); output != base.EndOutputSlots(); ++output)
87  {
88  for (auto&& childInput : output->GetConnections())
89  {
90  if (childInput->GetOwningLayer().GetType() == LayerEnumOf<ChildType>())
91  {
92  Wrapped::Run(graph, *childInput);
93  }
94  }
95 
96  // Removes unconnected children.
97  for (unsigned int i = 0; i < output->GetNumConnections();)
98  {
99  Layer* child = &output->GetConnection(i)->GetOwningLayer();
100 
101  if (child->IsOutputUnconnected())
102  {
103  graph.EraseLayer(child);
104  }
105  else
106  {
107  ++i;
108  }
109  }
110  }
111  }

References Graph::EraseLayer(), and Layer::IsOutputUnconnected().


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