| 811 | } |
| 812 | |
| 813 | ModelPtr OnnxParserImpl::LoadModelFromBinaryFile(const char* graphFile) |
| 814 | { |
| 815 | FILE* fd = fopen(graphFile, "rb"); |
| 816 | |
| 817 | if (fd == nullptr) |
| 818 | { |
| 819 | throw FileNotFoundException(fmt::format("Invalid (null) filename {}", CHECK_LOCATION().AsString())); |
| 820 | } |
| 821 | |
| 822 | // Parse the file into a message |
| 823 | ModelPtr modelProto = std::make_unique<onnx::ModelProto>(); |
| 824 | |
| 825 | google::protobuf::io::FileInputStream inStream(fileno(fd)); |
| 826 | google::protobuf::io::CodedInputStream codedStream(&inStream); |
| 827 | codedStream.SetTotalBytesLimit(INT_MAX); |
| 828 | bool success = modelProto.get()->ParseFromCodedStream(&codedStream); |
| 829 | fclose(fd); |
| 830 | |
| 831 | if (!success) |
| 832 | { |
| 833 | std::stringstream error; |
| 834 | error << "Failed to parse graph file"; |
| 835 | throw ParseException(fmt::format("{} {}", error.str(), CHECK_LOCATION().AsString())); |
| 836 | } |
| 837 | return modelProto; |
| 838 | |
| 839 | } |
| 840 | |
| 841 | INetworkPtr OnnxParserImpl::CreateNetworkFromBinaryFile(const char* graphFile) |
| 842 | { |
nothing calls this directly
no test coverage detected