blob: 41e65d418d2d85e297faf06375d9251c96f3c675 [file] [log] [blame]
Éanna Ó Catháin58885892019-02-27 16:16:39 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Éanna Ó Catháin58885892019-02-27 16:16:39 +00006#include "ParserFlatbuffersSerializeFixture.hpp"
Finn Williams85d36712021-01-26 22:30:06 +00007#include <armnnDeserializer/IDeserializer.hpp>
Éanna Ó Catháin58885892019-02-27 16:16:39 +00008
9#include <string>
Éanna Ó Catháin58885892019-02-27 16:16:39 +000010
Sadik Armagan1625efc2021-06-10 18:24:34 +010011TEST_SUITE("Deserializer_Division")
12{
Éanna Ó Catháin58885892019-02-27 16:16:39 +000013struct DivisionFixture : public ParserFlatbuffersSerializeFixture
14{
15 explicit DivisionFixture(const std::string & inputShape1,
16 const std::string & inputShape2,
17 const std::string & outputShape,
18 const std::string & dataType)
19 {
20 m_JsonString = R"(
21 {
22 inputIds: [0, 1],
23 outputIds: [3],
24 layers: [
25 {
26 layer_type: "InputLayer",
27 layer: {
28 base: {
29 layerBindingId: 0,
30 base: {
31 index: 0,
32 layerName: "InputLayer1",
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 },
44 }],
45 },}},
46 },
47 {
48 layer_type: "InputLayer",
49 layer: {
50 base: {
51 layerBindingId: 1,
52 base: {
53 index:1,
54 layerName: "InputLayer2",
55 layerType: "Input",
56 inputSlots: [{
57 index: 0,
58 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
59 }],
60 outputSlots: [ {
61 index: 0,
62 tensorInfo: {
63 dimensions: )" + inputShape2 + R"(,
64 dataType: )" + dataType + R"(
65 },
66 }],
67 },}},
68 },
69 {
70 layer_type: "DivisionLayer",
71 layer : {
72 base: {
73 index:2,
74 layerName: "DivisionLayer",
75 layerType: "Division",
76 inputSlots: [
77 {
78 index: 0,
79 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
80 },
81 {
82 index: 1,
83 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
84 }
85 ],
86 outputSlots: [ {
87 index: 0,
88 tensorInfo: {
89 dimensions: )" + outputShape + R"(,
90 dataType: )" + dataType + R"(
91 },
92 }],
93 }},
94 },
95 {
96 layer_type: "OutputLayer",
97 layer: {
98 base:{
99 layerBindingId: 0,
100 base: {
101 index: 3,
102 layerName: "OutputLayer",
103 layerType: "Output",
104 inputSlots: [{
105 index: 0,
106 connection: {sourceLayerIndex:2, outputSlotIndex:0 },
107 }],
108 outputSlots: [ {
109 index: 0,
110 tensorInfo: {
111 dimensions: )" + outputShape + R"(,
112 dataType: )" + dataType + R"(
113 },
114 }],
115 }}},
116 }]
117 }
118 )";
119 Setup();
120 }
121};
122
123
124struct SimpleDivisionFixture : DivisionFixture
125{
126 SimpleDivisionFixture() : DivisionFixture("[ 2, 2 ]",
127 "[ 2, 2 ]",
128 "[ 2, 2 ]",
129 "QuantisedAsymm8") {}
130};
131
132struct SimpleDivisionFixture2 : DivisionFixture
133{
134 SimpleDivisionFixture2() : DivisionFixture("[ 2, 2, 1, 1 ]",
135 "[ 2, 2, 1, 1 ]",
136 "[ 2, 2, 1, 1 ]",
137 "Float32") {}
138};
139
Sadik Armagan1625efc2021-06-10 18:24:34 +0100140TEST_CASE_FIXTURE(SimpleDivisionFixture, "DivisionQuantisedAsymm8")
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000141{
Derek Lambertif90c56d2020-01-10 17:14:08 +0000142 RunTest<2, armnn::DataType::QAsymmU8>(
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000143 0,
144 {{"InputLayer1", { 0, 5, 24, 21 }},
145 {"InputLayer2", { 4, 1, 6, 7 }}},
146 {{"OutputLayer", { 0, 5, 3, 3 }}});
147}
148
Sadik Armagan1625efc2021-06-10 18:24:34 +0100149TEST_CASE_FIXTURE(SimpleDivisionFixture2, "DivisionFloat32")
Éanna Ó Catháin58885892019-02-27 16:16:39 +0000150{
151 RunTest<4, armnn::DataType::Float32>(
152 0,
153 {{"InputLayer1", { 100, 40, 226, 9 }},
154 {"InputLayer2", { 5, 8, 1, 3 }}},
155 {{"OutputLayer", { 20, 5, 226, 3 }}});
156}
157
Sadik Armagan1625efc2021-06-10 18:24:34 +0100158}