From 2e5d0b2e2a212ceb803681b717cbaf821f5e0929 Mon Sep 17 00:00:00 2001 From: Matthew Sloyan Date: Thu, 21 Oct 2021 14:05:31 +0100 Subject: IVGCVSW-6469 Add MirrorPad FrontEnd and Ref Support * Added PaddingMode enum to PaddingDescriptor to enable Symmetric and Reflect padding. * Added Symmetric and Reflect Ref implementation. * Added Serializer & Deserializer support. * Added unit tests. Signed-off-by: Matthew Sloyan Change-Id: I4bed907b31742b32ccefe5e8ca39a6f1e5bd9dee --- src/backends/aclCommon/ArmComputeTensorUtils.cpp | 6 +++--- src/backends/aclCommon/ArmComputeTensorUtils.hpp | 4 ++-- src/backends/aclCommon/ArmComputeUtils.hpp | 11 +++++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/backends/aclCommon') diff --git a/src/backends/aclCommon/ArmComputeTensorUtils.cpp b/src/backends/aclCommon/ArmComputeTensorUtils.cpp index 62f3263a0c..8bbaea71b3 100644 --- a/src/backends/aclCommon/ArmComputeTensorUtils.cpp +++ b/src/backends/aclCommon/ArmComputeTensorUtils.cpp @@ -254,9 +254,9 @@ arm_compute::Size2D BuildArmComputeSize2D(const unsigned int width, const unsign return arm_compute::Size2D(width, height); } -arm_compute::PixelValue GetPixelValue(arm_compute::ITensor& input, float pixelValue) +arm_compute::PixelValue GetPixelValue(const arm_compute::ITensorInfo* tensorInfo, float pixelValue) { - switch (input.info()->data_type()) + switch (tensorInfo->data_type()) { case arm_compute::DataType::F16: return arm_compute::PixelValue(static_cast(pixelValue)); @@ -273,7 +273,7 @@ arm_compute::PixelValue GetPixelValue(arm_compute::ITensor& input, float pixelVa return arm_compute::PixelValue(static_cast(pixelValue)); default: throw InvalidArgumentException("Unsupported DataType: [" + - std::to_string(static_cast(input.info()->data_type())) + "]"); + std::to_string(static_cast(tensorInfo->data_type())) + "]"); } } diff --git a/src/backends/aclCommon/ArmComputeTensorUtils.hpp b/src/backends/aclCommon/ArmComputeTensorUtils.hpp index ad5d4614fe..30df31b79d 100644 --- a/src/backends/aclCommon/ArmComputeTensorUtils.hpp +++ b/src/backends/aclCommon/ArmComputeTensorUtils.hpp @@ -65,8 +65,8 @@ arm_compute::PermutationVector BuildArmComputeTransposeVector(const armnn::Permu /// Utility function used to setup an arm_compute::Size2D object from width and height values. arm_compute::Size2D BuildArmComputeSize2D(const unsigned int width, const unsigned int height); -/// Gets the appropriate PixelValue for the input DataType -arm_compute::PixelValue GetPixelValue(arm_compute::ITensor& input, float pixelValue); +/// Gets the appropriate PixelValue for the TensorInfo DataType +arm_compute::PixelValue GetPixelValue(const arm_compute::ITensorInfo* tensorInfo, float pixelValue); /// Utility function used to setup an arm_compute::PadStrideInfo object from an armnn layer descriptor. template diff --git a/src/backends/aclCommon/ArmComputeUtils.hpp b/src/backends/aclCommon/ArmComputeUtils.hpp index 2f767891a1..f096346c38 100644 --- a/src/backends/aclCommon/ArmComputeUtils.hpp +++ b/src/backends/aclCommon/ArmComputeUtils.hpp @@ -300,6 +300,17 @@ inline arm_compute::Conv3dInfo ComputeConv3DInfo(const armnn::Convolution3dQueue return arm_compute::Conv3dInfo{stride, padding, activationInfo, dilation, roundType, isFastMathEnabled}; } +inline arm_compute::PaddingMode ConvertPaddingModeToAcl(const PaddingMode& paddingMode) +{ + switch (paddingMode) + { + case PaddingMode::Constant: return arm_compute::PaddingMode::CONSTANT; + case PaddingMode::Reflect: return arm_compute::PaddingMode::REFLECT; + case PaddingMode::Symmetric: return arm_compute::PaddingMode::SYMMETRIC; + default: throw InvalidArgumentException("Unsupported Padding Mode"); + } +} + inline arm_compute::ReductionOperation ConvertReductionOperationToAcl(const ReduceDescriptor& descriptor) { switch (descriptor.m_ReduceOperation) -- cgit v1.2.1