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"
10 #include <armnn/utility/IgnoreUnused.hpp>
15 BOOST_AUTO_TEST_SUITE(Deserializer)
17 struct AddFixture : public ParserFlatbuffersSerializeFixture
19 explicit AddFixture(const std::string & inputShape1,
20 const std::string & inputShape2,
21 const std::string & outputShape,
22 const std::string & dataType,
23 const std::string & activation="NONE")
25 armnn::IgnoreUnused(activation);
32 layer_type: "InputLayer",
38 layerName: "InputLayer1",
42 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
47 dimensions: )" + inputShape1 + R"(,
48 dataType: )" + dataType + R"(
54 layer_type: "InputLayer",
60 layerName: "InputLayer2",
64 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
69 dimensions: )" + inputShape2 + R"(,
70 dataType: )" + dataType + R"(
76 layer_type: "AdditionLayer",
80 layerName: "AdditionLayer",
81 layerType: "Addition",
85 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
89 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
95 dimensions: )" + outputShape + R"(,
96 dataType: )" + dataType + R"(
102 layer_type: "OutputLayer",
108 layerName: "OutputLayer",
112 connection: {sourceLayerIndex:2, outputSlotIndex:0 },
117 dimensions: )" + outputShape + R"(,
118 dataType: )" + dataType + R"(
130 struct SimpleAddFixture : AddFixture
132 SimpleAddFixture() : AddFixture("[ 2, 2 ]",
135 "QuantisedAsymm8") {}
138 struct SimpleAddFixture2 : AddFixture
140 SimpleAddFixture2() : AddFixture("[ 2, 2, 1, 1 ]",
146 BOOST_FIXTURE_TEST_CASE(AddQuantisedAsymm8, SimpleAddFixture)
148 RunTest<2, armnn::DataType::QAsymmU8>(
150 {{"InputLayer1", { 0, 1, 2, 3 }},
151 {"InputLayer2", { 4, 5, 6, 7 }}},
152 {{"OutputLayer", { 4, 6, 8, 10 }}});
155 BOOST_FIXTURE_TEST_CASE(AddFloat32, SimpleAddFixture2)
157 RunTest<4, armnn::DataType::Float32>(
159 {{"InputLayer1", { 111, 85, 226, 3 }},
160 {"InputLayer2", { 5, 8, 10, 12 }}},
161 {{"OutputLayer", { 116, 93, 236, 15 }}});
164 BOOST_AUTO_TEST_SUITE_END()