blob: d1ff250d3ded90b0093af0685f7b726d85addf76 [file] [log] [blame]
Conor Kennedy79ffdf52019-03-01 14:24:54 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include <boost/test/unit_test.hpp>
7#include "ParserFlatbuffersSerializeFixture.hpp"
8#include "../Deserializer.hpp"
9
10#include <string>
11#include <iostream>
12
13BOOST_AUTO_TEST_SUITE(Deserializer)
14
15struct GreaterFixture : public ParserFlatbuffersSerializeFixture
16{
17 explicit GreaterFixture(const std::string & inputShape1,
18 const std::string & inputShape2,
19 const std::string & outputShape,
20 const std::string & inputDataType,
21 const std::string & outputDataType)
22 {
23 m_JsonString = R"(
24 {
25 inputIds: [0, 1],
26 outputIds: [3],
27 layers: [
28 {
29 layer_type: "InputLayer",
30 layer: {
31 base: {
32 layerBindingId: 0,
33 base: {
34 index: 0,
35 layerName: "InputLayer1",
36 layerType: "Input",
37 inputSlots: [{
38 index: 0,
39 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
40 }],
41 outputSlots: [ {
42 index: 0,
43 tensorInfo: {
44 dimensions: )" + inputShape1 + R"(,
45 dataType: )" + inputDataType + R"(
46 },
47 }],
48 },}},
49 },
50 {
51 layer_type: "InputLayer",
52 layer: {
53 base: {
54 layerBindingId: 1,
55 base: {
56 index:1,
57 layerName: "InputLayer2",
58 layerType: "Input",
59 inputSlots: [{
60 index: 0,
61 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
62 }],
63 outputSlots: [ {
64 index: 0,
65 tensorInfo: {
66 dimensions: )" + inputShape2 + R"(,
67 dataType: )" + inputDataType + R"(
68 },
69 }],
70 },}},
71 },
72 {
73 layer_type: "GreaterLayer",
74 layer : {
75 base: {
76 index:2,
77 layerName: "GreaterLayer",
78 layerType: "Greater",
79 inputSlots: [
80 {
81 index: 0,
82 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
83 },
84 {
85 index: 1,
86 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
87 }
88 ],
89 outputSlots: [ {
90 index: 0,
91 tensorInfo: {
92 dimensions: )" + outputShape + R"(,
93 dataType: Boolean
94 },
95 }],
96 }},
97 },
98 {
99 layer_type: "OutputLayer",
100 layer: {
101 base:{
102 layerBindingId: 0,
103 base: {
104 index: 3,
105 layerName: "OutputLayer",
106 layerType: "Output",
107 inputSlots: [{
108 index: 0,
109 connection: {sourceLayerIndex:2, outputSlotIndex:0 },
110 }],
111 outputSlots: [ {
112 index: 0,
113 tensorInfo: {
114 dimensions: )" + outputShape + R"(,
115 dataType: )" + outputDataType + R"(
116 },
117 }],
118 }}},
119 }]
120 }
121 )";
122 Setup();
123 }
124};
125
126
127struct SimpleGreaterFixtureQuantisedAsymm8 : GreaterFixture
128{
129 SimpleGreaterFixtureQuantisedAsymm8() : GreaterFixture("[ 2, 2 ]", // input1Shape
130 "[ 2, 2 ]", // input2Shape
131 "[ 2, 2 ]", // outputShape
132 "QuantisedAsymm8", // inputDataType
133 "Float32") {} // outputDataType
134};
135
136struct SimpleGreaterFixtureFloat32 : GreaterFixture
137{
138 SimpleGreaterFixtureFloat32() : GreaterFixture("[ 2, 2, 1, 1 ]", // input1Shape
139 "[ 2, 2, 1, 1 ]", // input2Shape
140 "[ 2, 2, 1, 1 ]", // outputShape
141 "Float32", // inputDataType
142 "Float32") {} // outputDataType
143};
144
145struct SimpleGreaterFixtureBroadcast : GreaterFixture
146{
147 SimpleGreaterFixtureBroadcast() : GreaterFixture("[ 1, 2, 2, 2 ]", // input1Shape
148 "[ 1, 1, 1, 1 ]", // input2Shape
149 "[ 1, 2, 2, 2 ]", // outputShape
150 "Float32", // inputDataType
151 "Float32") {} // outputDataType
152};
153
154
155BOOST_FIXTURE_TEST_CASE(GreaterQuantisedAsymm8, SimpleGreaterFixtureQuantisedAsymm8)
156{
157 RunTest<2, armnn::DataType::QuantisedAsymm8, armnn::DataType::Boolean>(
158 0,
159 {{"InputLayer1", { 1, 5, 8, 7 }},
160 { "InputLayer2", { 4, 0, 6, 7 }}},
161 {{"OutputLayer", { 0, 1, 1, 0 }}});
162}
163
164BOOST_FIXTURE_TEST_CASE(GreaterFloat32, SimpleGreaterFixtureFloat32)
165{
166 RunTest<4, armnn::DataType::Float32, armnn::DataType::Boolean>(
167 0,
168 {{"InputLayer1", { 1.0f, 2.0f, 3.0f, 4.0f }},
169 { "InputLayer2", { 1.0f, 5.0f, 2.0f, 2.0f }}},
170 {{"OutputLayer", { 0, 0, 1, 1 }}});
171}
172
173BOOST_FIXTURE_TEST_CASE(GreaterBroadcast, SimpleGreaterFixtureBroadcast)
174{
175 RunTest<4, armnn::DataType::Float32, armnn::DataType::Boolean>(
176 0,
177 {{"InputLayer1", { 1, 2, 3, 4, 5, 6, 7, 8 }},
178 {"InputLayer2", { 1 }}},
179 {{"OutputLayer", { 0, 1, 1, 1, 1, 1, 1, 1 }}});
180}
181
182BOOST_AUTO_TEST_SUITE_END()