blob: 66269dc4c353841b5b6bd579bd5896c4674d0fda [file] [log] [blame]
Sadik Armagandbb0c0c2019-02-21 09:01:41 +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"
Finn Williams85d36712021-01-26 22:30:06 +00008#include <armnnDeserializer/IDeserializer.hpp>
Sadik Armagandbb0c0c2019-02-21 09:01:41 +00009
10#include <string>
Sadik Armagandbb0c0c2019-02-21 09:01:41 +000011
12BOOST_AUTO_TEST_SUITE(DeserializeParser)
13
14struct FullyConnectedFixture : public ParserFlatbuffersSerializeFixture
15{
16 explicit FullyConnectedFixture(const std::string & inputShape1,
17 const std::string & outputShape,
18 const std::string & weightsShape,
19 const std::string & dataType)
20 {
21 m_JsonString = R"(
22 {
23 inputIds: [0],
24 outputIds: [2],
25 layers: [{
26 layer_type: "InputLayer",
27 layer: {
28 base: {
29 layerBindingId: 0,
30 base: {
31 index: 0,
32 layerName: "InputLayer",
33 layerType: "Input",
34 inputSlots: [{
35 index: 0,
36 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
37 }],
38 outputSlots: [{
39 index: 0,
40 tensorInfo: {
41 dimensions: )" + inputShape1 + R"(,
42 dataType: )" + dataType + R"(,
43 quantizationScale: 1.0,
44 quantizationOffset: 0
45 },
46 }]
47 },
48 }
49 },
50 },
51 {
52 layer_type: "FullyConnectedLayer",
53 layer : {
54 base: {
55 index:1,
56 layerName: "FullyConnectedLayer",
57 layerType: "FullyConnected",
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 quantizationScale: 2.0,
68 quantizationOffset: 0
69 },
70 }],
71 },
72 descriptor: {
73 biasEnabled: false,
74 transposeWeightsMatrix: true
75 },
76 weights: {
77 info: {
78 dimensions: )" + weightsShape + R"(,
79 dataType: )" + dataType + R"(,
80 quantizationScale: 1.0,
81 quantizationOffset: 0
82 },
83 data_type: ByteData,
84 data: {
85 data: [
86 2, 3, 4, 5
87 ],
88 }
89 }
90 },
91 },
92 {
93 layer_type: "OutputLayer",
94 layer: {
95 base:{
96 layerBindingId: 0,
97 base: {
98 index: 2,
99 layerName: "OutputLayer",
100 layerType: "Output",
101 inputSlots: [{
102 index: 0,
103 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
104 }],
105 outputSlots: [ {
106 index: 0,
107 tensorInfo: {
108 dimensions: )" + outputShape + R"(,
109 dataType: )" + dataType + R"(
110 },
111 }],
112 }
113 }},
114 }]
115 }
116 )";
117 Setup();
118 }
119};
120
121struct FullyConnectedWithNoBiasFixture : FullyConnectedFixture
122{
123 FullyConnectedWithNoBiasFixture()
124 : FullyConnectedFixture("[ 1, 4, 1, 1 ]", // inputShape
125 "[ 1, 1 ]", // outputShape
126 "[ 1, 4 ]", // filterShape
127 "QuantisedAsymm8") // filterData
128 {}
129};
130
131BOOST_FIXTURE_TEST_CASE(FullyConnectedWithNoBias, FullyConnectedWithNoBiasFixture)
132{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000133 RunTest<2, armnn::DataType::QAsymmU8>(
Sadik Armagandbb0c0c2019-02-21 09:01:41 +0000134 0,
135 {{"InputLayer", { 10, 20, 30, 40 }}},
136 {{"OutputLayer", { 400/2 }}});
137}
138
139BOOST_AUTO_TEST_SUITE_END()