MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ParseRecordIoFile

Function ParseRecordIoFile

tensorflow/compiler/xla/tools/replay_computation.cc:346–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346StatusOr<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
377StatusOr<HloSnapshot> ParseSingleHloFile(const string& filename,
378 const Options& opts) {

Callers 1

ParseInputFileFunction · 0.85

Calls 11

DefaultFunction · 0.85
NeedsRealDataMethod · 0.80
NewRandomAccessFileMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45
okMethod · 0.45
ReadRecordMethod · 0.45
ParseFromStringMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected