MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / InitRuntime

Method InitRuntime

oneflow/core/framework/nn_graph.cpp:565–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563}
564
565Maybe<void> NNGraph::InitRuntime() {
566 CHECK_OR_RETURN(!runtime_inited_)
567 << Error::RuntimeError() << "nn.Graph runtime is already initialized";
568
569 auto compile_tc = std::make_unique<CostCounter<std::chrono::seconds>>(true, true);
570 NewRuntimeBuffers();
571
572 JUST(GetVariableRealBlobAfterSyncPlan());
573
574 // NOTE(strint): Do memory shrink to free cached memory in eager VM before graph runtime init.
575 JUST(vm::CurrentRankSync());
576 auto* vm = JUST(SingletonMaybe<VirtualMachine>());
577 JUST(vm->ShrinkAllMem());
578
579 if (Singleton<ResourceDesc, ForSession>::Get()->enable_debug_mode()) {
580 auto cur_rank = GlobalProcessCtx::Rank();
581 auto plan_name = "job_" + name_ + "_plan";
582 if (JUST(CurrentCompileMode()) != CompileMode::kNaive) {
583 plan_name += std::to_string(cur_rank);
584 }
585 if (cur_rank == 0 || JUST(CurrentCompileMode()) != CompileMode::kNaive) {
586 TeePersistentLogStream::Create(plan_name)->Write(plan_);
587 PlanUtil::ToDotFile(plan_, plan_name + ".dot");
588 }
589 }
590
591 runtime_.reset(new Runtime(plan_, variable_op_name2eager_blob_object_));
592 compile_tc->Count("[GraphCompile]" + name_ + " InitRuntime", 0, true);
593 JUST(LogProgress("[GraphCompile]" + name_ + " Done", true));
594
595 runtime_inited_ = true;
596 return Maybe<void>::Ok();
597}
598
599Maybe<void> NNGraph::AlignStatesAfterLogicalGraphCompile() {
600 auto compile_tc = std::make_unique<CostCounter<std::chrono::seconds>>(true, true);

Callers

nothing calls this directly

Calls 10

CurrentRankSyncFunction · 0.85
GetFunction · 0.85
CurrentCompileModeFunction · 0.85
to_stringFunction · 0.85
LogProgressFunction · 0.85
ShrinkAllMemMethod · 0.80
enable_debug_modeMethod · 0.80
WriteMethod · 0.45
resetMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected