ArmNN  NotReleased
OptimizeInversePermutes.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 #include "Optimization.hpp"
8 
9 #include <boost/core/ignore_unused.hpp>
10 
11 namespace armnn
12 {
13 namespace optimizations
14 {
15 
17 {
18 public:
21  void Run(Graph& graph, InputSlot& connection) const
22  {
23  boost::ignore_unused(graph);
24  Layer& base = connection.GetConnectedOutputSlot()->GetOwningLayer();
25  auto child = boost::polymorphic_downcast<PermuteLayer*>(&connection.GetOwningLayer());
26 
27  if (child->IsInverse(*boost::polymorphic_downcast<PermuteLayer*>(&base)))
28  {
29  // Bypass both layers. Child will be removed as it's left unconnected.
30  // Base layer will be removed if left unconnected.
32  }
33  }
34 
35 protected:
36  OptimizeInversePermutesImpl() = default;
37  ~OptimizeInversePermutesImpl() = default;
38 };
39 
41 
42 } // namespace optimizations
43 } // namespace armnn
void Run(Graph &graph, InputSlot &connection) const
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:55
void MoveAllConnections(OutputSlot &destination)
Moves all connections to another OutputSlot.
Definition: Layer.cpp:112
Layer & GetOwningLayer() const
Definition: Layer.hpp:115
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Definition: Layer.hpp:312
Layer & GetOwningLayer() const
Definition: Layer.hpp:52
const InputSlot & GetInputSlot(unsigned int index) const override
Definition: Layer.hpp:310