IVGCVSW-5593 Implement Pimpl Idiom for serialization classes
[platform/upstream/armnn.git] / src / armnnDeserializer / test / DeserializePad.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include <boost/test/unit_test.hpp>
7 #include "ParserFlatbuffersSerializeFixture.hpp"
8 #include <armnnDeserializer/IDeserializer.hpp>
9
10 #include <string>
11
12 BOOST_AUTO_TEST_SUITE(Deserializer)
13
14 struct PadFixture : public ParserFlatbuffersSerializeFixture
15 {
16     explicit PadFixture(const std::string &inputShape,
17                         const std::string &padList,
18                         const std::string &outputShape,
19                         const std::string &dataType)
20     {
21         m_JsonString = R"(
22             {
23                 inputIds: [0],
24                 outputIds: [2],
25                 layers: [
26                     {
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: )" + inputShape + R"(,
43                                             dataType: )" + dataType + R"(
44                                         }
45                                     }]
46                                 }
47                             }
48                         }
49                     },
50                     {
51                         layer_type: "PadLayer",
52                         layer: {
53                             base: {
54                                 index: 1,
55                                 layerName: "PadLayer",
56                                 layerType: "Pad",
57                                 inputSlots: [{
58                                     index: 0,
59                                     connection: {sourceLayerIndex:0, outputSlotIndex:0 },
60                                 }],
61                                 outputSlots: [{
62                                     index: 0,
63                                     tensorInfo: {
64                                         dimensions: )" + outputShape + R"(,
65                                         dataType: )" + dataType + R"(
66                                     }
67                                 }]
68                             },
69                             descriptor: {
70                                 padList: )" + padList + R"(,
71                             }
72                         }
73                     },
74                     {
75                         layer_type: "OutputLayer",
76                         layer: {
77                             base:{
78                                 layerBindingId: 2,
79                                 base: {
80                                     index: 2,
81                                     layerName: "OutputLayer",
82                                     layerType: "Output",
83                                     inputSlots: [{
84                                         index: 0,
85                                         connection: {sourceLayerIndex:1, outputSlotIndex:0 },
86                                     }],
87                                     outputSlots: [{
88                                         index: 0,
89                                         tensorInfo: {
90                                             dimensions: )" + outputShape + R"(,
91                                             dataType: )" + dataType + R"(
92                                         },
93                                     }],
94                                 }
95                             }
96                         },
97                     }
98                 ]
99             }
100         )";
101         SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
102     }
103 };
104
105 struct SimplePadFixture : PadFixture
106 {
107     SimplePadFixture() : PadFixture("[ 2, 2, 2 ]",
108                                     "[ 0, 1, 2, 1, 2, 2 ]",
109                                     "[ 3, 5, 6 ]",
110                                     "QuantisedAsymm8") {}
111 };
112
113 BOOST_FIXTURE_TEST_CASE(SimplePadQuantisedAsymm8, SimplePadFixture)
114 {
115     RunTest<3, armnn::DataType::QAsymmU8>(0,
116                                                  {
117                                                     0, 4, 2, 5, 6, 1, 5, 2
118                                                  },
119                                                  {
120                                                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
121                                                     4, 0, 0, 0, 0, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0,
122                                                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,
123                                                     1, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0,
124                                                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
125                                                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
126                                                  });
127 }
128
129 BOOST_AUTO_TEST_SUITE_END()