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
diff --git a/Utils.cpp b/Utils.cpp
index 6fd1a78..873dce4 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -408,7 +408,18 @@
         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)
         {