2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include <boost/test/unit_test.hpp>
7 #include "ParserFlatbuffersSerializeFixture.hpp"
8 #include <armnnDeserializer/IDeserializer.hpp>
12 BOOST_AUTO_TEST_SUITE(Deserializer)
14 struct BatchNormalizationFixture : public ParserFlatbuffersSerializeFixture
16 explicit BatchNormalizationFixture(const std::string &inputShape,
17 const std::string &outputShape,
18 const std::string &meanShape,
19 const std::string &varianceShape,
20 const std::string &offsetShape,
21 const std::string &scaleShape,
22 const std::string &dataType,
23 const std::string &dataLayout)
31 layer_type: "InputLayer",
37 layerName: "InputLayer",
41 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
46 dimensions: )" + inputShape + R"(,
47 dataType: ")" + dataType + R"(",
48 quantizationScale: 0.5,
57 layer_type: "BatchNormalizationLayer",
61 layerName: "BatchNormalizationLayer",
62 layerType: "BatchNormalization",
65 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
70 dimensions: )" + outputShape + R"(,
71 dataType: ")" + dataType + R"("
77 dataLayout: ")" + dataLayout + R"("
81 dimensions: )" + meanShape + R"(,
82 dataType: ")" + dataType + R"("
91 dimensions: )" + varianceShape + R"(,
92 dataType: ")" + dataType + R"("
101 dimensions: )" + offsetShape + R"(,
102 dataType: ")" + dataType + R"("
111 dimensions: )" + scaleShape + R"(,
112 dataType: ")" + dataType + R"("
122 layer_type: "OutputLayer",
128 layerName: "OutputLayer",
132 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
137 dimensions: )" + outputShape + R"(,
138 dataType: ")" + dataType + R"("
150 struct BatchNormFixture : BatchNormalizationFixture
152 BatchNormFixture():BatchNormalizationFixture("[ 1, 3, 3, 1 ]",
162 BOOST_FIXTURE_TEST_CASE(BatchNormalizationFloat32, BatchNormFixture)
164 RunTest<4, armnn::DataType::Float32>(0,
165 {{"InputLayer", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f }}},
166 {{"OutputLayer",{ -2.8277204f, -2.12079024f, -1.4138602f,
167 -0.7069301f, 0.0f, 0.7069301f,
168 1.4138602f, 2.12079024f, 2.8277204f }}});
171 BOOST_AUTO_TEST_SUITE_END()