| 732 | } |
| 733 | |
| 734 | ModelPtr OnnxParserImpl::LoadModelFromTextFile(const char* graphFile) |
| 735 | { |
| 736 | FILE* fd = fopen(graphFile, "r"); |
| 737 | |
| 738 | if (fd == nullptr) |
| 739 | { |
| 740 | throw FileNotFoundException(fmt::format("Invalid (null) filename {}", CHECK_LOCATION().AsString())); |
| 741 | } |
| 742 | |
| 743 | // Parse the file into a message |
| 744 | ModelPtr modelProto = std::make_unique<onnx::ModelProto>(); |
| 745 | using google::protobuf::io::FileInputStream; |
| 746 | std::unique_ptr<FileInputStream> input = std::make_unique<FileInputStream>(fileno(fd)); |
| 747 | bool success = google::protobuf::TextFormat::Parse(input.get(), modelProto.get()); |
| 748 | fclose(fd); |
| 749 | |
| 750 | if (!success) |
| 751 | { |
| 752 | std::stringstream error; |
| 753 | error << "Failed to parse graph file"; |
| 754 | throw ParseException(fmt::format("{} {}", error.str(), CHECK_LOCATION().AsString())); |
| 755 | } |
| 756 | return modelProto; |
| 757 | } |
| 758 | |
| 759 | INetworkPtr OnnxParserImpl::CreateNetworkFromTextFile(const char* graphFile) |
| 760 | { |
nothing calls this directly
no test coverage detected