| 235 | } |
| 236 | |
| 237 | Status 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 | } |
no test coverage detected