diff options
author | Teresa Charlin <teresa.charlinreyes@arm.com> | 2019-07-18 16:23:58 +0100 |
---|---|---|
committer | Sadik Armagan <sadik.armagan@arm.com> | 2019-07-23 16:14:27 +0000 |
commit | 7b1845206d723a91aec811edaf7cb0cf832dfd25 (patch) | |
tree | 319cefd88ec0148e6376add04a9e2efff77171eb /src/armnn | |
parent | 9e10c2b9ee9ce2e8f74f80e22842a47479ba1174 (diff) | |
download | armnn-7b1845206d723a91aec811edaf7cb0cf832dfd25.tar.gz |
IVGCVSW-3476 Add InferOutputShapes unit tests for convolution workloads
* Convolution2d, DepthwiseConvolution2d & TransposeConvolution2d
Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Change-Id: I2490c684765d8c7349183572f46e86c201b8eefd
Diffstat (limited to 'src/armnn')
-rw-r--r-- | src/armnn/test/InferOutputTests.cpp | 9 | ||||
-rw-r--r-- | src/armnn/test/InferOutputTests.hpp | 97 |
2 files changed, 106 insertions, 0 deletions
diff --git a/src/armnn/test/InferOutputTests.cpp b/src/armnn/test/InferOutputTests.cpp index 24ae8b263b..4581d87a5b 100644 --- a/src/armnn/test/InferOutputTests.cpp +++ b/src/armnn/test/InferOutputTests.cpp @@ -31,4 +31,13 @@ ARMNN_SIMPLE_TEST_CASE(StackInferOutputShapeFromInputsNoMatch, StackInferOut ARMNN_SIMPLE_TEST_CASE(StackValidateTensorShapesFromInputsMatch, StackValidateTensorShapesFromInputsMatchTest) ARMNN_SIMPLE_TEST_CASE(StackValidateTensorShapesFromInputsNoMatch, StackValidateTensorShapesFromInputsNoMatchTest) +// Convolution2D +ARMNN_SIMPLE_TEST_CASE(Convolution2dInferOutputShape, Convolution2dInferOutputShapeTest) + +// DepthwiseConvolution2D +ARMNN_SIMPLE_TEST_CASE(DepthwiseConvolution2dInferOutputShape, DepthwiseConvolution2dInferOutputShapeTest) + +// TransposeConvolution2D +ARMNN_SIMPLE_TEST_CASE(TransposeConvolution2dInferOutputShape, TransposeConvolution2dInferOutputShapeTest) + BOOST_AUTO_TEST_SUITE_END() diff --git a/src/armnn/test/InferOutputTests.hpp b/src/armnn/test/InferOutputTests.hpp index 47eabd3cb0..58a081a130 100644 --- a/src/armnn/test/InferOutputTests.hpp +++ b/src/armnn/test/InferOutputTests.hpp @@ -347,3 +347,100 @@ void StackValidateTensorShapesFromInputsNoMatchTest() // Graph::InferTensorInfos calls Layer::ValidateTensorShapesFromInputs BOOST_CHECK_THROW(graph.InferTensorInfos(), armnn::LayerValidationException); } + +void Convolution2dInferOutputShapeTest() +{ + armnn::Graph graph; + + armnn::Convolution2dDescriptor descriptor; + descriptor.m_DilationX = 2; + descriptor.m_DilationY = 2; + descriptor.m_PadTop = 1; + descriptor.m_PadBottom = 1; + descriptor.m_PadLeft = 1; + descriptor.m_PadRight = 1; + descriptor.m_StrideX = 3; + descriptor.m_StrideY = 3; + descriptor.m_DataLayout = armnn::DataLayout::NCHW; + + armnn::Convolution2dLayer* const convolution2dLayer = + graph.AddLayer<armnn::Convolution2dLayer>(descriptor, "convolution2d"); + + std::vector<armnn::TensorShape> shapes; + const std::vector<unsigned int> inputSize = {1, 2, 10, 10}; + armnn::TensorShape inputShape(4, inputSize.data()); + shapes.push_back(inputShape); + + const std::vector<unsigned int> filterSize = { 1, 2, 2, 2}; + armnn::TensorShape filterShape(4, filterSize.data()); + shapes.push_back(filterShape); + + const std::vector<unsigned int> expectedOutputSizes = {1, 1, 4, 4}; + armnn::TensorShape expectedOutputShape(4, expectedOutputSizes.data()); + + BOOST_CHECK(expectedOutputShape == convolution2dLayer->InferOutputShapes(shapes).at(0)); +} + +void TransposeConvolution2dInferOutputShapeTest() +{ + armnn::Graph graph; + + armnn::TransposeConvolution2dDescriptor descriptor; + descriptor.m_PadTop = 0; + descriptor.m_PadBottom = 1; + descriptor.m_PadLeft = 0; + descriptor.m_PadRight = 1; + descriptor.m_StrideX = 2; + descriptor.m_StrideY = 2; + descriptor.m_DataLayout = armnn::DataLayout::NCHW; + + armnn::TransposeConvolution2dLayer* const transposeConvolution2dLayer = + graph.AddLayer<armnn::TransposeConvolution2dLayer>(descriptor, "TransposeConvolution2d"); + + std::vector<armnn::TensorShape> shapes; + const std::vector<unsigned int> inputSize = {1, 2, 3, 3}; + armnn::TensorShape inputShape(4, inputSize.data()); + shapes.push_back(inputShape); + + const std::vector<unsigned int> filterSize = { 1, 2, 3, 3}; + armnn::TensorShape filterShape(4, filterSize.data()); + shapes.push_back(filterShape); + + const std::vector<unsigned int> expectedOutputSizes = {1, 2, 6, 6}; + armnn::TensorShape expectedOutputShape(4, expectedOutputSizes.data()); + + BOOST_CHECK(expectedOutputShape == transposeConvolution2dLayer->InferOutputShapes(shapes).at(0)); +} + +void DepthwiseConvolution2dInferOutputShapeTest() +{ + armnn::Graph graph; + + armnn::DepthwiseConvolution2dDescriptor descriptor; + descriptor.m_DilationX = 3; + descriptor.m_DilationY = 3; + descriptor.m_PadTop = 1; + descriptor.m_PadBottom = 2; + descriptor.m_PadLeft = 1; + descriptor.m_PadRight = 2; + descriptor.m_StrideX = 2; + descriptor.m_StrideY = 2; + descriptor.m_DataLayout = armnn::DataLayout::NCHW; + + armnn::DepthwiseConvolution2dLayer* const depthwiseConvolution2dLayer = + graph.AddLayer<armnn::DepthwiseConvolution2dLayer>(descriptor, "DepthwiseConvolution2d"); + + std::vector<armnn::TensorShape> shapes; + const std::vector<unsigned int> inputSize = {1, 2, 10, 10}; + armnn::TensorShape inputShape(4, inputSize.data()); + shapes.push_back(inputShape); + + const std::vector<unsigned int> filterSize = { 1, 2, 3, 3}; + armnn::TensorShape filterShape(4, filterSize.data()); + shapes.push_back(filterShape); + + const std::vector<unsigned int> expectedOutputSizes = {1, 2, 4, 4}; + armnn::TensorShape expectedOutputShape(4, expectedOutputSizes.data()); + + BOOST_CHECK(expectedOutputShape == depthwiseConvolution2dLayer->InferOutputShapes(shapes).at(0)); +}
\ No newline at end of file |