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

Method WriteToPath

tensorflow/compiler/xla/text_literal_writer.cc:32–59  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

30namespace xla {
31
32/* static */ Status TextLiteralWriter::WriteToPath(const Literal& literal,
33 absl::string_view path) {
34 std::unique_ptr<tensorflow::WritableFile> f;
35 auto s = tensorflow::Env::Default()->NewWritableFile(string(path), &f);
36 if (!s.ok()) {
37 return s;
38 }
39
40 s = f->Append(ShapeUtil::HumanString(literal.shape()) + "\n");
41 if (!s.ok()) {
42 return s;
43 }
44
45 Status status;
46 tensorflow::WritableFile* f_ptr = f.get();
47 literal.EachCellAsString(
48 [f_ptr, &status](absl::Span<const int64> indices, const string& value) {
49 if (!status.ok()) {
50 return;
51 }
52 string coordinates =
53 absl::StrCat("(", absl::StrJoin(indices, ", "), ")");
54
55 status = f_ptr->Append(absl::StrCat(coordinates, ": ", value, "\n"));
56 });
57 auto ignored = f->Close();
58 return status;
59}
60
61} // namespace xla

Callers

nothing calls this directly

Calls 9

DefaultFunction · 0.85
EachCellAsStringMethod · 0.80
StrCatFunction · 0.50
NewWritableFileMethod · 0.45
okMethod · 0.45
AppendMethod · 0.45
shapeMethod · 0.45
getMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected