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 "../Deserializer.hpp"
13 BOOST_AUTO_TEST_SUITE(Deserializer)
15 struct Pooling2dFixture : public ParserFlatbuffersSerializeFixture
17 explicit Pooling2dFixture(const std::string &inputShape,
18 const std::string &outputShape,
19 const std::string &dataType,
20 const std::string &dataLayout,
21 const std::string &poolingAlgorithm)
29 layer_type: "InputLayer",
35 layerName: "InputLayer",
39 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
44 dimensions: )" + inputShape + R"(,
45 dataType: )" + dataType + R"(
50 layer_type: "Pooling2dLayer",
54 layerName: "Pooling2dLayer",
55 layerType: "Pooling2d",
58 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
63 dimensions: )" + outputShape + R"(,
64 dataType: )" + dataType + R"(
68 poolType: )" + poolingAlgorithm + R"(,
69 outputShapeRounding: "Floor",
70 paddingMethod: Exclude,
71 dataLayout: )" + dataLayout + R"(,
83 layer_type: "OutputLayer",
89 layerName: "OutputLayer",
93 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
98 dimensions: )" + outputShape + R"(,
99 dataType: )" + dataType + R"(
106 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
110 struct SimpleAvgPooling2dFixture : Pooling2dFixture
112 SimpleAvgPooling2dFixture() : Pooling2dFixture("[ 1, 2, 2, 1 ]", "[ 1, 1, 1, 1 ]",
113 "Float32", "NHWC", "Average") {}
116 struct SimpleAvgPooling2dFixture2 : Pooling2dFixture
118 SimpleAvgPooling2dFixture2() : Pooling2dFixture("[ 1, 2, 2, 1 ]",
120 "QuantisedAsymm8", "NHWC", "Average") {}
123 struct SimpleMaxPooling2dFixture : Pooling2dFixture
125 SimpleMaxPooling2dFixture() : Pooling2dFixture("[ 1, 1, 2, 2 ]",
127 "Float32", "NCHW", "Max") {}
130 struct SimpleMaxPooling2dFixture2 : Pooling2dFixture
132 SimpleMaxPooling2dFixture2() : Pooling2dFixture("[ 1, 1, 2, 2 ]",
134 "QuantisedAsymm8", "NCHW", "Max") {}
137 BOOST_FIXTURE_TEST_CASE(Pooling2dFloat32Avg, SimpleAvgPooling2dFixture)
139 RunTest<4, armnn::DataType::Float32>(0, { 2, 3, 5, 2 }, { 3 });
142 BOOST_FIXTURE_TEST_CASE(Pooling2dQuantisedAsymm8Avg, SimpleAvgPooling2dFixture2)
144 RunTest<4, armnn::DataType::QAsymmU8>(0,
149 BOOST_FIXTURE_TEST_CASE(Pooling2dFloat32Max, SimpleMaxPooling2dFixture)
151 RunTest<4, armnn::DataType::Float32>(0, { 2, 5, 5, 2 }, { 5 });
154 BOOST_FIXTURE_TEST_CASE(Pooling2dQuantisedAsymm8Max, SimpleMaxPooling2dFixture2)
156 RunTest<4, armnn::DataType::QAsymmU8>(0,
161 BOOST_AUTO_TEST_SUITE_END()