ArmNN
 22.08
OptimizeForExclusiveConnectionImpl< 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 OptimizeForExclusiveConnectionImpl< BaseType, ChildType, Wrapped >:
OptimizeForTypeImpl< BaseType, OptimizeForExclusiveConnectionImpl< BaseType, ChildType, Wrapped > > OptimizeForExclusiveConnection< BaseType, ChildType, Wrapped >

Public Member Functions

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

Protected Member Functions

 ~OptimizeForExclusiveConnectionImpl ()=default
 

Detailed Description

template<typename BaseType, typename ChildType, typename Wrapped>
class armnn::OptimizeForExclusiveConnectionImpl< 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 131 of file Optimization.hpp.

Constructor & Destructor Documentation

◆ ~OptimizeForExclusiveConnectionImpl()

~OptimizeForExclusiveConnectionImpl ( )
protecteddefault

Member Function Documentation

◆ Run()

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

Definition at line 136 of file Optimization.hpp.

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

137  {
138  for (auto output = base.BeginOutputSlots(); output != base.EndOutputSlots(); ++output)
139  {
140  if (output->GetNumConnections() == 1)
141  {
142  for (auto&& childInput : output->GetConnections())
143  {
144  if (childInput->GetOwningLayer().GetType() == LayerEnumOf<ChildType>())
145  {
146  Wrapped::Run(graph, *childInput);
147  }
148  }
149 
150  // Removes unconnected children.
151  for (unsigned int i = 0; i < output->GetNumConnections();)
152  {
153  Layer* child = &output->GetConnection(i)->GetOwningLayer();
154 
155  if (child->IsOutputUnconnected())
156  {
157  graph.EraseLayer(child);
158  }
159  else
160  {
161  ++i;
162  }
163  }
164  }
165  }
166  }

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