ArmNN
 24.08
TransposeAsReshapeImpl Class Reference

#include <TransposeAsReshape.hpp>

Public Member Functions

void Run (Graph &graph, TransposeLayer &transpose) const
 Run for every TransposeLayer. Replaces it with a ReshapeLayer if they are equivalent. More...
 

Protected Member Functions

 TransposeAsReshapeImpl ()=default
 
 ~TransposeAsReshapeImpl ()=default
 

Detailed Description

Definition at line 14 of file TransposeAsReshape.hpp.

Constructor & Destructor Documentation

◆ TransposeAsReshapeImpl()

TransposeAsReshapeImpl ( )
protecteddefault

◆ ~TransposeAsReshapeImpl()

~TransposeAsReshapeImpl ( )
protecteddefault

Member Function Documentation

◆ Run()

void Run ( Graph graph,
TransposeLayer transpose 
) const
inline

Run for every TransposeLayer. Replaces it with a ReshapeLayer if they are equivalent.

Definition at line 18 of file TransposeAsReshape.hpp.

19  {
20  if (IsReshape(transpose))
21  {
22  const TensorInfo& outInfo = transpose.GetOutputHandler().GetTensorInfo();
23 
24  const std::string name = std::string("as_reshape-") + transpose.GetName();
25  const ReshapeDescriptor descriptor{outInfo.GetShape()};
26  // Inserts NewLayer so layers don't need to be re-sorted.
27  auto reshape = graph.InsertNewLayer<ReshapeLayer>(transpose.GetInputSlot(0), descriptor, name.c_str());
28 
29  // Bypass transpose. It will be deleted since it's left unconnected.
30  transpose.GetOutputSlot().MoveAllConnections(reshape->GetOutputSlot());
31  }
32  }

References Layer::GetInputSlot(), Layer::GetName(), Layer::GetOutputHandler(), Layer::GetOutputSlot(), TensorInfo::GetShape(), OutputHandler::GetTensorInfo(), Graph::InsertNewLayer(), and OutputSlot::MoveAllConnections().


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