MCPcopy Create free account
hub / github.com/ARM-software/armnn / LoadModelFromFile

Method LoadModelFromFile

src/armnnTfLiteParser/TfLiteParser.cpp:5487–5515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5485}
5486
5487TfLiteParserImpl::ModelPtr TfLiteParserImpl::LoadModelFromFile(const char* fileName)
5488{
5489 if (fileName == nullptr)
5490 {
5491 throw InvalidArgumentException(fmt::format("Invalid (null) file name {}",
5492 CHECK_LOCATION().AsString()));
5493 }
5494 std::error_code errorCode;
5495 fs::path pathToFile(fileName);
5496 if (!fs::exists(pathToFile, errorCode))
5497 {
5498 //fmt::format() could not be used here (format error)
5499 std::stringstream msg;
5500 msg << "Cannot find the file (" << fileName << ") errorCode: " << errorCode
5501 << " " << CHECK_LOCATION().AsString();
5502 throw FileNotFoundException(msg.str());
5503 }
5504 if (!fs::is_regular_file(pathToFile))
5505 {
5506 // Exclude non regular files.
5507 throw InvalidArgumentException(fmt::format("File \"{}\" is not a regular file and cannot be loaded.",
5508 pathToFile.c_str()));
5509 }
5510
5511 std::ifstream file(fileName, std::ios::binary);
5512 std::string fileContent((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
5513 return LoadModelFromBinary(reinterpret_cast<const uint8_t *>(fileContent.c_str()),
5514 fileContent.size());
5515}
5516
5517TfLiteParserImpl::ModelPtr TfLiteParserImpl::LoadModelFromBinary(const uint8_t* binaryContent, size_t len)
5518{

Callers

nothing calls this directly

Calls 9

formatEnum · 0.85
existsFunction · 0.85
is_regular_fileFunction · 0.85
AsStringMethod · 0.45
strMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected