ArmNN
 22.02
DeserializeL2Normalization.cpp File Reference

Go to the source code of this file.

Functions

 TEST_SUITE ("Deserializer_L2Normalization")
 

Function Documentation

◆ TEST_SUITE()

TEST_SUITE ( "Deserializer_L2Normalization"  )

Definition at line 11 of file DeserializeL2Normalization.cpp.

References ParserFlatbuffersSerializeFixture::Setup(), and TEST_CASE_FIXTURE().

12 {
13 struct L2NormalizationFixture : public ParserFlatbuffersSerializeFixture
14 {
15  explicit L2NormalizationFixture(const std::string &inputShape,
16  const std::string &outputShape,
17  const std::string &dataType,
18  const std::string &dataLayout,
19  const std::string epsilon)
20  {
21  m_JsonString = R"(
22  {
23  inputIds: [0],
24  outputIds: [2],
25  layers: [
26  {
27  layer_type: "InputLayer",
28  layer: {
29  base: {
30  layerBindingId: 0,
31  base: {
32  index: 0,
33  layerName: "InputLayer",
34  layerType: "Input",
35  inputSlots: [{
36  index: 0,
37  connection: {sourceLayerIndex:0, outputSlotIndex:0 },
38  }],
39  outputSlots: [{
40  index: 0,
41  tensorInfo: {
42  dimensions: )" + inputShape + R"(,
43  dataType: ")" + dataType + R"(",
44  quantizationScale: 0.5,
45  quantizationOffset: 0
46  },
47  }]
48  },
49  }
50  },
51  },
52  {
53  layer_type: "L2NormalizationLayer",
54  layer : {
55  base: {
56  index:1,
57  layerName: "L2NormalizationLayer",
58  layerType: "L2Normalization",
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  dataLayout: ")" + dataLayout + R"(",
73  eps: )" + epsilon + R"(
74  },
75  },
76  },
77  {
78  layer_type: "OutputLayer",
79  layer: {
80  base:{
81  layerBindingId: 0,
82  base: {
83  index: 2,
84  layerName: "OutputLayer",
85  layerType: "Output",
86  inputSlots: [{
87  index: 0,
88  connection: {sourceLayerIndex:1, outputSlotIndex:0 },
89  }],
90  outputSlots: [ {
91  index: 0,
92  tensorInfo: {
93  dimensions: )" + outputShape + R"(,
94  dataType: ")" + dataType + R"("
95  },
96  }],
97  }
98  }},
99  }]
100  }
101 )";
102  Setup();
103  }
104 };
105 
106 struct L2NormFixture : L2NormalizationFixture
107 {
108  // Using a non standard epsilon value of 1e-8
109  L2NormFixture():L2NormalizationFixture("[ 1, 3, 1, 1 ]",
110  "[ 1, 3, 1, 1 ]",
111  "Float32",
112  "NCHW",
113  "0.00000001"){}
114 };
115 
116 TEST_CASE_FIXTURE(L2NormFixture, "L2NormalizationFloat32")
117 {
118  // 1 / sqrt(1^2 + 2^2 + 3^2)
119  const float approxInvL2Norm = 0.267261f;
120 
121  RunTest<4, armnn::DataType::Float32>(0,
122  {{"InputLayer", { 1.0f, 2.0f, 3.0f }}},
123  {{"OutputLayer",{ 1.0f * approxInvL2Norm,
124  2.0f * approxInvL2Norm,
125  3.0f * approxInvL2Norm }}});
126 }
127 
128 TEST_CASE_FIXTURE(L2NormFixture, "L2NormalizationEpsilonLimitFloat32")
129 {
130  // 1 / sqrt(1e-8)
131  const float approxInvL2Norm = 10000;
132 
133  RunTest<4, armnn::DataType::Float32>(0,
134  {{"InputLayer", { 0.00000001f, 0.00000002f, 0.00000003f }}},
135  {{"OutputLayer",{ 0.00000001f * approxInvL2Norm,
136  0.00000002f * approxInvL2Norm,
137  0.00000003f * approxInvL2Norm }}});
138 }
139 
140 }
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")