| 5485 | } |
| 5486 | |
| 5487 | TfLiteParserImpl::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 | |
| 5517 | TfLiteParserImpl::ModelPtr TfLiteParserImpl::LoadModelFromBinary(const uint8_t* binaryContent, size_t len) |
| 5518 | { |
nothing calls this directly
no test coverage detected