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