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

Method LoadShard

tensorflow/core/util/tensor_slice_reader.cc:141–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141void TensorSliceReader::LoadShard(int shard) const {
142 CHECK_LT(shard, sss_.size());
143 if (sss_[shard] || !status_.ok()) {
144 return; // Already loaded, or invalid.
145 }
146 string value;
147 SavedTensorSlices sts;
148 const string fname = fnames_[shard];
149 VLOG(1) << "Reading meta data from file " << fname << "...";
150 Table* table;
151 Status s = open_function_(fname, &table);
152 if (!s.ok()) {
153 status_ = errors::DataLoss("Unable to open table file ", fname, ": ",
154 s.ToString());
155 return;
156 }
157 sss_[shard].reset(table);
158 if (!(table->Get(kSavedTensorSlicesKey, &value) &&
159 ParseProtoUnlimited(&sts, value))) {
160 status_ = errors::Internal(
161 "Failed to find the saved tensor slices at the beginning of the "
162 "checkpoint file: ",
163 fname);
164 return;
165 }
166 status_ = CheckVersions(sts.meta().versions(), TF_CHECKPOINT_VERSION,
167 TF_CHECKPOINT_VERSION_MIN_PRODUCER, "Checkpoint",
168 "checkpoint");
169 if (!status_.ok()) return;
170 for (const SavedSliceMeta& ssm : sts.meta().tensor()) {
171 TensorShape ssm_shape;
172 status_ = TensorShape::BuildTensorShapeBase(ssm.shape(), &ssm_shape);
173 if (!status_.ok()) return;
174 for (const TensorSliceProto& tsp : ssm.slice()) {
175 TensorSlice ss_slice;
176 status_ = TensorSlice::BuildTensorSlice(tsp, &ss_slice);
177 if (!status_.ok()) return;
178 status_ = RegisterTensorSlice(ssm.name(), ssm_shape, ssm.type(), fname,
179 ss_slice, &tensors_);
180 if (!status_.ok()) return;
181 }
182 }
183}
184
185void TensorSliceReader::LoadAllShards() const {
186 VLOG(1) << "Loading all shards for " << filepattern_;

Callers

nothing calls this directly

Calls 15

ParseProtoUnlimitedFunction · 0.85
InternalFunction · 0.85
CheckVersionsFunction · 0.85
RegisterTensorSliceFunction · 0.85
sliceMethod · 0.80
nameMethod · 0.65
typeMethod · 0.65
sizeMethod · 0.45
okMethod · 0.45
ToStringMethod · 0.45
resetMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected