ArmNN  NotReleased
OptimizeInversePermutesTests.cpp File Reference
#include "../TestUtils.hpp"
#include <Optimizer.hpp>
#include <boost/test/unit_test.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (OptimizeInversePermutesTest)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( OptimizeInversePermutesTest  )

Definition at line 17 of file OptimizeInversePermutesTests.cpp.

References Graph::AddLayer(), BOOST_AUTO_TEST_SUITE_END(), Graph::cbegin(), Graph::cend(), CheckSequence(), Graph::InsertNewLayer(), armnn::MakeOptimizations(), and Optimizer::Pass().

18 {
19  armnn::Graph graph;
20 
21  auto output = graph.AddLayer<armnn::OutputLayer>(0, "output");
22 
23  graph.InsertNewLayer<armnn::InputLayer>(output->GetInputSlot(0), 0, "input");
24 
25  // Inserts two permutes, one the inverse of the other.
26  graph.InsertNewLayer<armnn::PermuteLayer>(output->GetInputSlot(0), armnn::PermuteDescriptor({ 0, 2, 3, 1 }),
27  "perm0231");
28  graph.InsertNewLayer<armnn::PermuteLayer>(output->GetInputSlot(0), armnn::PermuteDescriptor({ 0, 3, 1, 2 }),
29  "perm0312");
30 
31  BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType<armnn::InputLayer>,
32  &IsLayerOfType<armnn::PermuteLayer>, &IsLayerOfType<armnn::PermuteLayer>,
33  &IsLayerOfType<armnn::OutputLayer>));
34 
36 
37  // The permutes are removed.
38  BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType<armnn::InputLayer>,
39  &IsLayerOfType<armnn::OutputLayer>));
40 }
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: InputLayer.hpp:13
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:397
static void Pass(Graph &graph, const Optimizations &optimizations)
Definition: Optimizer.cpp:16
bool CheckSequence(const armnn::Graph::ConstIterator first, const armnn::Graph::ConstIterator last)
Definition: TestUtils.hpp:20
This layer represents a permutation operation.
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: OutputLayer.hpp:13
ConstIterator cbegin() const
Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops...
Definition: Graph.hpp:168
Optimizer::Optimizations MakeOptimizations(Args &&... args)
Definition: Optimizer.hpp:43
ConstIterator cend() const
Returns const iterator pointing to the end of the list. Lowercase for range-based for loops...
Definition: Graph.hpp:170
A PermuteDescriptor for the PermuteLayer.
LayerT * InsertNewLayer(InputSlot &insertBefore, Args &&... args)
Definition: Graph.hpp:409
OptimizeForConnection< PermuteLayer, PermuteLayer, OptimizeInversePermutesImpl > OptimizeInversePermutes