xref: /aosp_15_r20/external/armnn/src/armnnDeserializer/test/DeserializeShape.cpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
1 //
2 // Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ParserFlatbuffersSerializeFixture.hpp"
7 #include <armnnDeserializer/IDeserializer.hpp>
8 
9 #include <doctest/doctest.h>
10 
11 #include <string>
12 
13 TEST_SUITE("Deserializer_Shape")
14 {
15 struct ShapeFixture : public ParserFlatbuffersSerializeFixture
16 {
ShapeFixtureShapeFixture17     explicit ShapeFixture()
18     {
19         m_JsonString = R"(
20             {
21               layers: [
22                 {
23                   layer_type: "InputLayer",
24                   layer: {
25                     base: {
26                       base: {
27                         layerName: "InputLayer",
28                         layerType: "Input",
29                         inputSlots: [
30 
31                         ],
32                         outputSlots: [
33                           {
34                             tensorInfo: {
35                               dimensions: [
36                                 1,
37                                 3,
38                                 3,
39                                 1
40                               ],
41                               dataType: "Signed32",
42                               quantizationScale: 0.0
43                             }
44                           }
45                         ]
46                       }
47                     }
48                   }
49                 },
50                 {
51                   layer_type: "ShapeLayer",
52                   layer: {
53                     base: {
54                       index: 1,
55                       layerName: "shape",
56                       layerType: "Shape",
57                       inputSlots: [
58                         {
59                           connection: {
60                             sourceLayerIndex: 0,
61                             outputSlotIndex: 0
62                           }
63                         }
64                       ],
65                       outputSlots: [
66                         {
67                           tensorInfo: {
68                             dimensions: [
69                               4
70                             ],
71                             dataType: "Signed32",
72                             quantizationScale: 0.0
73                           }
74                         }
75                       ]
76                     }
77                   }
78                 },
79                 {
80                   layer_type: "OutputLayer",
81                   layer: {
82                     base: {
83                       base: {
84                         index: 2,
85                         layerName: "OutputLayer",
86                         layerType: "Output",
87                         inputSlots: [
88                           {
89                             connection: {
90                               sourceLayerIndex: 1,
91                               outputSlotIndex: 0
92                             }
93                           }
94                         ],
95                         outputSlots: [
96 
97                         ]
98                       }
99                     }
100                   }
101                 }
102               ],
103               inputIds: [
104                 0
105               ],
106               outputIds: [
107                 0
108               ],
109               featureVersions: {
110                 bindingIdsScheme: 1
111               }
112             }
113     )";
114         Setup();
115     }
116 };
117 
118 struct SimpleShapeFixture : ShapeFixture
119 {
SimpleShapeFixtureSimpleShapeFixture120     SimpleShapeFixture() : ShapeFixture() {}
121 };
122 
123 TEST_CASE_FIXTURE(SimpleShapeFixture, "DeserializeShape")
124 {
125     RunTest<1, armnn::DataType::Signed32>(
126             0,
127             {{"InputLayer", { 1, 1, 1, 1, 1, 1, 1, 1, 1 }}},
128             {{"OutputLayer",{ 1, 3, 3, 1 }}});
129 }
130 
131 }
132