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

Method Init

serving/processor/serving/model_instance.cc:237–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237Status LocalSessionInstance::Init(ModelConfig* config,
238 ModelStore* model_store) {
239 // init local partition policy
240 PartitionPolicy::GetGlobalPolicy()->Init(config);
241
242 model_store->GetLatestVersion(version_);
243 while (version_.SavedModelEmpty() ||
244 (config->enable_incr_model_update && version_.CkptEmpty())) {
245 if (config->enable_incr_model_update) {
246 // Wait until saved model meta file ready
247 LOG(INFO) << "[Model Instance] SavedModel or Checkpoint dir is empty,"
248 << "will try 1 minute later, current version: "
249 << version_.DebugString();
250 } else {
251 LOG(INFO) << "[Model Instance] SavedModel dir is empty,"
252 << "will try 1 minute later, current version: "
253 << version_.DebugString();
254 }
255
256 sleep(60);
257 model_store->GetLatestVersion(version_);
258 }
259
260 TF_RETURN_IF_ERROR(ReadMetaGraphDefFromSavedModel(
261 version_.savedmodel_dir.c_str(),
262 {kSavedModelTagServe}, &meta_graph_def_));
263
264 warmup_file_name_ = config->warmup_file_name;
265 parser_ = ParserFactory::GetInstance(config->serialize_protocol, 4);
266
267 GraphOptimizerOption option;
268 option.native_tf_mode = true;
269 if (config->shard_embedding) {
270 option.shard_embedding = config->shard_embedding;
271 option.shard_embedding_names = config->shard_embedding_names;
272 option.partition_id = PartitionPolicy::GetGlobalPolicy()->GetEmbeddingGroupId();
273 option.shard_instance_count =
274 PartitionPolicy::GetGlobalPolicy()->GetShardInstanceCount();
275 }
276
277 option.st = config->storage_type;
278 option.path = config->storage_path;
279 option.size = config->storage_size;
280
281 optimizer_ = new SavedModelOptimizer(config->signature_name,
282 &meta_graph_def_, option);
283 TF_RETURN_IF_ERROR(optimizer_->Optimize());
284
285 TF_RETURN_IF_ERROR(ReadModelSignature(config));
286
287 session_mgr_ = new ModelSessionMgr(meta_graph_def_,
288 session_options_, run_options_);
289
290 if (config->enable_incr_model_update) {
291 return LoadModelFromCheckpoint(config, true);
292 } else {
293 return LoadSavedModel(config);
294 }

Callers 2

CreateInstancesMethod · 0.45
ModelUpdaterMethod · 0.45

Calls 14

sleepFunction · 0.85
GetInstanceFunction · 0.85
GetLatestVersionMethod · 0.80
SavedModelEmptyMethod · 0.80
CkptEmptyMethod · 0.80
c_strMethod · 0.80
GetEmbeddingGroupIdMethod · 0.80
GetShardInstanceCountMethod · 0.80
LoadSavedModelFunction · 0.50
DebugStringMethod · 0.45
OptimizeMethod · 0.45

Tested by

no test coverage detected