diff options
author | Conor Kennedy <conor.kennedy@arm.com> | 2019-03-01 14:37:12 +0000 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-03-04 11:24:12 +0000 |
commit | da1f975558a96499ea48cfca54e727a04b175271 (patch) | |
tree | e83ed0ac3be1bd404a85cc4d4d9cbaf18e444a67 /src/armnnDeserializer/test | |
parent | 6522cdcd8b07aa8f423f832305eed57d79891e92 (diff) | |
download | armnn-da1f975558a96499ea48cfca54e727a04b175271.tar.gz |
IVGCVSW-2711 Add Serializer and Deserializer for Subtraction
Change-Id: I87836b5314c1f791b4df2ca90d239573ca28a2da
Signed-off-by: Conor Kennedy <conor.kennedy@arm.com>
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Diffstat (limited to 'src/armnnDeserializer/test')
-rw-r--r-- | src/armnnDeserializer/test/DeserializeSubtraction.cpp | 176 |
1 files changed, 176 insertions, 0 deletions
diff --git a/src/armnnDeserializer/test/DeserializeSubtraction.cpp b/src/armnnDeserializer/test/DeserializeSubtraction.cpp new file mode 100644 index 0000000000..5058bb840d --- /dev/null +++ b/src/armnnDeserializer/test/DeserializeSubtraction.cpp @@ -0,0 +1,176 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include <boost/test/unit_test.hpp> +#include "ParserFlatbuffersSerializeFixture.hpp" +#include "../Deserializer.hpp" + +#include <string> +#include <iostream> + +BOOST_AUTO_TEST_SUITE(Deserializer) + +struct SubtractionFixture : public ParserFlatbuffersSerializeFixture +{ + explicit SubtractionFixture(const std::string & inputShape1, + const std::string & inputShape2, + const std::string & outputShape, + const std::string & dataType) + { + m_JsonString = R"( + { + inputIds: [0, 1], + outputIds: [3], + layers: [ + { + layer_type: "InputLayer", + layer: { + base: { + layerBindingId: 0, + base: { + index: 0, + layerName: "inputLayer1", + layerType: "Input", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:0, outputSlotIndex:0 }, + }], + outputSlots: [ { + index: 0, + tensorInfo: { + dimensions: )" + inputShape1 + R"(, + dataType: )" + dataType + R"( + }, + }], + }, + }}, + }, + { + layer_type: "InputLayer", + layer: { + base: { + layerBindingId: 1, + base: { + index:1, + layerName: "inputLayer2", + layerType: "Input", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:0, outputSlotIndex:0 }, + }], + outputSlots: [ { + index: 0, + tensorInfo: { + dimensions: )" + inputShape2 + R"(, + dataType: )" + dataType + R"( + }, + }], + }, + }}, + }, + { + layer_type: "SubtractionLayer", + layer : { + base: { + index:2, + layerName: "subtractionLayer", + layerType: "Subtraction", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:0, outputSlotIndex:0 }, + }, + { + index: 1, + connection: {sourceLayerIndex:1, outputSlotIndex:0 }, + }], + outputSlots: [ { + index: 0, + tensorInfo: { + dimensions: )" + outputShape + R"(, + dataType: )" + dataType + R"( + }, + }], + }}, + }, + { + layer_type: "OutputLayer", + layer: { + base:{ + layerBindingId: 0, + base: { + index: 3, + layerName: "outputLayer", + layerType: "Output", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:2, outputSlotIndex:0 }, + }], + outputSlots: [ { + index: 0, + tensorInfo: { + dimensions: )" + outputShape + R"(, + dataType: )" + dataType + R"( + }, + }], + }}}, + }] + } + )"; + Setup(); + } +}; + +struct SimpleSubtractionFixture : SubtractionFixture +{ + SimpleSubtractionFixture() : SubtractionFixture("[ 1, 4 ]", + "[ 1, 4 ]", + "[ 1, 4 ]", + "QuantisedAsymm8") {} +}; + +struct SimpleSubtractionFixture2 : SubtractionFixture +{ + SimpleSubtractionFixture2() : SubtractionFixture("[ 1, 4 ]", + "[ 1, 4 ]", + "[ 1, 4 ]", + "Float32") {} +}; + +struct SimpleSubtractionFixtureBroadcast : SubtractionFixture +{ + SimpleSubtractionFixtureBroadcast() : SubtractionFixture("[ 1, 4 ]", + "[ 1, 1 ]", + "[ 1, 4 ]", + "Float32") {} +}; + +BOOST_FIXTURE_TEST_CASE(SubtractionQuantisedAsymm8, SimpleSubtractionFixture) +{ + RunTest<2, armnn::DataType::QuantisedAsymm8>( + 0, + {{"inputLayer1", { 4, 5, 6, 7 }}, + {"inputLayer2", { 3, 2, 1, 0 }}}, + {{"outputLayer", { 1, 3, 5, 7 }}}); +} + +BOOST_FIXTURE_TEST_CASE(SubtractionFloat32, SimpleSubtractionFixture2) +{ + RunTest<2, armnn::DataType::Float32>( + 0, + {{"inputLayer1", { 4, 5, 6, 7 }}, + {"inputLayer2", { 3, 2, 1, 0 }}}, + {{"outputLayer", { 1, 3, 5, 7 }}}); +} + +BOOST_FIXTURE_TEST_CASE(SubtractionBroadcast, SimpleSubtractionFixtureBroadcast) +{ + RunTest<2, armnn::DataType::Float32>( + 0, + {{"inputLayer1", { 4, 5, 6, 7 }}, + {"inputLayer2", { 2 }}}, + {{"outputLayer", { 2, 3, 4, 5 }}}); +} + +BOOST_AUTO_TEST_SUITE_END() |