| 532 | } |
| 533 | |
| 534 | Status ReadTextProto(Env* env, const string& fname, |
| 535 | ::tensorflow::protobuf::Message* proto) { |
| 536 | #if !defined(TENSORFLOW_LITE_PROTOS) |
| 537 | std::unique_ptr<RandomAccessFile> file; |
| 538 | TF_RETURN_IF_ERROR(env->NewRandomAccessFile(fname, &file)); |
| 539 | std::unique_ptr<FileStream> stream(new FileStream(file.get())); |
| 540 | |
| 541 | if (!::tensorflow::protobuf::TextFormat::Parse(stream.get(), proto)) { |
| 542 | TF_RETURN_IF_ERROR(stream->status()); |
| 543 | return errors::DataLoss("Can't parse ", fname, " as text proto"); |
| 544 | } |
| 545 | return Status::OK(); |
| 546 | #else |
| 547 | return errors::Unimplemented("Can't parse text protos with protolite."); |
| 548 | #endif |
| 549 | } |
| 550 | |
| 551 | Status ReadTextOrBinaryProto(Env* env, const string& fname, |
| 552 | #if !defined(TENSORFLOW_LITE_PROTOS) |