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 Pooling2dFixture : public ParserFlatbuffersSerializeFixture
16 explicit Pooling2dFixture(const std::string &inputShape,
17 const std::string &outputShape,
18 const std::string &dataType,
19 const std::string &dataLayout,
20 const std::string &poolingAlgorithm)
28 layer_type: "InputLayer",
34 layerName: "InputLayer",
38 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
43 dimensions: )" + inputShape + R"(,
44 dataType: )" + dataType + R"(
49 layer_type: "Pooling2dLayer",
53 layerName: "Pooling2dLayer",
54 layerType: "Pooling2d",
57 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
62 dimensions: )" + outputShape + R"(,
63 dataType: )" + dataType + R"(
67 poolType: )" + poolingAlgorithm + R"(,
68 outputShapeRounding: "Floor",
69 paddingMethod: Exclude,
70 dataLayout: )" + dataLayout + R"(,
82 layer_type: "OutputLayer",
88 layerName: "OutputLayer",
92 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
97 dimensions: )" + outputShape + R"(,
98 dataType: )" + dataType + R"(
105 SetupSingleInputSingleOutput("InputLayer", "OutputLayer");
109 struct SimpleAvgPooling2dFixture : Pooling2dFixture
111 SimpleAvgPooling2dFixture() : Pooling2dFixture("[ 1, 2, 2, 1 ]", "[ 1, 1, 1, 1 ]",
112 "Float32", "NHWC", "Average") {}
115 struct SimpleAvgPooling2dFixture2 : Pooling2dFixture
117 SimpleAvgPooling2dFixture2() : Pooling2dFixture("[ 1, 2, 2, 1 ]",
119 "QuantisedAsymm8", "NHWC", "Average") {}
122 struct SimpleMaxPooling2dFixture : Pooling2dFixture
124 SimpleMaxPooling2dFixture() : Pooling2dFixture("[ 1, 1, 2, 2 ]",
126 "Float32", "NCHW", "Max") {}
129 struct SimpleMaxPooling2dFixture2 : Pooling2dFixture
131 SimpleMaxPooling2dFixture2() : Pooling2dFixture("[ 1, 1, 2, 2 ]",
133 "QuantisedAsymm8", "NCHW", "Max") {}
136 BOOST_FIXTURE_TEST_CASE(Pooling2dFloat32Avg, SimpleAvgPooling2dFixture)
138 RunTest<4, armnn::DataType::Float32>(0, { 2, 3, 5, 2 }, { 3 });
141 BOOST_FIXTURE_TEST_CASE(Pooling2dQuantisedAsymm8Avg, SimpleAvgPooling2dFixture2)
143 RunTest<4, armnn::DataType::QAsymmU8>(0,
148 BOOST_FIXTURE_TEST_CASE(Pooling2dFloat32Max, SimpleMaxPooling2dFixture)
150 RunTest<4, armnn::DataType::Float32>(0, { 2, 5, 5, 2 }, { 5 });
153 BOOST_FIXTURE_TEST_CASE(Pooling2dQuantisedAsymm8Max, SimpleMaxPooling2dFixture2)
155 RunTest<4, armnn::DataType::QAsymmU8>(0,
160 BOOST_AUTO_TEST_SUITE_END()