From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- ...ze_consecutive_reshapes_tests_8cpp_source.xhtml | 136 +++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 20.02/_optimize_consecutive_reshapes_tests_8cpp_source.xhtml (limited to '20.02/_optimize_consecutive_reshapes_tests_8cpp_source.xhtml') diff --git a/20.02/_optimize_consecutive_reshapes_tests_8cpp_source.xhtml b/20.02/_optimize_consecutive_reshapes_tests_8cpp_source.xhtml new file mode 100644 index 0000000000..622a959359 --- /dev/null +++ b/20.02/_optimize_consecutive_reshapes_tests_8cpp_source.xhtml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + +ArmNN: src/armnn/test/optimizations/OptimizeConsecutiveReshapesTests.cpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
OptimizeConsecutiveReshapesTests.cpp
+
+
+Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "../TestUtils.hpp"
7 
8 #include <Optimizer.hpp>
9 
10 #include <boost/test/unit_test.hpp>
11 
12 BOOST_AUTO_TEST_SUITE(Optimizer)
13 using namespace armnn::optimizations;
14 
15 BOOST_AUTO_TEST_CASE(OptimizeConsecutiveReshapesTest)
16 {
17  armnn::Graph graph;
18 
19  const armnn::TensorInfo info0({ 1, 2, 3, 5 }, armnn::DataType::Float32);
20 
21  auto output = graph.AddLayer<armnn::OutputLayer>(0, "output");
22  auto input = graph.InsertNewLayer<armnn::InputLayer>(output->GetInputSlot(0), 0, "input");
23 
24  input->GetOutputHandler().SetTensorInfo(info0);
25 
26  {
27  // Inserts two reshapes.
28  const armnn::TensorInfo info1({ 1, 30, 1, 1 }, armnn::DataType::Float32);
29  const armnn::TensorInfo info2({ 1, 2, 1, 15 }, armnn::DataType::Float32);
30 
31  std::string reshape1Name = "reshape1";
32  std::string reshape2Name = "reshape2";
33 
34  auto reshape1 = graph.InsertNewLayer<armnn::ReshapeLayer>(
35  output->GetInputSlot(0), armnn::ReshapeDescriptor{ info1.GetShape() }, reshape1Name.c_str());
36  auto reshape2 = graph.InsertNewLayer<armnn::ReshapeLayer>(
37  output->GetInputSlot(0), armnn::ReshapeDescriptor{ info2.GetShape() }, reshape2Name.c_str());
38 
39  reshape1->GetOutputHandler().SetTensorInfo(info1);
40  reshape2->GetOutputHandler().SetTensorInfo(info2);
41 
42  BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType<armnn::InputLayer>,
43  &IsLayerOfType<armnn::ReshapeLayer>, &IsLayerOfType<armnn::ReshapeLayer>,
44  &IsLayerOfType<armnn::OutputLayer>));
45 
47 
48  auto checkReshape = [&info2](const armnn::Layer* const layer) -> bool {
49  const auto reshapeLayer = static_cast<const armnn::ReshapeLayer*>(layer);
50  return IsLayerOfType<armnn::ReshapeLayer>(layer) &&
51  (reshapeLayer->GetParameters().m_TargetShape == info2.GetShape()) &&
52  (reshapeLayer->GetOutputHandler().GetTensorInfo().GetShape() == info2.GetShape());
53  };
54 
55  // The two reshapes are replaced by a single equivalent reshape.
56  BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType<armnn::InputLayer>, checkReshape,
57  &IsLayerOfType<armnn::OutputLayer>));
58 
59  // Check the new reshape layer has the other two reshapes as related layers
60  std::list<std::string> testRelatedLayers = { reshape2Name, reshape1Name };
61 
62  BOOST_TEST(CheckRelatedLayers<armnn::ReshapeLayer>(graph, testRelatedLayers));
63  }
64 
65  {
66  // Inserts a reshape to the input shape.
67  auto reshapeToIn = graph.InsertNewLayer<armnn::ReshapeLayer>(
68  output->GetInputSlot(0), armnn::ReshapeDescriptor{ info0.GetShape() }, "reshapeToIn");
69 
70  reshapeToIn->GetOutputHandler().SetTensorInfo(info0);
71 
73 
74  // The two reshapes are removed.
75  BOOST_TEST(CheckSequence(graph.cbegin(), graph.cend(), &IsLayerOfType<armnn::InputLayer>,
76  &IsLayerOfType<armnn::OutputLayer>));
77  }
78 }
79 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
+
Optimizer::Optimizations MakeOptimizations(Args &&... args)
Definition: Optimizer.hpp:43
+
A ReshapeDescriptor for the ReshapeLayer.
+ + +
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:397
+
ConstIterator cbegin() const
Returns const iterator pointing to the beginning of the list. Lowercase for range-based for loops...
Definition: Graph.hpp:168
+
static void Pass(Graph &graph, const Optimizations &optimizations)
Definition: Optimizer.cpp:16
+
This layer represents a reshape operation.
+
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
+ +
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: OutputLayer.hpp:13
+
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
+ +
void SetTensorInfo(const TensorInfo &tensorInfo)
Sets the TensorInfo used by this output handler.
+
BOOST_AUTO_TEST_SUITE_END()
+
const OutputHandler & GetOutputHandler(unsigned int i=0) const
Definition: Layer.hpp:221
+
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: InputLayer.hpp:13
+
bool CheckSequence(const armnn::Graph::ConstIterator first, const armnn::Graph::ConstIterator last)
Definition: TestUtils.hpp:20
+ +
ConstIterator cend() const
Returns const iterator pointing to the end of the list. Lowercase for range-based for loops...
Definition: Graph.hpp:170
+
LayerT * InsertNewLayer(InputSlot &insertBefore, Args &&... args)
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itse...
Definition: Graph.hpp:409
+ +
+
+ + + + -- cgit v1.2.1