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>
10 #include <armnn/utility/IgnoreUnused.hpp>
14 BOOST_AUTO_TEST_SUITE(Deserializer)
16 struct AddFixture : public ParserFlatbuffersSerializeFixture
18 explicit AddFixture(const std::string & inputShape1,
19 const std::string & inputShape2,
20 const std::string & outputShape,
21 const std::string & dataType,
22 const std::string & activation="NONE")
24 armnn::IgnoreUnused(activation);
31 layer_type: "InputLayer",
37 layerName: "InputLayer1",
41 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
46 dimensions: )" + inputShape1 + R"(,
47 dataType: )" + dataType + R"(
53 layer_type: "InputLayer",
59 layerName: "InputLayer2",
63 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
68 dimensions: )" + inputShape2 + R"(,
69 dataType: )" + dataType + R"(
75 layer_type: "AdditionLayer",
79 layerName: "AdditionLayer",
80 layerType: "Addition",
84 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
88 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
94 dimensions: )" + outputShape + R"(,
95 dataType: )" + dataType + R"(
101 layer_type: "OutputLayer",
107 layerName: "OutputLayer",
111 connection: {sourceLayerIndex:2, outputSlotIndex:0 },
116 dimensions: )" + outputShape + R"(,
117 dataType: )" + dataType + R"(
129 struct SimpleAddFixture : AddFixture
131 SimpleAddFixture() : AddFixture("[ 2, 2 ]",
134 "QuantisedAsymm8") {}
137 struct SimpleAddFixture2 : AddFixture
139 SimpleAddFixture2() : AddFixture("[ 2, 2, 1, 1 ]",
145 BOOST_FIXTURE_TEST_CASE(AddQuantisedAsymm8, SimpleAddFixture)
147 RunTest<2, armnn::DataType::QAsymmU8>(
149 {{"InputLayer1", { 0, 1, 2, 3 }},
150 {"InputLayer2", { 4, 5, 6, 7 }}},
151 {{"OutputLayer", { 4, 6, 8, 10 }}});
154 BOOST_FIXTURE_TEST_CASE(AddFloat32, SimpleAddFixture2)
156 RunTest<4, armnn::DataType::Float32>(
158 {{"InputLayer1", { 111, 85, 226, 3 }},
159 {"InputLayer2", { 5, 8, 10, 12 }}},
160 {{"OutputLayer", { 116, 93, 236, 15 }}});
163 BOOST_AUTO_TEST_SUITE_END()