From ccfeb5ea9d3aa17f66c1c13f1682ac519c8973c0 Mon Sep 17 00:00:00 2001 From: Colm Donelan Date: Tue, 30 Mar 2021 15:30:13 +0100 Subject: IVGCVSW-5766 Avoiding driver abort when Cts tests use invalid filter shape. * A number of DepthwiseConv2d Cts tests pass a filter operand with a dimension[0] value greater than 1 in contravention of Android documentation. Adding a check to handle this gracefully. * Changing a hard assert in ConversionUtils::ConstTensorPin to a warning. Signed-off-by: Colm Donelan Change-Id: I605340d098b717d1d88d259a0ed89a801287764d --- ConversionUtils.cpp | 5 ++++- ConversionUtils.hpp | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ConversionUtils.cpp b/ConversionUtils.cpp index b03ffbda..9cc6e286 100644 --- a/ConversionUtils.cpp +++ b/ConversionUtils.cpp @@ -62,7 +62,10 @@ ConstTensorPin::ConstTensorPin(const armnn::TensorInfo& tensorInfo, const armnn::PermutationVector& mappings) { armnn::IgnoreUnused(numBytes); - assert(tensorInfo.GetNumBytes() == numBytes); + if (tensorInfo.GetNumBytes() != numBytes) + { + ALOGW("The size of ConstTensor does not match its TensorInfo."); + } const bool needsSwizzling = (mappings.GetSize() > 0); if (needsSwizzling) diff --git a/ConversionUtils.hpp b/ConversionUtils.hpp index e5f99ed4..439d4a4a 100644 --- a/ConversionUtils.hpp +++ b/ConversionUtils.hpp @@ -2559,6 +2559,14 @@ bool ConvertDepthwiseConv2d(const HalOperation& operation, const HalModel& model { return Fail("%s: Operand is invalid", __func__); } + // Basic sanity check on the weights shape. + // ANEURALNETWORKS_DEPTHWISE_CONV_2D specifies a 4-D tensor, of shape + // [1, filter_height, filter_width, depth_out] + if (weightsOperand->dimensions[0] != 1) + { + return Fail("%s: Filter operand dimension 0 is invalid, should be 1", __func__); + } + armnn::DepthwiseConvolution2dDescriptor desc; desc.m_DataLayout = armnn::DataLayout::NHWC; -- cgit v1.2.1