IVGCVSW-3941 Fix bug around file opening in RecordByRecordCaffeParser
authorAron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Wed, 2 Oct 2019 15:05:44 +0000 (16:05 +0100)
committerKevin May <kevin.may@arm.com>
Thu, 3 Oct 2019 06:49:39 +0000 (06:49 +0000)
* Added error check after attempting to create input file stream and
  throw FileNotFoundException in case of failure

Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Change-Id: I46b77e21c5330bb60e1190ddbefa6473e43085d9

src/armnnCaffeParser/RecordByRecordCaffeParser.cpp

index 592dc5c..cb79436 100644 (file)
@@ -474,8 +474,12 @@ armnn::INetworkPtr RecordByRecordCaffeParser::CreateNetworkFromBinaryFile(
     }
     m_RequestedOutputs = requestedOutputs;
 
-    //FILE * fp = fopen(graphFile, "rb");
     std::ifstream ifs(graphFile, std::ifstream::in|std::ifstream::binary);
+    if (ifs.fail())
+    {
+        throw armnn::FileNotFoundException("Failed to open graph file '" + std::string(graphFile) + "'");
+    }
+
     std::vector<LayerParameterInfo> layerInfo;
     NetParameterInfo netParameterInfo;
     while(true)
@@ -727,6 +731,3 @@ armnn::INetworkPtr RecordByRecordCaffeParser::LoadLayers(std::ifstream& ifs,
 
     return move(m_Network);
 }
-
-
-