ArmNN
 21.02
DeserializeAbs.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 AbsFixture : public ParserFlatbuffersSerializeFixture
15  {
16  explicit AbsFixture(const std::string &inputShape,
17  const std::string &outputShape,
18  const std::string &dataType)
19  {
20  m_JsonString = R"(
21  {
22  inputIds: [0],
23  outputIds: [2],
24  layers: [
25  {
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: )" + inputShape + R"(,
42  dataType: )" + dataType + R"(
43  }
44  }]
45  }
46  }
47  }
48  },
49  {
50  layer_type: "AbsLayer",
51  layer: {
52  base: {
53  index: 1,
54  layerName: "AbsLayer",
55  layerType: "Abs",
56  inputSlots: [{
57  index: 0,
58  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
59  }],
60  outputSlots: [{
61  index: 0,
62  tensorInfo: {
63  dimensions: )" + outputShape + R"(,
64  dataType: )" + dataType + R"(
65  }
66  }]
67  }
68 
69  }
70  },
71  {
72  layer_type: "OutputLayer",
73  layer: {
74  base:{
75  layerBindingId: 2,
76  base: {
77  index: 2,
78  layerName: "OutputLayer",
79  layerType: "Output",
80  inputSlots: [{
81  index: 0,
82  connection: {sourceLayerIndex:1, outputSlotIndex:0 },
83  }],
84  outputSlots: [{
85  index: 0,
86  tensorInfo: {
87  dimensions: )" + outputShape + R"(,
88  dataType: )" + dataType + R"(
89  },
90  }],
91  }
92  }
93  },
94  }
95  ]
96  }
97  )";
98  Setup();
99  }
100  };
101 
102  struct SimpleAbsFixture : AbsFixture
103  {
104  SimpleAbsFixture()
105  : AbsFixture("[ 1, 2, 2, 2 ]", // inputShape
106  "[ 1, 2, 2, 2 ]", // outputShape
107  "Float32") // dataType
108  {}
109  };
110 
111  BOOST_FIXTURE_TEST_CASE(SimpleAbsTest, SimpleAbsFixture)
112  {
113  RunTest<4, armnn::DataType::Float32>(
114  0,
115  {{"InputLayer", { -100.0f, -50.5f, -25.9999f, -0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}},
116  {{"OutputLayer", { 100.0f, 50.5f, 25.9999f, 0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}});
117  }
118 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_FIXTURE_TEST_CASE(SimpleAbsTest, SimpleAbsFixture)