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

Function RunRestore

tensorflow/cc/saved_model/loader.cc:283–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283Status RunRestore(const RunOptions& run_options, const string& export_dir,
284 const StringPiece restore_op_name,
285 const StringPiece variable_filename_const_op_name,
286 const std::vector<AssetFileDef>& asset_file_defs,
287 Session* session) {
288 LOG(INFO) << "Restoring SavedModel bundle.";
289 // Find path to variables to be restored in export directory.
290 const string variables_directory =
291 io::JoinPath(export_dir, kSavedModelVariablesDirectory);
292 // Check for saver checkpoints in v2 format. Models exported in the checkpoint
293 // v2 format will have a variables.index file. The corresponding
294 // variables are stored in the variables.data-?????-of-????? files.
295 const string variables_index_path = io::JoinPath(
296 variables_directory, MetaFilename(kSavedModelVariablesFilename));
297 if (!Env::Default()->FileExists(variables_index_path).ok()) {
298 LOG(INFO) << "The specified SavedModel has no variables; no checkpoints "
299 "were restored. File does not exist: "
300 << variables_index_path;
301 return Status::OK();
302 }
303 const string variables_path =
304 io::JoinPath(variables_directory, kSavedModelVariablesFilename);
305
306 // Add variables to the graph.
307 Tensor variables_path_tensor(DT_STRING, TensorShape({}));
308 variables_path_tensor.scalar<tstring>()() = variables_path;
309
310 std::vector<std::pair<string, Tensor>> inputs = {
311 {string(variable_filename_const_op_name), variables_path_tensor}};
312
313 AddAssetsTensorsToInputs(export_dir, asset_file_defs, &inputs);
314
315 RunMetadata run_metadata;
316 return RunOnce(run_options, inputs, {}, {string(restore_op_name)},
317 nullptr /* outputs */, &run_metadata, session);
318}
319
320Status GetAssetFileDefs(const MetaGraphDef& meta_graph_def,
321 std::vector<AssetFileDef>* asset_file_defs) {

Callers 1

LoadSavedModelInternalFunction · 0.70

Calls 8

MetaFilenameFunction · 0.85
DefaultFunction · 0.85
AddAssetsTensorsToInputsFunction · 0.70
RunOnceFunction · 0.70
JoinPathFunction · 0.50
TensorShapeClass · 0.50
okMethod · 0.45
FileExistsMethod · 0.45

Tested by

no test coverage detected