diff options
author | Teresa Charlin <teresa.charlinreyes@arm.com> | 2023-04-26 11:19:03 +0100 |
---|---|---|
committer | TeresaARM <teresa.charlinreyes@arm.com> | 2023-04-26 15:58:14 +0000 |
commit | 024ef0b460c802a7c841dcba4b7e894e714d4512 (patch) | |
tree | 3a49a270538308a7fd24ae05e805d0acbeac4b26 /src/armnn | |
parent | 357add2c4685362afb188feaaa67b90e4d6d2361 (diff) | |
download | armnn-024ef0b460c802a7c841dcba4b7e894e714d4512.tar.gz |
BugFix: calculate explicit padding for Transpose Convolution using output size
* If the output shape is given in Transpose convolution, use it to calculate the padding
Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com>
Change-Id: I0bf3dee94c2ce606ed67fb385018b220188c3017
Diffstat (limited to 'src/armnn')
-rw-r--r-- | src/armnn/layers/TransposeConvolution2dLayer.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/armnn/layers/TransposeConvolution2dLayer.cpp b/src/armnn/layers/TransposeConvolution2dLayer.cpp index f79c5887fb..534d6b431e 100644 --- a/src/armnn/layers/TransposeConvolution2dLayer.cpp +++ b/src/armnn/layers/TransposeConvolution2dLayer.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017,2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -98,20 +98,25 @@ void TransposeConvolution2dLayer::ValidateTensorShapesFromInputs() ARMNN_ASSERT_MSG(m_Weight != nullptr, "TransposeConvolution2dLayer: Weight data cannot be null."); std::vector<TensorShape> expectedOutputShape; + std::vector<TensorShape> outputShapeGivenAsInput; + + expectedOutputShape = InferOutputShapes({GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape(), + m_Weight->GetTensorInfo().GetShape() }); + + ARMNN_ASSERT(expectedOutputShape.size() == 1); + // If output_shape was specified then use it rather than calculate an inferred output shape. if (m_Param.m_OutputShapeEnabled) { TensorShape shapeAsTensorShape(static_cast<unsigned int>(m_Param.m_OutputShape.size()), m_Param.m_OutputShape.data()); - expectedOutputShape.push_back(shapeAsTensorShape); - } - else - { - expectedOutputShape = InferOutputShapes({GetInputSlot(0).GetConnection()->GetTensorInfo().GetShape(), - m_Weight->GetTensorInfo().GetShape() }); - } + outputShapeGivenAsInput.push_back(shapeAsTensorShape); - ARMNN_ASSERT(expectedOutputShape.size() == 1); + ARMNN_ASSERT(outputShapeGivenAsInput.size() == 1); + ARMNN_ASSERT_MSG(expectedOutputShape == outputShapeGivenAsInput, + "TransposeConvolution2dLayer: output calculated by InferOutputShapes and " + "the output given as an input parameter to the layer are not matching"); + } ValidateAndCopyShape(outputShape, expectedOutputShape[0], m_ShapeInferenceMethod, "TransposeConvolution2dLayer"); } |