blob: 0956fc531ac03989b0d090dd20c0b6ead10477fb [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
Sadik Armagan5f450272019-02-12 14:31:45 +00006#include "ParserFlatbuffersSerializeFixture.hpp"
Finn Williams85d36712021-01-26 22:30:06 +00007#include <armnnDeserializer/IDeserializer.hpp>
Sadik Armagan5f450272019-02-12 14:31:45 +00008
Jan Eilers8eb25602020-03-09 12:13:48 +00009#include <armnn/utility/IgnoreUnused.hpp>
10
Sadik Armagan5f450272019-02-12 14:31:45 +000011#include <string>
Sadik Armagan5f450272019-02-12 14:31:45 +000012
Sadik Armagan1625efc2021-06-10 18:24:34 +010013TEST_SUITE("Deserializer_Multiplication")
14{
Sadik Armagan5f450272019-02-12 14:31:45 +000015struct 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 {
Jan Eilers8eb25602020-03-09 12:13:48 +000023 armnn::IgnoreUnused(activation);
Sadik Armagan5f450272019-02-12 14:31:45 +000024 m_JsonString = R"(
25 {
26 inputIds: [0, 1],
27 outputIds: [3],
28 layers: [
29 {
30 layer_type: "InputLayer",
31 layer: {
32 base: {
33 layerBindingId: 0,
34 base: {
35 index: 0,
36 layerName: "InputLayer1",
37 layerType: "Input",
38 inputSlots: [{
39 index: 0,
40 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
41 }],
42 outputSlots: [ {
43 index: 0,
44 tensorInfo: {
45 dimensions: )" + inputShape1 + R"(,
46 dataType: )" + dataType + R"(
47 },
48 }],
49 },}},
50 },
51 {
52 layer_type: "InputLayer",
53 layer: {
54 base: {
55 layerBindingId: 1,
56 base: {
57 index:1,
58 layerName: "InputLayer2",
59 layerType: "Input",
60 inputSlots: [{
61 index: 0,
62 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
63 }],
64 outputSlots: [ {
65 index: 0,
66 tensorInfo: {
67 dimensions: )" + inputShape2 + R"(,
68 dataType: )" + dataType + R"(
69 },
70 }],
71 },}},
72 },
73 {
74 layer_type: "MultiplicationLayer",
75 layer : {
76 base: {
77 index:2,
78 layerName: "MultiplicationLayer",
79 layerType: "Multiplication",
80 inputSlots: [
81 {
82 index: 0,
83 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
84 },
85 {
86 index: 1,
87 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
88 }
89 ],
90 outputSlots: [ {
91 index: 0,
92 tensorInfo: {
93 dimensions: )" + outputShape + R"(,
94 dataType: )" + dataType + R"(
95 },
96 }],
97 }},
98 },
99 {
100 layer_type: "OutputLayer",
101 layer: {
102 base:{
Saoirse Stewart3fcef202019-02-14 14:57:37 +0000103 layerBindingId: 0,
Sadik Armagan5f450272019-02-12 14:31:45 +0000104 base: {
105 index: 3,
106 layerName: "OutputLayer",
107 layerType: "Output",
108 inputSlots: [{
109 index: 0,
110 connection: {sourceLayerIndex:2, outputSlotIndex:0 },
111 }],
112 outputSlots: [ {
113 index: 0,
114 tensorInfo: {
115 dimensions: )" + outputShape + R"(,
116 dataType: )" + dataType + R"(
117 },
118 }],
119 }}},
120 }]
121 }
122 )";
123 Setup();
124 }
125};
126
127
128struct SimpleMultiplicationFixture : MultiplicationFixture
129{
130 SimpleMultiplicationFixture() : MultiplicationFixture("[ 2, 2 ]",
131 "[ 2, 2 ]",
132 "[ 2, 2 ]",
133 "QuantisedAsymm8") {}
134};
135
136struct SimpleMultiplicationFixture2 : MultiplicationFixture
137{
138 SimpleMultiplicationFixture2() : MultiplicationFixture("[ 2, 2, 1, 1 ]",
139 "[ 2, 2, 1, 1 ]",
140 "[ 2, 2, 1, 1 ]",
141 "Float32") {}
142};
143
Sadik Armagan1625efc2021-06-10 18:24:34 +0100144TEST_CASE_FIXTURE(SimpleMultiplicationFixture, "MultiplicationQuantisedAsymm8")
Sadik Armagan5f450272019-02-12 14:31:45 +0000145{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000146 RunTest<2, armnn::DataType::QAsymmU8>(
Sadik Armagan5f450272019-02-12 14:31:45 +0000147 0,
148 {{"InputLayer1", { 0, 1, 2, 3 }},
149 {"InputLayer2", { 4, 5, 6, 7 }}},
150 {{"OutputLayer", { 0, 5, 12, 21 }}});
151}
152
Sadik Armagan1625efc2021-06-10 18:24:34 +0100153TEST_CASE_FIXTURE(SimpleMultiplicationFixture2, "MultiplicationFloat32")
Sadik Armagan5f450272019-02-12 14:31:45 +0000154{
155 RunTest<4, armnn::DataType::Float32>(
156 0,
157 {{"InputLayer1", { 100, 40, 226, 9 }},
158 {"InputLayer2", { 5, 8, 1, 12 }}},
159 {{"OutputLayer", { 500, 320, 226, 108 }}});
160}
161
Sadik Armagan1625efc2021-06-10 18:24:34 +0100162}