ArmNN
 22.08
DeserializeActivation.cpp File Reference
#include "ParserFlatbuffersSerializeFixture.hpp"
#include <armnnDeserializer/IDeserializer.hpp>
#include <doctest/doctest.h>
#include <string>

Go to the source code of this file.

Functions

 TEST_SUITE ("DeserializeParser_Activation")
 

Function Documentation

◆ TEST_SUITE()

TEST_SUITE ( "DeserializeParser_Activation"  )

Definition at line 13 of file DeserializeActivation.cpp.

References ActivationFixture::a, ActivationFixture::ActivationFixture(), ActivationFixture::b, and TEST_CASE_FIXTURE().

14 {
16 {
17  explicit ActivationFixture(const std::string& inputShape,
18  const std::string& outputShape,
19  const std::string& dataType,
20  const std::string& activationType="Sigmoid",
21  const std::string& a = "0.0",
22  const std::string& b = "0.0")
23  {
24  m_JsonString = R"(
25  {
26  inputIds: [0],
27  outputIds: [2],
28  layers: [{
29  layer_type: "InputLayer",
30  layer: {
31  base: {
32  layerBindingId: 0,
33  base: {
34  index: 0,
35  layerName: "InputLayer",
36  layerType: "Input",
37  inputSlots: [{
38  index: 0,
39  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
40  }],
41  outputSlots: [{
42  index: 0,
43  tensorInfo: {
44  dimensions: )" + inputShape + R"(,
45  dataType: )" + dataType + R"(
46  },
47  }],
48  },
49  }
50  },
51  },
52  {
53  layer_type: "ActivationLayer",
54  layer : {
55  base: {
56  index:1,
57  layerName: "ActivationLayer",
58  layerType: "Activation",
59  inputSlots: [{
60  index: 0,
61  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
62  }],
63  outputSlots: [{
64  index: 0,
65  tensorInfo: {
66  dimensions: )" + outputShape + R"(,
67  dataType: )" + dataType + R"(
68  },
69  }],
70  },
71  descriptor: {
72  a: )" + a + R"(,
73  b: )" + b + R"(,
74  activationFunction: )" + activationType + R"(
75  },
76  },
77  },
78  {
79  layer_type: "OutputLayer",
80  layer: {
81  base:{
82  layerBindingId: 2,
83  base: {
84  index: 2,
85  layerName: "OutputLayer",
86  layerType: "Output",
87  inputSlots: [{
88  index: 0,
89  connection: {sourceLayerIndex:1, outputSlotIndex:0 },
90  }],
91  outputSlots: [{
92  index: 0,
93  tensorInfo: {
94  dimensions: )" + outputShape + R"(,
95  dataType: )" + dataType + R"(
96  },
97  }],
98  }
99  }
100  },
101  }]
102  }
103  )";
104  Setup();
105  }
106 };
107 
108 struct SimpleActivationFixture : ActivationFixture
109 {
110  SimpleActivationFixture() : ActivationFixture("[1, 2, 2, 1]",
111  "[1, 2, 2, 1]",
112  "QuantisedAsymm8",
113  "ReLu") {}
114 };
115 
116 struct SimpleActivationFixture2 : ActivationFixture
117 {
118  SimpleActivationFixture2() : ActivationFixture("[1, 2, 2, 1]",
119  "[1, 2, 2, 1]",
120  "Float32",
121  "ReLu") {}
122 };
123 
124 struct SimpleActivationFixture3 : ActivationFixture
125 {
126  SimpleActivationFixture3() : ActivationFixture("[1, 2, 2, 1]",
127  "[1, 2, 2, 1]",
128  "QuantisedAsymm8",
129  "BoundedReLu",
130  "5.0",
131  "0.0") {}
132 };
133 
134 struct SimpleActivationFixture4 : ActivationFixture
135 {
136  SimpleActivationFixture4() : ActivationFixture("[1, 2, 2, 1]",
137  "[1, 2, 2, 1]",
138  "Float32",
139  "BoundedReLu",
140  "5.0",
141  "0.0") {}
142 };
143 
144 
145 TEST_CASE_FIXTURE(SimpleActivationFixture, "ActivationReluQuantisedAsymm8")
146 {
147  RunTest<4, armnn::DataType::QAsymmU8>(
148  0,
149  {{"InputLayer", {10, 0, 2, 0}}},
150  {{"OutputLayer", {10, 0, 2, 0}}});
151 }
152 
153 TEST_CASE_FIXTURE(SimpleActivationFixture2, "ActivationReluFloat32")
154 {
155  RunTest<4, armnn::DataType::Float32>(
156  0,
157  {{"InputLayer", {111, -85, 226, 3}}},
158  {{"OutputLayer", {111, 0, 226, 3}}});
159 }
160 
161 
162 TEST_CASE_FIXTURE(SimpleActivationFixture3, "ActivationBoundedReluQuantisedAsymm8")
163 {
164  RunTest<4, armnn::DataType::QAsymmU8>(
165  0,
166  {{"InputLayer", {10, 0, 2, 0}}},
167  {{"OutputLayer", {5, 0, 2, 0}}});
168 }
169 
170 TEST_CASE_FIXTURE(SimpleActivationFixture4, "ActivationBoundedReluFloat32")
171 {
172  RunTest<4, armnn::DataType::Float32>(
173  0,
174  {{"InputLayer", {111, -85, 226, 3}}},
175  {{"OutputLayer", {5, 0, 5, 3}}});
176 }
177 
178 }
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")