ArmNN
 21.02
DeserializeAdd.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 
11 
12 #include <string>
13 
14 BOOST_AUTO_TEST_SUITE(Deserializer)
15 
16 struct AddFixture : public ParserFlatbuffersSerializeFixture
17 {
18  explicit AddFixture(const std::string & inputShape1,
19  const std::string & inputShape2,
20  const std::string & outputShape,
21  const std::string & dataType,
22  const std::string & activation="NONE")
23  {
24  armnn::IgnoreUnused(activation);
25  m_JsonString = R"(
26  {
27  inputIds: [0, 1],
28  outputIds: [3],
29  layers: [
30  {
31  layer_type: "InputLayer",
32  layer: {
33  base: {
34  layerBindingId: 0,
35  base: {
36  index: 0,
37  layerName: "InputLayer1",
38  layerType: "Input",
39  inputSlots: [{
40  index: 0,
41  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
42  }],
43  outputSlots: [ {
44  index: 0,
45  tensorInfo: {
46  dimensions: )" + inputShape1 + R"(,
47  dataType: )" + dataType + R"(
48  },
49  }],
50  },}},
51  },
52  {
53  layer_type: "InputLayer",
54  layer: {
55  base: {
56  layerBindingId: 1,
57  base: {
58  index:1,
59  layerName: "InputLayer2",
60  layerType: "Input",
61  inputSlots: [{
62  index: 0,
63  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
64  }],
65  outputSlots: [ {
66  index: 0,
67  tensorInfo: {
68  dimensions: )" + inputShape2 + R"(,
69  dataType: )" + dataType + R"(
70  },
71  }],
72  },}},
73  },
74  {
75  layer_type: "AdditionLayer",
76  layer : {
77  base: {
78  index:2,
79  layerName: "AdditionLayer",
80  layerType: "Addition",
81  inputSlots: [
82  {
83  index: 0,
84  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
85  },
86  {
87  index: 1,
88  connection: {sourceLayerIndex:1, outputSlotIndex:0 },
89  }
90  ],
91  outputSlots: [ {
92  index: 0,
93  tensorInfo: {
94  dimensions: )" + outputShape + R"(,
95  dataType: )" + dataType + R"(
96  },
97  }],
98  }},
99  },
100  {
101  layer_type: "OutputLayer",
102  layer: {
103  base:{
104  layerBindingId: 0,
105  base: {
106  index: 3,
107  layerName: "OutputLayer",
108  layerType: "Output",
109  inputSlots: [{
110  index: 0,
111  connection: {sourceLayerIndex:2, outputSlotIndex:0 },
112  }],
113  outputSlots: [ {
114  index: 0,
115  tensorInfo: {
116  dimensions: )" + outputShape + R"(,
117  dataType: )" + dataType + R"(
118  },
119  }],
120  }}},
121  }]
122  }
123  )";
124  Setup();
125  }
126 };
127 
128 
129 struct SimpleAddFixture : AddFixture
130 {
131  SimpleAddFixture() : AddFixture("[ 2, 2 ]",
132  "[ 2, 2 ]",
133  "[ 2, 2 ]",
134  "QuantisedAsymm8") {}
135 };
136 
137 struct SimpleAddFixture2 : AddFixture
138 {
139  SimpleAddFixture2() : AddFixture("[ 2, 2, 1, 1 ]",
140  "[ 2, 2, 1, 1 ]",
141  "[ 2, 2, 1, 1 ]",
142  "Float32") {}
143 };
144 
145 BOOST_FIXTURE_TEST_CASE(AddQuantisedAsymm8, SimpleAddFixture)
146 {
147  RunTest<2, armnn::DataType::QAsymmU8>(
148  0,
149  {{"InputLayer1", { 0, 1, 2, 3 }},
150  {"InputLayer2", { 4, 5, 6, 7 }}},
151  {{"OutputLayer", { 4, 6, 8, 10 }}});
152 }
153 
154 BOOST_FIXTURE_TEST_CASE(AddFloat32, SimpleAddFixture2)
155 {
156  RunTest<4, armnn::DataType::Float32>(
157  0,
158  {{"InputLayer1", { 111, 85, 226, 3 }},
159  {"InputLayer2", { 5, 8, 10, 12 }}},
160  {{"OutputLayer", { 116, 93, 236, 15 }}});
161 }
162 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
void IgnoreUnused(Ts &&...)
BOOST_AUTO_TEST_SUITE_END()
BOOST_FIXTURE_TEST_CASE(AddQuantisedAsymm8, SimpleAddFixture)