MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / readBinaryProto

Function readBinaryProto

parsers/caffe/caffeParser/readProto.h:38–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36// So we need to read the deploy file to get the input
37
38bool readBinaryProto(trtcaffe::NetParameter* net, const char* file, size_t bufSize)
39{
40 CHECK_NULL_RET_VAL(net, false)
41 CHECK_NULL_RET_VAL(file, false)
42 using namespace google::protobuf::io;
43
44 std::ifstream stream(file, std::ios::in | std::ios::binary);
45 if (!stream)
46 {
47 RETURN_AND_LOG_ERROR(false, "Could not open file " + std::string(file));
48 }
49
50 IstreamInputStream rawInput(&stream);
51 CodedInputStream codedInput(&rawInput);
52#if GOOGLE_PROTOBUF_VERSION >= 3011000
53 codedInput.SetTotalBytesLimit(int(bufSize));
54#else
55 // Note: This WARs the very low default size limit (64MB)
56 codedInput.SetTotalBytesLimit(int(bufSize), -1);
57#endif
58 bool ok = net->ParseFromCodedStream(&codedInput);
59 stream.close();
60
61 if (!ok)
62 {
63 RETURN_AND_LOG_ERROR(false, "Could not parse binary model file");
64 }
65
66 return ok;
67}
68
69bool readTextProto(trtcaffe::NetParameter* net, const char* file)
70{

Callers 1

parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected