From 2e5d0b2e2a212ceb803681b717cbaf821f5e0929 Mon Sep 17 00:00:00 2001 From: Matthew Sloyan Date: Thu, 21 Oct 2021 14:05:31 +0100 Subject: IVGCVSW-6469 Add MirrorPad FrontEnd and Ref Support * Added PaddingMode enum to PaddingDescriptor to enable Symmetric and Reflect padding. * Added Symmetric and Reflect Ref implementation. * Added Serializer & Deserializer support. * Added unit tests. Signed-off-by: Matthew Sloyan Change-Id: I4bed907b31742b32ccefe5e8ca39a6f1e5bd9dee --- src/armnnDeserializer/test/DeserializePad.cpp | 119 ++++++++++++++++++++++---- 1 file changed, 103 insertions(+), 16 deletions(-) (limited to 'src/armnnDeserializer/test') diff --git a/src/armnnDeserializer/test/DeserializePad.cpp b/src/armnnDeserializer/test/DeserializePad.cpp index 43de22912f..ade097483c 100644 --- a/src/armnnDeserializer/test/DeserializePad.cpp +++ b/src/armnnDeserializer/test/DeserializePad.cpp @@ -12,10 +12,11 @@ TEST_SUITE("Deserializer_Pad") { struct PadFixture : public ParserFlatbuffersSerializeFixture { - explicit PadFixture(const std::string &inputShape, - const std::string &padList, - const std::string &outputShape, - const std::string &dataType) + explicit PadFixture(const std::string& inputShape, + const std::string& padList, + const std::string& outputShape, + const std::string& dataType, + const std::string& paddingMode) { m_JsonString = R"( { @@ -67,6 +68,7 @@ struct PadFixture : public ParserFlatbuffersSerializeFixture }, descriptor: { padList: )" + padList + R"(, + paddingMode: )" + paddingMode + R"(, } } }, @@ -106,23 +108,108 @@ struct SimplePadFixture : PadFixture SimplePadFixture() : PadFixture("[ 2, 2, 2 ]", "[ 0, 1, 2, 1, 2, 2 ]", "[ 3, 5, 6 ]", - "QuantisedAsymm8") {} + "QuantisedAsymm8", + "Constant") {} }; TEST_CASE_FIXTURE(SimplePadFixture, "SimplePadQuantisedAsymm8") { RunTest<3, armnn::DataType::QAsymmU8>(0, - { - 0, 4, 2, 5, 6, 1, 5, 2 - }, - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 0, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, - 1, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }); + { + 0, 4, 2, 5, 6, 1, 5, 2 + }, + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, + 1, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }); +} + +struct SimplePadSymmetricFixture : PadFixture +{ + SimplePadSymmetricFixture() : PadFixture("[ 2, 2, 2 ]", + "[ 1, 1, 1, 1, 1, 1 ]", + "[ 4, 4, 4 ]", + "QuantisedAsymm8", + "Symmetric") {} +}; + +TEST_CASE_FIXTURE(SimplePadSymmetricFixture, "SimplePadSymmetricQuantisedAsymm8") +{ + RunTest<3, armnn::DataType::QAsymmU8>(0, + { + 1, 2, + 3, 4, + + 5, 6, + 7, 8 + }, + { + 1, 1, 2, 2, + 1, 1, 2, 2, + 3, 3, 4, 4, + 3, 3, 4, 4, + + 1, 1, 2, 2, + 1, 1, 2, 2, + 3, 3, 4, 4, + 3, 3, 4, 4, + + 5, 5, 6, 6, + 5, 5, 6, 6, + 7, 7, 8, 8, + 7, 7, 8, 8, + + 5, 5, 6, 6, + 5, 5, 6, 6, + 7, 7, 8, 8, + 7, 7, 8, 8 + }); +} + +struct SimplePadReflectFixture : PadFixture +{ + SimplePadReflectFixture() : PadFixture("[ 2, 2, 2 ]", + "[ 1, 1, 1, 1, 1, 1 ]", + "[ 4, 4, 4 ]", + "QuantisedAsymm8", + "Reflect") {} +}; + +TEST_CASE_FIXTURE(SimplePadReflectFixture, "SimplePadReflectQuantisedAsymm8") +{ + RunTest<3, armnn::DataType::QAsymmU8>(0, + { + 1, 2, + 3, 4, + + 5, 6, + 7, 8 + }, + { + 8, 7, 8, 7, + 6, 5, 6, 5, + 8, 7, 8, 7, + 6, 5, 6, 5, + + 4, 3, 4, 3, + 2, 1, 2, 1, + 4, 3, 4, 3, + 2, 1, 2, 1, + + 8, 7, 8, 7, + 6, 5, 6, 5, + 8, 7, 8, 7, + 6, 5, 6, 5, + + 4, 3, 4, 3, + 2, 1, 2, 1, + 4, 3, 4, 3, + 2, 1, 2, 1 + }); } } -- cgit v1.2.1