ArmNN
 21.02
DeserializeMean.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 <boost/test/unit_test.hpp>
9 
10 #include <string>
11 
12 BOOST_AUTO_TEST_SUITE(Deserializer)
13 
14 struct MeanFixture : public ParserFlatbuffersSerializeFixture
15 {
16  explicit MeanFixture(const std::string &inputShape,
17  const std::string &outputShape,
18  const std::string &axis,
19  const std::string &dataType)
20  {
21  m_JsonString = R"(
22  {
23  inputIds: [0],
24  outputIds: [2],
25  layers: [
26  {
27  layer_type: "InputLayer",
28  layer: {
29  base: {
30  layerBindingId: 0,
31  base: {
32  index: 0,
33  layerName: "InputLayer",
34  layerType: "Input",
35  inputSlots: [{
36  index: 0,
37  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
38  }],
39  outputSlots: [{
40  index: 0,
41  tensorInfo: {
42  dimensions: )" + inputShape + R"(,
43  dataType: )" + dataType + R"(
44  }
45  }]
46  }
47  }
48  }
49  },
50  {
51  layer_type: "MeanLayer",
52  layer: {
53  base: {
54  index: 1,
55  layerName: "MeanLayer",
56  layerType: "Mean",
57  inputSlots: [{
58  index: 0,
59  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
60  }],
61  outputSlots: [{
62  index: 0,
63  tensorInfo: {
64  dimensions: )" + outputShape + R"(,
65  dataType: )" + dataType + R"(
66  }
67  }]
68  },
69  descriptor: {
70  axis: )" + axis + R"(,
71  keepDims: true
72  }
73  }
74  },
75  {
76  layer_type: "OutputLayer",
77  layer: {
78  base:{
79  layerBindingId: 2,
80  base: {
81  index: 2,
82  layerName: "OutputLayer",
83  layerType: "Output",
84  inputSlots: [{
85  index: 0,
86  connection: {sourceLayerIndex:1, outputSlotIndex:0 },
87  }],
88  outputSlots: [{
89  index: 0,
90  tensorInfo: {
91  dimensions: )" + outputShape + R"(,
92  dataType: )" + dataType + R"(
93  },
94  }],
95  }
96  }
97  },
98  }
99  ]
100  }
101  )";
102  Setup();
103  }
104 };
105 
106 struct SimpleMeanFixture : MeanFixture
107 {
108  SimpleMeanFixture()
109  : MeanFixture("[ 1, 1, 3, 2 ]", // inputShape
110  "[ 1, 1, 1, 2 ]", // outputShape
111  "[ 2 ]", // axis
112  "Float32") // dataType
113  {}
114 };
115 
116 BOOST_FIXTURE_TEST_CASE(SimpleMean, SimpleMeanFixture)
117 {
118  RunTest<4, armnn::DataType::Float32>(
119  0,
120  {{"InputLayer", { 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f }}},
121  {{"OutputLayer", { 2.0f, 2.0f }}});
122 }
123 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_FIXTURE_TEST_CASE(SimpleMean, SimpleMeanFixture)