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 NormalizationFixture : public ParserFlatbuffersSerializeFixture
16 explicit NormalizationFixture(const std::string &inputShape,
17 const std::string & outputShape,
18 const std::string &dataType,
19 const std::string &normAlgorithmChannel,
20 const std::string &normAlgorithmMethod,
21 const std::string &dataLayout)
28 layer_type: "InputLayer",
34 layerName: "InputLayer",
38 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
43 dimensions: )" + inputShape + R"(,
44 dataType: )" + dataType + R"(,
45 quantizationScale: 0.5,
54 layer_type: "NormalizationLayer",
58 layerName: "NormalizationLayer",
59 layerType: "Normalization",
62 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
67 dimensions: )" + outputShape + R"(,
68 dataType: )" + dataType + R"(
73 normChannelType: )" + normAlgorithmChannel + R"(,
74 normMethodType: )" + normAlgorithmMethod + R"(,
79 dataLayout: )" + dataLayout + R"(
84 layer_type: "OutputLayer",
90 layerName: "OutputLayer",
94 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
99 dimensions: )" + outputShape + R"(,
100 dataType: )" + dataType + R"(
108 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
112 struct FloatNhwcLocalBrightnessAcrossNormalizationFixture : NormalizationFixture
114 FloatNhwcLocalBrightnessAcrossNormalizationFixture() : NormalizationFixture("[ 2, 2, 2, 1 ]", "[ 2, 2, 2, 1 ]",
115 "Float32", "0", "0", "NHWC") {}
119 BOOST_FIXTURE_TEST_CASE(Float32NormalizationNhwcDataLayout, FloatNhwcLocalBrightnessAcrossNormalizationFixture)
121 RunTest<4, armnn::DataType::Float32>(0, { 1.0f, 2.0f, 3.0f, 4.0f,
122 5.0f, 6.0f, 7.0f, 8.0f },
123 { 0.5f, 0.400000006f, 0.300000012f, 0.235294119f,
124 0.192307696f, 0.16216217f, 0.140000001f, 0.123076923f });
127 struct FloatNchwLocalBrightnessWithinNormalizationFixture : NormalizationFixture
129 FloatNchwLocalBrightnessWithinNormalizationFixture() : NormalizationFixture("[ 2, 1, 2, 2 ]", "[ 2, 1, 2, 2 ]",
130 "Float32", "1", "0", "NCHW") {}
133 BOOST_FIXTURE_TEST_CASE(Float32NormalizationNchwDataLayout, FloatNchwLocalBrightnessWithinNormalizationFixture)
135 RunTest<4, armnn::DataType::Float32>(0, { 1.0f, 2.0f, 3.0f, 4.0f,
136 5.0f, 6.0f, 7.0f, 8.0f },
137 { 0.0322581f, 0.0645161f, 0.0967742f, 0.1290323f,
138 0.0285714f, 0.0342857f, 0.04f, 0.0457143f });
142 BOOST_AUTO_TEST_SUITE_END()