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

Method Finish

tensorflow/core/util/tensor_slice_writer.cc:95–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95Status TensorSliceWriter::Finish() {
96 Builder* b;
97 Status s = create_builder_(tmpname_, &b);
98 if (!s.ok()) {
99 delete b;
100 return s;
101 }
102 std::unique_ptr<Builder> builder(b);
103
104 // We save the saved tensor slice metadata as the first element.
105 string meta;
106 sts_.AppendToString(&meta);
107 builder->Add(kSavedTensorSlicesKey, meta);
108
109 // Go through all the data and add them
110 for (const auto& x : data_) {
111 builder->Add(x.first, x.second);
112 }
113
114 int64 file_size;
115 s = builder->Finish(&file_size);
116 // We need to rename the file to the proper name
117 if (s.ok()) {
118 s = Env::Default()->RenameFile(tmpname_, filename_);
119 if (s.ok()) {
120 VLOG(1) << "Written " << slices_ << " slices for "
121 << sts_.meta().tensor_size() << " tensors (" << file_size
122 << " bytes) to " << filename_;
123 } else {
124 LOG(ERROR) << "Failed to rename file " << tmpname_ << " to " << filename_;
125 }
126 } else {
127 Env::Default()->DeleteFile(tmpname_).IgnoreError();
128 }
129 return s;
130}
131
132/* static */
133size_t TensorSliceWriter::MaxBytesPerElement(DataType dt) {

Callers 8

FinishMethod · 0.45
SimpleFloatHelperFunction · 0.45
SimpleIntXHelperFunction · 0.45
MutateSavedTensorSlicesFunction · 0.45
TESTFunction · 0.45
VersionTestFunction · 0.45
TESTFunction · 0.45

Calls 7

DefaultFunction · 0.85
tensor_sizeMethod · 0.80
okMethod · 0.45
AddMethod · 0.45
RenameFileMethod · 0.45
IgnoreErrorMethod · 0.45
DeleteFileMethod · 0.45

Tested by 7

SimpleFloatHelperFunction · 0.36
SimpleIntXHelperFunction · 0.36
MutateSavedTensorSlicesFunction · 0.36
TESTFunction · 0.36
VersionTestFunction · 0.36
TESTFunction · 0.36