ArmNN
 20.11
DeserializeFullyConnected.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>
8 #include "../Deserializer.hpp"
9 
10 #include <string>
11 #include <iostream>
12 
13 BOOST_AUTO_TEST_SUITE(DeserializeParser)
14 
15 struct FullyConnectedFixture : public ParserFlatbuffersSerializeFixture
16 {
17  explicit FullyConnectedFixture(const std::string & inputShape1,
18  const std::string & outputShape,
19  const std::string & weightsShape,
20  const std::string & dataType)
21  {
22  m_JsonString = R"(
23  {
24  inputIds: [0],
25  outputIds: [2],
26  layers: [{
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: )" + inputShape1 + R"(,
43  dataType: )" + dataType + R"(,
44  quantizationScale: 1.0,
45  quantizationOffset: 0
46  },
47  }]
48  },
49  }
50  },
51  },
52  {
53  layer_type: "FullyConnectedLayer",
54  layer : {
55  base: {
56  index:1,
57  layerName: "FullyConnectedLayer",
58  layerType: "FullyConnected",
59  inputSlots: [{
60  index: 0,
61  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
62  }],
63  outputSlots: [{
64  index: 0,
65  tensorInfo: {
66  dimensions: )" + outputShape + R"(,
67  dataType: )" + dataType + R"(,
68  quantizationScale: 2.0,
69  quantizationOffset: 0
70  },
71  }],
72  },
73  descriptor: {
74  biasEnabled: false,
75  transposeWeightsMatrix: true
76  },
77  weights: {
78  info: {
79  dimensions: )" + weightsShape + R"(,
80  dataType: )" + dataType + R"(,
81  quantizationScale: 1.0,
82  quantizationOffset: 0
83  },
84  data_type: ByteData,
85  data: {
86  data: [
87  2, 3, 4, 5
88  ],
89  }
90  }
91  },
92  },
93  {
94  layer_type: "OutputLayer",
95  layer: {
96  base:{
97  layerBindingId: 0,
98  base: {
99  index: 2,
100  layerName: "OutputLayer",
101  layerType: "Output",
102  inputSlots: [{
103  index: 0,
104  connection: {sourceLayerIndex:1, outputSlotIndex:0 },
105  }],
106  outputSlots: [ {
107  index: 0,
108  tensorInfo: {
109  dimensions: )" + outputShape + R"(,
110  dataType: )" + dataType + R"(
111  },
112  }],
113  }
114  }},
115  }]
116  }
117  )";
118  Setup();
119  }
120 };
121 
122 struct FullyConnectedWithNoBiasFixture : FullyConnectedFixture
123 {
124  FullyConnectedWithNoBiasFixture()
125  : FullyConnectedFixture("[ 1, 4, 1, 1 ]", // inputShape
126  "[ 1, 1 ]", // outputShape
127  "[ 1, 4 ]", // filterShape
128  "QuantisedAsymm8") // filterData
129  {}
130 };
131 
132 BOOST_FIXTURE_TEST_CASE(FullyConnectedWithNoBias, FullyConnectedWithNoBiasFixture)
133 {
134  RunTest<2, armnn::DataType::QAsymmU8>(
135  0,
136  {{"InputLayer", { 10, 20, 30, 40 }}},
137  {{"OutputLayer", { 400/2 }}});
138 }
139 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(FullyConnectedWithNoBias, FullyConnectedWithNoBiasFixture)
BOOST_AUTO_TEST_SUITE_END()