diff options
author | narpra01 <narumol.prangnawarat@arm.com> | 2018-10-26 17:36:32 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-27 21:50:38 +0000 |
commit | 7af7688a77e9fe2929a626f7c7dab9aef089d2b3 (patch) | |
tree | 70ab471953ee151107b411588a515a25ca845b97 /src/armnn/layers/Convolution2dLayer.cpp | |
parent | f98d21a244c384c5942e4b261d168f65ecc8a797 (diff) | |
download | armnn-7af7688a77e9fe2929a626f7c7dab9aef089d2b3.tar.gz |
IVGCVSW-2083 - Add DataLayout parameter to calculate the expected output shape in ValidateTensorShapesFromInputs
* Convolution2dLayer
* DepthwiseConvolution2dLayer
* Pooling2dLayer
* ResizeBilinearLayer
* Unittests for ValidateTensorShapesFromInputs
Change-Id: I057caf8a90d822175a7dd7271f960b65c6154bb4
Diffstat (limited to 'src/armnn/layers/Convolution2dLayer.cpp')
-rw-r--r-- | src/armnn/layers/Convolution2dLayer.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/armnn/layers/Convolution2dLayer.cpp b/src/armnn/layers/Convolution2dLayer.cpp index d4b67cca3f..d611aedc06 100644 --- a/src/armnn/layers/Convolution2dLayer.cpp +++ b/src/armnn/layers/Convolution2dLayer.cpp @@ -58,22 +58,28 @@ std::vector<TensorShape> Convolution2dLayer::InferOutputShapes(const std::vector // If we support multiple batch dimensions in the future, then this assert will need to change. BOOST_ASSERT_MSG(inputShape.GetNumDimensions() == 4, "Convolutions will always have 4D input."); - unsigned int inWidth = inputShape[3]; - unsigned int inHeight = inputShape[2]; + DataLayoutIndexed dataLayoutIndex(m_Param.m_DataLayout); + + unsigned int inWidth = inputShape[dataLayoutIndex.GetWidthIndex()]; + unsigned int inHeight = inputShape[dataLayoutIndex.GetHeightIndex()]; unsigned int inBatchSize = inputShape[0]; - unsigned int filterWidth = filterShape[3]; + unsigned int filterWidth = filterShape[dataLayoutIndex.GetWidthIndex()]; unsigned int readWidth = (inWidth + m_Param.m_PadLeft + m_Param.m_PadRight) - (filterWidth); - unsigned int outWidth = 1+(readWidth / m_Param.m_StrideX); + unsigned int outWidth = 1 + (readWidth / m_Param.m_StrideX); - unsigned int filterHeight = filterShape[2]; + unsigned int filterHeight = filterShape[dataLayoutIndex.GetHeightIndex()]; unsigned int readHeight = (inHeight + m_Param.m_PadTop + m_Param.m_PadBottom) - (filterHeight); - unsigned int outHeight = 1+(readHeight / m_Param.m_StrideY); + unsigned int outHeight = 1 + (readHeight / m_Param.m_StrideY); unsigned int outChannels = filterShape[0]; unsigned int outBatchSize = inBatchSize; - return std::vector<TensorShape>({ TensorShape({outBatchSize, outChannels, outHeight, outWidth})}); + TensorShape tensorShape = m_Param.m_DataLayout == armnn::DataLayout::NHWC ? + TensorShape( { outBatchSize, outHeight, outWidth, outChannels } ) : + TensorShape( { outBatchSize, outChannels, outHeight, outWidth }); + + return std::vector<TensorShape>({ tensorShape }); } void Convolution2dLayer::ValidateTensorShapesFromInputs() |