ArmNN
 21.11
DeserializeDepthToSpace.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
9 
10 #include <string>
11 
12 TEST_SUITE("Deserializer_DepthToSpace")
13 {
14 struct DepthToSpaceFixture : public ParserFlatbuffersSerializeFixture
15 {
16  explicit DepthToSpaceFixture(const std::string& inputShape,
17  const std::string& outputShape,
18  const std::string& blockSize,
19  const std::string& dataLayout,
20  const std::string& dataType)
21  {
22  m_JsonString = R"(
23  {
24  inputIds: [0],
25  outputIds: [2],
26  layers: [
27  {
28  layer_type: "InputLayer",
29  layer: {
30  base: {
31  layerBindingId: 0,
32  base: {
33  index: 0,
34  layerName: "InputLayer",
35  layerType: "Input",
36  inputSlots: [{
37  index: 0,
38  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
39  }],
40  outputSlots: [{
41  index: 0,
42  tensorInfo: {
43  dimensions: )" + inputShape + R"(,
44  dataType: )" + dataType + R"(
45  }
46  }]
47  }
48  }
49  }
50  },
51  {
52  layer_type: "DepthToSpaceLayer",
53  layer: {
54  base: {
55  index: 1,
56  layerName: "DepthToSpaceLayer",
57  layerType: "DepthToSpace",
58  inputSlots: [{
59  index: 0,
60  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
61  }],
62  outputSlots: [{
63  index: 0,
64  tensorInfo: {
65  dimensions: )" + outputShape + R"(,
66  dataType: )" + dataType + R"(
67  }
68  }]
69  },
70  descriptor: {
71  blockSize: )" + blockSize + R"(,
72  dataLayout: )" + dataLayout + R"(,
73  }
74  }
75  },
76  {
77  layer_type: "OutputLayer",
78  layer: {
79  base:{
80  layerBindingId: 2,
81  base: {
82  index: 2,
83  layerName: "OutputLayer",
84  layerType: "Output",
85  inputSlots: [{
86  index: 0,
87  connection: {sourceLayerIndex:1, outputSlotIndex:0 },
88  }],
89  outputSlots: [{
90  index: 0,
91  tensorInfo: {
92  dimensions: )" + outputShape + R"(,
93  dataType: )" + dataType + R"(
94  },
95  }],
96  }
97  }
98  },
99  }
100  ]
101  }
102  )";
103  SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
104  }
105 };
106 
107 struct DepthToSpaceFloat32Fixture : DepthToSpaceFixture
108 {
109  DepthToSpaceFloat32Fixture() : DepthToSpaceFixture("[ 1, 2, 2, 4 ]", // input shape
110  "[ 1, 4, 4, 1 ]", // output shape
111  "2", // block size
112  "NHWC", // data layout
113  "Float32") {} // data type
114 };
115 
116 TEST_CASE_FIXTURE(DepthToSpaceFloat32Fixture, "DepthToSpaceFloat32")
117 {
118  RunTest<4, armnn::DataType::Float32>(
119  0,
120  {
121  1.f, 2.f, 3.f, 4.f,
122  5.f, 6.f, 7.f, 8.f,
123  9.f, 10.f, 11.f, 12.f,
124  13.f, 14.f, 15.f, 16.f
125  },
126  {
127  1.f, 2.f, 5.f, 6.f,
128  3.f, 4.f, 7.f, 8.f,
129  9.f, 10.f, 13.f, 14.f,
130  11.f, 12.f, 15.f, 16.f
131  });
132 }
133 
134 }
TEST_SUITE("Deserializer_DepthToSpace")
void SetupSingleInputSingleOutput(const std::string &inputName, const std::string &outputName)
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")