| 344 | } |
| 345 | |
| 346 | StatusOr<std::vector<HloSnapshot>> ParseRecordIoFile(absl::string_view filename, |
| 347 | const Options& opts) { |
| 348 | tensorflow::Env* env = tensorflow::Env::Default(); |
| 349 | |
| 350 | std::unique_ptr<tensorflow::RandomAccessFile> file; |
| 351 | TF_RETURN_IF_ERROR(env->NewRandomAccessFile( |
| 352 | string(filename.begin(), filename.end()), &file)); |
| 353 | tensorflow::io::RecordReader reader( |
| 354 | file.get(), |
| 355 | tensorflow::io::RecordReaderOptions::CreateRecordReaderOptions("ZLIB")); |
| 356 | |
| 357 | std::vector<HloSnapshot> snapshots; |
| 358 | uint64 offset = 0; |
| 359 | tensorflow::tstring record; |
| 360 | while (reader.ReadRecord(&offset, &record).ok()) { |
| 361 | HloSnapshot snapshot; |
| 362 | if (snapshot.mutable_hlo()->ParseFromString(record)) { |
| 363 | snapshots.push_back(std::move(snapshot)); |
| 364 | } else { |
| 365 | LOG(ERROR) << "Encountered bad proto"; |
| 366 | } |
| 367 | } |
| 368 | CHECK(!snapshots.empty()) |
| 369 | << "No proto is successfully parsed from the file - the file possibly " |
| 370 | "has a mismatched compression option, format, etc."; |
| 371 | CHECK(!opts.NeedsRealData()) |
| 372 | << "Without --use_fake_data or --compile_only, you must pass an " |
| 373 | "HloSnapshot -- HloProto and textual HLO don't carry real data."; |
| 374 | return snapshots; |
| 375 | } |
| 376 | |
| 377 | StatusOr<HloSnapshot> ParseSingleHloFile(const string& filename, |
| 378 | const Options& opts) { |
no test coverage detected