aboutsummaryrefslogtreecommitdiff
path: root/Utils.cpp
diff options
context:
space:
mode:
authorMike Kelly <mike.kelly@arm.com>2021-04-26 21:54:55 +0100
committermike.kelly <mike.kelly@arm.com>2021-05-04 13:53:55 +0000
commit7780e60b30abe4848222f3c895add1621ad6a160 (patch)
treee3567cf8aa7fe180cfb181ef75ae70b6c2ec9c3c /Utils.cpp
parentcfa20ec89e7d4bb141ce4af5b53465dfccf90a1a (diff)
downloadandroid-nn-driver-7780e60b30abe4848222f3c895add1621ad6a160.tar.gz
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 <mike.kelly@arm.com> Change-Id: If9022a278d138ece12c7e347c61722bf5a2faf3b
Diffstat (limited to 'Utils.cpp')
-rw-r--r--Utils.cpp11
1 files changed, 11 insertions, 0 deletions
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)
{