// // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #include "../TestUtils.hpp" #include #include using namespace armnn; BOOST_AUTO_TEST_SUITE(Optimizer) using namespace armnn::optimizations; BOOST_AUTO_TEST_CASE(OptimizeInversePermutesTest) { armnn::Graph graph; auto output = graph.AddLayer(0, "output"); graph.InsertNewLayer(output->GetInputSlot(0), 0, "input"); // Inserts two permutes, one the inverse of the other. graph.InsertNewLayer(output->GetInputSlot(0), armnn::PermuteDescriptor({ 0, 2, 3, 1 }), "perm0231"); graph.InsertNewLayer(output->GetInputSlot(0), armnn::PermuteDescriptor({ 0, 3, 1, 2 }), "perm0312"); BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, &IsLayerOfType, &IsLayerOfType, &IsLayerOfType)); armnn::Optimizer::Pass(graph, armnn::MakeOptimizations(OptimizeInversePermutes())); // The permutes are removed. BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType, &IsLayerOfType)); } BOOST_AUTO_TEST_SUITE_END()