aboutsummaryrefslogtreecommitdiff
path: root/src/armnnDeserializeParser/DeserializeParser.cpp
diff options
context:
space:
mode:
authorNattapat Chaimanowong <nattapat.chaimanowong@arm.com>2019-02-13 15:56:24 +0000
committerLes Bell <les.bell@arm.com>2019-02-15 14:00:05 +0000
commit43e7864cf81cd55fb53f8b98b4d387da859eae0d (patch)
treef83b4ab088155598cf9069ceb8f28d4e27b601ce /src/armnnDeserializeParser/DeserializeParser.cpp
parentcb8a3219331c8eb89dcdfbcdb2569c0e9ecdcf4e (diff)
downloadarmnn-43e7864cf81cd55fb53f8b98b4d387da859eae0d.tar.gz
IVGCVSW-2724 Fix bug in DeserializeParser
* Fixed error in which DeserializeParser::LoadGraphFromFile returns a pointer to a local variable in its scope Change-Id: Ic928b8509c0ae76570f0527b17e050b46327fe0c Signed-off-by: Nattapat Chaimanowong <nattapat.chaimanowong@arm.com>
Diffstat (limited to 'src/armnnDeserializeParser/DeserializeParser.cpp')
-rw-r--r--src/armnnDeserializeParser/DeserializeParser.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/armnnDeserializeParser/DeserializeParser.cpp b/src/armnnDeserializeParser/DeserializeParser.cpp
index 123fc9366c..6a6a0fafe2 100644
--- a/src/armnnDeserializeParser/DeserializeParser.cpp
+++ b/src/armnnDeserializeParser/DeserializeParser.cpp
@@ -72,7 +72,7 @@ void CheckLayers(const DeserializeParser::GraphPtr& graph,
boost::str(
boost::format("%1% was called with invalid (null) graph. "
"Possible reason is that the graph is not yet loaded and Unpack(ed). "
- "layers:%2% at %4%") %
+ "layers:%2% at %3%") %
location.m_Function %
layersIndex %
location.FileLine()));
@@ -82,7 +82,7 @@ void CheckLayers(const DeserializeParser::GraphPtr& graph,
throw ParseException(
boost::str(
boost::format("%1% was called with an invalid layers index. "
- "layers:%2% at %4%") %
+ "layers:%2% at %3%") %
location.m_Function %
layersIndex %
location.FileLine()));
@@ -322,7 +322,7 @@ void IDeserializeParser::Destroy(IDeserializeParser* parser)
INetworkPtr DeserializeParser::CreateNetworkFromBinaryFile(const char* graphFile)
{
ResetParser();
- m_Graph = LoadGraphFromFile(graphFile);
+ m_Graph = LoadGraphFromFile(graphFile, m_FileContent);
return CreateNetworkFromGraph();
}
@@ -333,7 +333,7 @@ INetworkPtr DeserializeParser::CreateNetworkFromBinary(const std::vector<uint8_t
return CreateNetworkFromGraph();
}
-DeserializeParser::GraphPtr DeserializeParser::LoadGraphFromFile(const char* fileName)
+DeserializeParser::GraphPtr DeserializeParser::LoadGraphFromFile(const char* fileName, std::string& fileContent)
{
if (fileName == nullptr)
{
@@ -350,7 +350,8 @@ DeserializeParser::GraphPtr DeserializeParser::LoadGraphFromFile(const char* fil
CHECK_LOCATION().AsString()));
}
std::ifstream file(fileName, std::ios::binary);
- std::string fileContent((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
+ fileContent = std::string((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
+
return LoadGraphFromBinary(reinterpret_cast<const uint8_t*>(fileContent.c_str()), fileContent.size());
}
@@ -606,5 +607,3 @@ void DeserializeParser::ParseMultiplication(unsigned int layerIndex)
}
}
-
-