blob: 44c66d308ab751316fb625aebc7e77fe0a21a279 [file] [log] [blame]
Aron Virginas-Tara2f4b4b2019-09-20 11:21:14 +01001//
2// Copyright © 2019 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ParserFlatbuffersSerializeFixture.hpp"
7
8#include "../Deserializer.hpp"
9
10#include <boost/test/unit_test.hpp>
11
12#include <string>
13
14BOOST_AUTO_TEST_SUITE(Deserializer)
15
16struct SliceFixture : public ParserFlatbuffersSerializeFixture
17{
18 explicit SliceFixture(const std::string& inputShape,
19 const std::string& outputShape,
20 const std::string& begin,
21 const std::string& size,
22 const std::string& dataType)
23 {
24 m_JsonString = R"(
25 {
26 inputIds: [0],
27 outputIds: [2],
28 layers: [
29 {
30 layer_type: "InputLayer",
31 layer: {
32 base: {
33 layerBindingId: 0,
34 base: {
35 index: 0,
36 layerName: "InputLayer",
37 layerType: "Input",
38 inputSlots: [{
39 index: 0,
40 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
41 }],
42 outputSlots: [{
43 index: 0,
44 tensorInfo: {
45 dimensions: )" + inputShape + R"(,
46 dataType: )" + dataType + R"(
47 }
48 }]
49 }
50 }
51 }
52 },
53 {
54 layer_type: "SliceLayer",
55 layer: {
56 base: {
57 index: 1,
58 layerName: "SliceLayer",
59 layerType: "Slice",
60 inputSlots: [{
61 index: 0,
62 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
63 }],
64 outputSlots: [{
65 index: 0,
66 tensorInfo: {
67 dimensions: )" + outputShape + R"(,
68 dataType: )" + dataType + R"(
69 }
70 }]
71 },
72 descriptor: {
73 begin: )" + begin + R"(,
74 size: )" + size + R"(,
75 }
76 }
77 },
78 {
79 layer_type: "OutputLayer",
80 layer: {
81 base:{
82 layerBindingId: 2,
83 base: {
84 index: 2,
85 layerName: "OutputLayer",
86 layerType: "Output",
87 inputSlots: [{
88 index: 0,
89 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
90 }],
91 outputSlots: [{
92 index: 0,
93 tensorInfo: {
94 dimensions: )" + outputShape + R"(,
95 dataType: )" + dataType + R"(
96 },
97 }],
98 }
99 }
100 },
101 }
102 ]
103 }
104 )";
105 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
106 }
107};
108
109struct SimpleSliceFixture : SliceFixture
110{
111 SimpleSliceFixture() : SliceFixture("[ 3, 2, 3, 5 ]", // input shape
112 "[ 2, 1, 2, 3 ]", // output shape
113 "[ 1, 0, 1, 2 ]", // begin
114 "[ 2, 1, 2, 3 ]", // size
115 "Float32") {} // data type
116};
117
118BOOST_FIXTURE_TEST_CASE(SimpleSliceFloat32, SimpleSliceFixture)
119{
120 RunTest<4, armnn::DataType::Float32>(
121 0,
122 {
123 0.f, 1.f, 2.f, 3.f, 4.f,
124 5.f, 6.f, 7.f, 8.f, 9.f,
125 10.f, 11.f, 12.f, 13.f, 14.f,
126
127 15.f, 16.f, 17.f, 18.f, 19.f,
128 20.f, 21.f, 22.f, 23.f, 24.f,
129 25.f, 26.f, 27.f, 28.f, 29.f,
130
131
132 30.f, 31.f, 32.f, 33.f, 34.f,
133 35.f, 36.f, 37.f, 38.f, 39.f,
134 40.f, 41.f, 42.f, 43.f, 44.f,
135
136 45.f, 46.f, 47.f, 48.f, 49.f,
137 50.f, 51.f, 52.f, 53.f, 54.f,
138 55.f, 56.f, 57.f, 58.f, 59.f,
139
140
141 60.f, 61.f, 62.f, 63.f, 64.f,
142 65.f, 66.f, 67.f, 68.f, 69.f,
143 70.f, 71.f, 72.f, 73.f, 74.f,
144
145 75.f, 76.f, 77.f, 78.f, 79.f,
146 80.f, 81.f, 82.f, 83.f, 84.f,
147 85.f, 86.f, 87.f, 88.f, 89.f
148 },
149 {
150 37.f, 38.f, 39.f,
151 42.f, 43.f, 44.f,
152
153 67.f, 68.f, 69.f,
154 72.f, 73.f, 74.f
155 });
156}
157
158BOOST_AUTO_TEST_SUITE_END()