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 SubtractionFixture : public ParserFlatbuffersSerializeFixture
17 explicit SubtractionFixture(const std::string & inputShape1,
18 const std::string & inputShape2,
19 const std::string & outputShape,
20 const std::string & dataType)
28 layer_type: "InputLayer",
34 layerName: "inputLayer1",
38 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
43 dimensions: )" + inputShape1 + R"(,
44 dataType: )" + dataType + R"(
51 layer_type: "InputLayer",
57 layerName: "inputLayer2",
61 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
66 dimensions: )" + inputShape2 + R"(,
67 dataType: )" + dataType + R"(
74 layer_type: "SubtractionLayer",
78 layerName: "subtractionLayer",
79 layerType: "Subtraction",
82 connection: {sourceLayerIndex:0, outputSlotIndex:0 },
86 connection: {sourceLayerIndex:1, outputSlotIndex:0 },
91 dimensions: )" + outputShape + R"(,
92 dataType: )" + dataType + R"(
98 layer_type: "OutputLayer",
104 layerName: "outputLayer",
108 connection: {sourceLayerIndex:2, outputSlotIndex:0 },
113 dimensions: )" + outputShape + R"(,
114 dataType: )" + dataType + R"(
125 struct SimpleSubtractionFixture : SubtractionFixture
127 SimpleSubtractionFixture() : SubtractionFixture("[ 1, 4 ]",
130 "QuantisedAsymm8") {}
133 struct SimpleSubtractionFixture2 : SubtractionFixture
135 SimpleSubtractionFixture2() : SubtractionFixture("[ 1, 4 ]",
141 struct SimpleSubtractionFixtureBroadcast : SubtractionFixture
143 SimpleSubtractionFixtureBroadcast() : SubtractionFixture("[ 1, 4 ]",
149 BOOST_FIXTURE_TEST_CASE(SubtractionQuantisedAsymm8, SimpleSubtractionFixture)
151 RunTest<2, armnn::DataType::QAsymmU8>(
153 {{"inputLayer1", { 4, 5, 6, 7 }},
154 {"inputLayer2", { 3, 2, 1, 0 }}},
155 {{"outputLayer", { 1, 3, 5, 7 }}});
158 BOOST_FIXTURE_TEST_CASE(SubtractionFloat32, SimpleSubtractionFixture2)
160 RunTest<2, armnn::DataType::Float32>(
162 {{"inputLayer1", { 4, 5, 6, 7 }},
163 {"inputLayer2", { 3, 2, 1, 0 }}},
164 {{"outputLayer", { 1, 3, 5, 7 }}});
167 BOOST_FIXTURE_TEST_CASE(SubtractionBroadcast, SimpleSubtractionFixtureBroadcast)
169 RunTest<2, armnn::DataType::Float32>(
171 {{"inputLayer1", { 4, 5, 6, 7 }},
172 {"inputLayer2", { 2 }}},
173 {{"outputLayer", { 2, 3, 4, 5 }}});
176 BOOST_AUTO_TEST_SUITE_END()