Example #1
0
    def init(self):
        # env init
        if not oneflow_api.IsEnvInited():
            flow.env.init()

        # session init
        if not oneflow_api.IsSessionInited():
            self._make_config_proto()
            session_util._TryCompleteConfigProto(self.config_proto_)
            c_api_util.InitLazyGlobalSession(self.config_proto_)

        self.status_ = self.SessionStatus.OPEN
Example #2
0
 def Init(self):
     assert self.status_ is SessionStatus.OPEN
     self.status_ = SessionStatus.RUNNING
     if not oneflow_api.IsEnvInited():
         oneflow.env.init()
     _TryCompleteConfigProto(self.config_proto)
     self.resource_ = self.config_proto.resource
     if not oneflow_api.EagerExecutionEnabled():
         c_api_util.InitLazyGlobalSession(self.config_proto)
         for job_name, func_desc in self.job_name2function_desc_.items():
             compiler.Compile(self, func_desc, self.config_proto)
             self.existed_module_names_ = set()
         self.job_name2var_name2var_blob_ = dict()
         assert len(self.job_name2function_desc_.items()) > 0
         oneflow_api.StartLazyGlobalSession()
         self.inter_user_job_info_ = c_api_util.GetInterUserJobInfo()
         # Get latest op_attr and job_name after compiler.Compile
         self.UpdateInfo4InterfaceOp()
         if not config_util.api_legacy_model_io_enabled():
             check_point_v2.Init()
     else:
         self.eager_config_proto_ctx_ = oneflow_api.LogicalConfigProtoContext(
             str(self.config_proto))
     return self
Example #3
0
def env_initialized(ctx):
    assert in_normal_mode(ctx)
    return oneflow_api.IsEnvInited()