blob: 0c8675b45074ba2098588b30dd65c7a89b4fb3a6 [file] [log] [blame]
Nattapat Chaimanowong45286992019-02-26 15:53:02 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Nattapat Chaimanowong45286992019-02-26 15:53:02 +00006#include "ParserFlatbuffersSerializeFixture.hpp"
Finn Williams85d36712021-01-26 22:30:06 +00007#include <armnnDeserializer/IDeserializer.hpp>
Nattapat Chaimanowong45286992019-02-26 15:53:02 +00008
9#include <string>
10
Sadik Armagan1625efc2021-06-10 18:24:34 +010011TEST_SUITE("Deserializer_SpaceToBatchND")
12{
Nattapat Chaimanowong45286992019-02-26 15:53:02 +000013struct SpaceToBatchNdFixture : public ParserFlatbuffersSerializeFixture
14{
15 explicit SpaceToBatchNdFixture(const std::string &inputShape,
16 const std::string &blockShape,
17 const std::string &padList,
18 const std::string &dataLayout,
19 const std::string &outputShape,
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: "SpaceToBatchNdLayer",
53 layer: {
54 base: {
55 index: 1,
56 layerName: "SpaceToBatchNdLayer",
57 layerType: "SpaceToBatchNd",
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 blockShape: )" + blockShape + R"(,
72 padList: )" + padList + R"(,
73 dataLayout: )" + dataLayout + R"(,
74 }
75 }
76 },
77 {
78 layer_type: "OutputLayer",
79 layer: {
80 base:{
81 layerBindingId: 2,
82 base: {
83 index: 2,
84 layerName: "OutputLayer",
85 layerType: "Output",
86 inputSlots: [{
87 index: 0,
88 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
89 }],
90 outputSlots: [{
91 index: 0,
92 tensorInfo: {
93 dimensions: )" + outputShape + R"(,
94 dataType: )" + dataType + R"(
95 },
96 }],
97 }
98 }
99 },
100 }
101 ]
102 }
103 )";
104 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
105 }
106};
107
108struct SimpleSpaceToBatchNdFixture : SpaceToBatchNdFixture
109{
110 SimpleSpaceToBatchNdFixture() : SpaceToBatchNdFixture("[ 2, 1, 2, 4 ]",
111 "[ 2, 2 ]",
112 "[ 0, 0, 2, 0 ]",
113 "NCHW",
114 "[ 8, 1, 1, 3 ]",
115 "Float32") {}
116};
117
Sadik Armagan1625efc2021-06-10 18:24:34 +0100118TEST_CASE_FIXTURE(SimpleSpaceToBatchNdFixture, "SimpleBatchToSpaceNdFloat32")
Nattapat Chaimanowong45286992019-02-26 15:53:02 +0000119{
120 RunTest<4, armnn::DataType::Float32>(0,
121 {
122 1.0f, 2.0f, 3.0f, 4.0f,
123 5.0f, 6.0f, 7.0f, 8.0f,
124 9.0f, 10.0f, 11.0f, 12.0f,
125 13.0f, 14.0f, 15.0f, 16.0f
126 },
127 {
128 0.0f, 1.0f, 3.0f,
129 0.0f, 9.0f, 11.0f,
130 0.0f, 2.0f, 4.0f,
131 0.0f, 10.0f, 12.0f,
132 0.0f, 5.0f, 7.0f,
133 0.0f, 13.0f, 15.0f,
134 0.0f, 6.0f, 8.0f,
135 0.0f, 14.0f, 16.0f
136 });
137}
138
Sadik Armagan1625efc2021-06-10 18:24:34 +0100139}