Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix](mlu-ops): solve protobuf version compatibility r.14. #1165

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/mlu_op_gtest/pb_gtest/src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,11 @@ bool Parser::readMessageFromFile(const std::string &filename, Node *proto) {
google::protobuf::io::FileInputStream input(fd);
if (strEndsWith(filename, ".pb")) {
google::protobuf::io::CodedInputStream coded_input(&input);
#if GOOGLE_PROTOBUF_VERSION > 3005000
coded_input.SetTotalBytesLimit(INT_MAX);
#elif GOOGLE_PROTOBUF_VERSION
coded_input.SetTotalBytesLimit(INT_MAX, INT_MAX - 1);
#endif
status = proto->ParseFromCodedStream(&coded_input);
} else if (strEndsWith(filename, ".prototxt")) {
status = google::protobuf::TextFormat::Parse(&input, proto);
Expand Down
4 changes: 4 additions & 0 deletions test/mlu_op_gtest/tools/pb2prototxt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ bool readIn(const std::string &filename, mluoptest::Node *proto) {
new google::protobuf::io::CodedInputStream(input);
// Total bytes hard limit / warning limit are set to 1GB and 512MB, as same
// as tensorflow.
#if GOOGLE_PROTOBUF_VERSION > 3005000
coded_stream->SetTotalBytesLimit(INT_MAX);
#elif GOOGLE_PROTOBUF_VERSION
coded_stream->SetTotalBytesLimit(INT_MAX, 512LL << 20);
#endif
proto->ParseFromCodedStream(coded_stream);
delete input;
delete coded_stream;
Expand Down