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