From c52190a7e80cf238ba1d8630e5cc36ec7c7849e2 Mon Sep 17 00:00:00 2001 From: Matthew Sloyan Date: Mon, 8 May 2023 11:33:55 +0100 Subject: BugFix: Calculate explicit padding for Delegate Transpose Convolution using output size * Added fix to Classic and Opaque Delegate which now matches the TfLiteParser. * Removed uses of single parameter IsValid function in classic Convolution visit functions. Signed-off-by: Matthew Sloyan Change-Id: I5be91ec25c11354a9b8472d0a429e71e02df6f9c --- delegate/common/src/DelegateUtils.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'delegate/common') diff --git a/delegate/common/src/DelegateUtils.hpp b/delegate/common/src/DelegateUtils.hpp index 1671a4c8cf..418cad313f 100644 --- a/delegate/common/src/DelegateUtils.hpp +++ b/delegate/common/src/DelegateUtils.hpp @@ -82,6 +82,29 @@ void CalcPadding(uint32_t inputSize, } } +// Function that calculates explicit padding when the output shape is known. +// At the moment the output is only given as an input parameter in Transpose Convolution, +// not in Convolution and Depthwise Convolution +void CalcPadding(uint32_t inputSize, + uint32_t filterSize, + uint32_t stride, + uint32_t dilation, + uint32_t& paddingFront, + uint32_t& paddingBack, + TfLitePadding padding, + uint32_t outputSize) +{ + armnn::IgnoreUnused(dilation); + paddingFront = 0; + paddingBack = 0; + if (padding == kTfLitePaddingSame) + { + uint32_t totalPadding = (inputSize - 1) * stride + filterSize - outputSize; + paddingFront = totalPadding / 2; + paddingBack = totalPadding - paddingFront; + } +} + unsigned int ComputeWrappedIndex(int index, unsigned int numDimensions) { int numDims = armnn::numeric_cast(numDimensions); -- cgit v1.2.1