blob: fea695d3cd030cba011c1bee6892841c40c041e1 [file] [log] [blame]
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +00006#include "ParserFlatbuffersSerializeFixture.hpp"
Finn Williams85d36712021-01-26 22:30:06 +00007#include <armnnDeserializer/IDeserializer.hpp>
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +00008
9#include <string>
10
Sadik Armagan1625efc2021-06-10 18:24:34 +010011TEST_SUITE("Deserializer_BatchToSpaceND")
12{
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +000013struct BatchToSpaceNdFixture : public ParserFlatbuffersSerializeFixture
14{
15 explicit BatchToSpaceNdFixture(const std::string &inputShape,
16 const std::string &blockShape,
17 const std::string &crops,
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: "BatchToSpaceNdLayer",
53 layer: {
54 base: {
55 index: 1,
56 layerName: "BatchToSpaceNdLayer",
57 layerType: "BatchToSpaceNd",
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 crops: )" + crops + 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 SimpleBatchToSpaceNdFixture : BatchToSpaceNdFixture
109{
110 SimpleBatchToSpaceNdFixture() : BatchToSpaceNdFixture("[ 4, 2, 2, 1 ]",
111 "[ 2, 2 ]",
112 "[ 0, 0, 0, 0 ]",
113 "NHWC",
114 "[ 1, 4, 4, 1 ]",
115 "Float32") {}
116};
117
Sadik Armagan1625efc2021-06-10 18:24:34 +0100118TEST_CASE_FIXTURE(SimpleBatchToSpaceNdFixture, "SimpleBatchToSpaceNdFloat32")
Nattapat Chaimanowong6b4ed982019-02-26 17:24:13 +0000119{
120 RunTest<4, armnn::DataType::Float32>(0,
121 {
122 1.0f, 3.0f, 9.0f, 11.0f,
123 2.0f, 4.0f, 10.0f, 12.0f,
124 5.0f, 7.0f, 13.0f, 15.0f,
125 6.0f, 8.0f, 14.0f, 16.0f
126 },
127 {
128 1.0f, 2.0f, 3.0f, 4.0f,
129 5.0f, 6.0f, 7.0f, 8.0f,
130 9.0f, 10.0f, 11.0f, 12.0f,
131 13.0f, 14.0f, 15.0f, 16.0f
132 });
133}
134
Sadik Armagan1625efc2021-06-10 18:24:34 +0100135}