From 7780e60b30abe4848222f3c895add1621ad6a160 Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Mon, 26 Apr 2021 21:54:55 +0100 Subject: IVGCVSW-5940 Enabling NN Driver dumps results in a driver segfault * Added checks to DumpTensor to handle situations where a shape has no dimensions or some unspecified dimensions Signed-off-by: Mike Kelly Change-Id: If9022a278d138ece12c7e347c61722bf5a2faf3b --- Utils.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Utils.cpp') diff --git a/Utils.cpp b/Utils.cpp index 6fd1a785..873dce4a 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -408,7 +408,18 @@ void DumpTensor(const std::string& dumpDir, const unsigned int numDimensions = tensor.GetNumDimensions(); const armnn::TensorShape shape = tensor.GetShape(); + if (!shape.AreAllDimensionsSpecified()) + { + fileStream << "Cannot dump tensor elements: not all dimensions are specified" << std::endl; + return; + } fileStream << "# Number of elements " << tensor.GetNumElements() << std::endl; + + if (numDimensions == 0) + { + fileStream << "# Shape []" << std::endl; + return; + } fileStream << "# Shape [" << shape[0]; for (unsigned int d = 1; d < numDimensions; ++d) { -- cgit v1.2.1