blob: a9dbfbf7daabab547a9e34d3480444f7eec5cd13 [file] [log] [blame]
Sadik Armagan5f450272019-02-12 14:31:45 +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"
Derek Lamberti0028d1b2019-02-20 13:57:42 +00008#include "../Deserializer.hpp"
Sadik Armagan5f450272019-02-12 14:31:45 +00009
10#include <string>
11#include <iostream>
12
Derek Lamberti0028d1b2019-02-20 13:57:42 +000013BOOST_AUTO_TEST_SUITE(Deserializer)
Sadik Armagan5f450272019-02-12 14:31:45 +000014
15struct MultiplicationFixture : public ParserFlatbuffersSerializeFixture
16{
17 explicit MultiplicationFixture(const std::string & inputShape1,
18 const std::string & inputShape2,
19 const std::string & outputShape,
20 const std::string & dataType,
21 const std::string & activation="NONE")
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: )" + dataType + 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: )" + dataType + R"(
68 },
69 }],
70 },}},
71 },
72 {
73 layer_type: "MultiplicationLayer",
74 layer : {
75 base: {
76 index:2,
77 layerName: "MultiplicationLayer",
78 layerType: "Multiplication",
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: )" + dataType + R"(
94 },
95 }],
96 }},
97 },
98 {
99 layer_type: "OutputLayer",
100 layer: {
101 base:{
Saoirse Stewart3fcef202019-02-14 14:57:37 +0000102 layerBindingId: 0,
Sadik Armagan5f450272019-02-12 14:31:45 +0000103 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: )" + dataType + R"(
116 },
117 }],
118 }}},
119 }]
120 }
121 )";
122 Setup();
123 }
124};
125
126
127struct SimpleMultiplicationFixture : MultiplicationFixture
128{
129 SimpleMultiplicationFixture() : MultiplicationFixture("[ 2, 2 ]",
130 "[ 2, 2 ]",
131 "[ 2, 2 ]",
132 "QuantisedAsymm8") {}
133};
134
135struct SimpleMultiplicationFixture2 : MultiplicationFixture
136{
137 SimpleMultiplicationFixture2() : MultiplicationFixture("[ 2, 2, 1, 1 ]",
138 "[ 2, 2, 1, 1 ]",
139 "[ 2, 2, 1, 1 ]",
140 "Float32") {}
141};
142
143BOOST_FIXTURE_TEST_CASE(MultiplicationQuantisedAsymm8, SimpleMultiplicationFixture)
144{
145 RunTest<2, armnn::DataType::QuantisedAsymm8>(
146 0,
147 {{"InputLayer1", { 0, 1, 2, 3 }},
148 {"InputLayer2", { 4, 5, 6, 7 }}},
149 {{"OutputLayer", { 0, 5, 12, 21 }}});
150}
151
152BOOST_FIXTURE_TEST_CASE(MultiplicationFloat32, SimpleMultiplicationFixture2)
153{
154 RunTest<4, armnn::DataType::Float32>(
155 0,
156 {{"InputLayer1", { 100, 40, 226, 9 }},
157 {"InputLayer2", { 5, 8, 1, 12 }}},
158 {{"OutputLayer", { 500, 320, 226, 108 }}});
159}
160
161BOOST_AUTO_TEST_SUITE_END()