diff options
author | Matthew Sloyan <matthew.sloyan@arm.com> | 2023-05-08 11:33:55 +0100 |
---|---|---|
committer | Matthew Sloyan <matthew.sloyan@arm.com> | 2023-05-08 12:14:04 +0100 |
commit | c52190a7e80cf238ba1d8630e5cc36ec7c7849e2 (patch) | |
tree | c1ad0e73f65de76648b7793261ef6839c5374735 /delegate/common | |
parent | cef54317be7e6053612cc559c244ba1c0487ab52 (diff) | |
download | armnn-c52190a7e80cf238ba1d8630e5cc36ec7c7849e2.tar.gz |
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 <matthew.sloyan@arm.com>
Change-Id: I5be91ec25c11354a9b8472d0a429e71e02df6f9c
Diffstat (limited to 'delegate/common')
-rw-r--r-- | delegate/common/src/DelegateUtils.hpp | 23 |
1 files changed, 23 insertions, 0 deletions
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<int>(numDimensions); |