diff options
author | James Conroy <james.conroy@arm.com> | 2019-10-08 15:41:34 +0100 |
---|---|---|
committer | Jim Flynn Arm <jim.flynn@arm.com> | 2019-10-10 08:48:39 +0000 |
commit | c8724c7b9ff663538bd32ad789dbcc3e1aa88637 (patch) | |
tree | 629a55e0f949fd9bede7e3b34cdc7ff337f9762c /src/armnn/test/InferOutputTests.hpp | |
parent | 92bbcaed655d1dfe696f12f264599589b8ada602 (diff) | |
download | armnn-c8724c7b9ff663538bd32ad789dbcc3e1aa88637.tar.gz |
IVGCVSW-3944 Add ArgMinMax output shape validation
Signed-off-by: James Conroy <james.conroy@arm.com>
Change-Id: I469895da158b062cd19248832525fa21527f7d41
Diffstat (limited to 'src/armnn/test/InferOutputTests.hpp')
-rw-r--r-- | src/armnn/test/InferOutputTests.hpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/armnn/test/InferOutputTests.hpp b/src/armnn/test/InferOutputTests.hpp index c428a9db61..feb2125656 100644 --- a/src/armnn/test/InferOutputTests.hpp +++ b/src/armnn/test/InferOutputTests.hpp @@ -10,6 +10,7 @@ #include <armnn/ArmNN.hpp> #include <Graph.hpp> +#include <layers/ArgMinMaxLayer.hpp> #include <layers/BatchToSpaceNdLayer.hpp> #include <layers/SpaceToDepthLayer.hpp> #include <layers/PreluLayer.hpp> @@ -18,6 +19,91 @@ #include <boost/algorithm/string.hpp> #include <boost/test/unit_test.hpp> +void ArgMinMaxInferOutputShapeImpl(const armnn::ArgMinMaxDescriptor descriptor, + const std::vector<armnn::TensorShape>& inputShapes, + std::vector<armnn::TensorShape>& outputShapes) +{ + armnn::Graph graph; + auto argMinMaxLayer = graph.AddLayer<armnn::ArgMinMaxLayer>(descriptor, "argMinMax"); + outputShapes = argMinMaxLayer->InferOutputShapes(inputShapes); +} + +void ArgMinMaxInferOutputShape4dTest() +{ + armnn::Graph graph; + armnn::ArgMinMaxDescriptor descriptor; + descriptor.m_Axis = 2; + + const std::vector<armnn::TensorShape> inputShapes + { + { 1, 3, 2, 4 } + }; + + std::vector<armnn::TensorShape> outputShapes; + BOOST_CHECK_NO_THROW(ArgMinMaxInferOutputShapeImpl(descriptor, inputShapes, outputShapes)); + + armnn::TensorShape expectedOutputShape( { 1, 3, 4 } ); + BOOST_CHECK(outputShapes.size() == 1); + BOOST_CHECK(outputShapes[0] == expectedOutputShape); +} + +void ArgMinMaxInferOutputShape3dTest() +{ + armnn::Graph graph; + armnn::ArgMinMaxDescriptor descriptor; + descriptor.m_Axis = 0; + + const std::vector<armnn::TensorShape> inputShapes + { + { 1, 3, 2 } + }; + + std::vector<armnn::TensorShape> outputShapes; + BOOST_CHECK_NO_THROW(ArgMinMaxInferOutputShapeImpl(descriptor, inputShapes, outputShapes)); + + armnn::TensorShape expectedOutputShape( { 3, 2 } ); + BOOST_CHECK(outputShapes.size() == 1); + BOOST_CHECK(outputShapes[0] == expectedOutputShape); +} + +void ArgMinMaxInferOutputShape2dTest() +{ + armnn::Graph graph; + armnn::ArgMinMaxDescriptor descriptor; + descriptor.m_Axis = 1; + + const std::vector<armnn::TensorShape> inputShapes + { + { 3, 2 } + }; + + std::vector<armnn::TensorShape> outputShapes; + BOOST_CHECK_NO_THROW(ArgMinMaxInferOutputShapeImpl(descriptor, inputShapes, outputShapes)); + + armnn::TensorShape expectedOutputShape( { 3 } ); + BOOST_CHECK(outputShapes.size() == 1); + BOOST_CHECK(outputShapes[0] == expectedOutputShape); +} + +void ArgMinMaxInferOutputShape1dTest() +{ + armnn::Graph graph; + armnn::ArgMinMaxDescriptor descriptor; + descriptor.m_Axis = 0; + + const std::vector<armnn::TensorShape> inputShapes + { + { 5 } + }; + + std::vector<armnn::TensorShape> outputShapes; + BOOST_CHECK_NO_THROW(ArgMinMaxInferOutputShapeImpl(descriptor, inputShapes, outputShapes)); + + armnn::TensorShape expectedOutputShape( { 1 } ); + BOOST_CHECK(outputShapes.size() == 1); + BOOST_CHECK(outputShapes[0] == expectedOutputShape); +} + void BatchToSpaceInferOutputShapeTest() { armnn::Graph graph; |