aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/layers/TransposeConvolution2dLayer.cpp
diff options
context:
space:
mode:
authorAron Virginas-Tar <Aron.Virginas-Tar@arm.com>2019-06-26 15:02:47 +0100
committerÁron Virginás-Tar <aron.virginas-tar@arm.com>2019-06-27 14:34:50 +0000
commit98180eff3c1feed19576d82ceac06d476235d973 (patch)
tree3fb83f43e02a10de12c7b2d2af2984bf4785b25d /src/armnn/layers/TransposeConvolution2dLayer.cpp
parent735a450d3b53a2d745b9a7a6d85747e25ec37ede (diff)
downloadarmnn-98180eff3c1feed19576d82ceac06d476235d973.tar.gz
IVGCVSW-3324 Add end-to-end tests for TransposeConvolution2d on CpuRef
* Added one end-to-end test for all supported data types and data layout * Implemented RefLayerSupport::IsTransposeConvolution2dSupported() * Fixed formula used in TransposeConvolution2dLayer::InferOutputShapes() Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> Change-Id: If1ba3c226ecfa17f7fceffae857f39297c6433f2
Diffstat (limited to 'src/armnn/layers/TransposeConvolution2dLayer.cpp')
-rw-r--r--src/armnn/layers/TransposeConvolution2dLayer.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/armnn/layers/TransposeConvolution2dLayer.cpp b/src/armnn/layers/TransposeConvolution2dLayer.cpp
index 69f598d288..1a994e7442 100644
--- a/src/armnn/layers/TransposeConvolution2dLayer.cpp
+++ b/src/armnn/layers/TransposeConvolution2dLayer.cpp
@@ -66,26 +66,27 @@ std::vector<TensorShape> TransposeConvolution2dLayer::InferOutputShapes(
DataLayoutIndexed dataLayoutIndex(m_Param.m_DataLayout);
- unsigned int inBatchSize = inputShape[0];
- unsigned int inWidth = inputShape[dataLayoutIndex.GetWidthIndex()];
- unsigned int inHeight = inputShape[dataLayoutIndex.GetHeightIndex()];
- unsigned int inChannels = inputShape[dataLayoutIndex.GetChannelsIndex()];
+ const unsigned int batches = inputShape[0];
+ const unsigned int channels = inputShape[dataLayoutIndex.GetChannelsIndex()];
- unsigned int kernelWidth = kernelShape[dataLayoutIndex.GetWidthIndex()];
- unsigned int kernelHeight = kernelShape[dataLayoutIndex.GetHeightIndex()];
+ const unsigned int wInput = inputShape[dataLayoutIndex.GetWidthIndex()];
+ const unsigned int hInput = inputShape[dataLayoutIndex.GetHeightIndex()];
- unsigned int totalPaddingX = m_Param.m_PadLeft + m_Param.m_PadRight;
- unsigned int totalPaddingY = m_Param.m_PadTop + m_Param.m_PadBottom;
+ const unsigned int wKernel = kernelShape[dataLayoutIndex.GetWidthIndex()];
+ const unsigned int hKernel = kernelShape[dataLayoutIndex.GetHeightIndex()];
- unsigned int outWidth = m_Param.m_StrideX * (inWidth + 1) - totalPaddingX + kernelWidth;
- unsigned int outHeight = m_Param.m_StrideY * (inHeight + 1) - totalPaddingY + kernelHeight;
+ const unsigned int wStridedInput = 1u + m_Param.m_StrideX * (wInput - 1);
+ const unsigned int hStridedInput = 1u + m_Param.m_StrideY * (hInput - 1);
- unsigned int outChannels = inChannels;
- unsigned int outBatchSize = inBatchSize;
+ const unsigned int wPaddedOutput = wStridedInput + wKernel - (wKernel % 2);
+ const unsigned int hPaddedOutput = hStridedInput + hKernel - (hKernel % 2);
+
+ unsigned int wOutput = wPaddedOutput - (m_Param.m_PadLeft + m_Param.m_PadRight);
+ unsigned int hOutput = hPaddedOutput - (m_Param.m_PadTop + m_Param.m_PadBottom);
TensorShape tensorShape = m_Param.m_DataLayout == armnn::DataLayout::NHWC ?
- TensorShape( { outBatchSize, outHeight, outWidth, outChannels } ) :
- TensorShape( { outBatchSize, outChannels, outHeight, outWidth });
+ TensorShape( { batches, hOutput, wOutput, channels } ) :
+ TensorShape( { batches, channels, hOutput, wOutput });
return std::vector<TensorShape>({ tensorShape });
}