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