def _GetPhysicalBlobObjects(logical_blob_object, lbi): blob_register = blob_register_util.GetDefaultBlobRegister() physical_blob_objects = None def BuildLogical2PhysicalInstruction(builder): nonlocal physical_blob_objects physical_blob_objects = builder.UnpackLogicalBlobToPhysicalBlobs( logical_blob_object) vm_util.LogicalRun(BuildLogical2PhysicalInstruction) return physical_blob_objects
def MirroredCast(op_attribute_str, parallel_conf): op_attribute = text_format.Parse(op_attribute_str, op_attribute_pb.OpAttribute()) blob_register = blob_register_util.GetDefaultBlobRegister() is_cast_to_mirrored = op_attribute.op_conf.HasField("cast_to_mirrored_conf") is_cast_from_mirrored = op_attribute.op_conf.HasField("cast_from_mirrored_conf") assert is_cast_to_mirrored or is_cast_from_mirrored _MirroredCastAndAddOutputBlobReleaser(op_attribute, blob_register) bw_blob_register = gradient_util.GetDefaultBackwardBlobRegister() gradient_util.TrySetBackwardUsedBlobObject( op_attribute, blob_register, bw_blob_register )
def ForceReleaseEagerBlobs(self): blob_register_util.GetDefaultBlobRegister().ForceReleaseAll() self.backward_blob_register_.ForceReleaseAll()
import oneflow.core.job.placement_pb2 as placement_proto_pb import oneflow.core.operator.op_conf_pb2 as op_conf_util import oneflow.core.register.logical_blob_id_pb2 as logical_blob_id_util import oneflow.python.framework.c_api_util as c_api_util import oneflow.python.framework.compile_context as compile_context import oneflow.python.framework.id_util as id_util import oneflow.python.framework.input_blob_def as input_blob_util import oneflow.python.framework.remote_blob as remote_blob_util import oneflow.python.framework.hob as hob import oneflow.python.lib.core.enable_if as enable_if import oneflow.python.framework.session_context as session_ctx import oneflow.python.framework.scope_util as scope_util import oneflow.python.eager.vm_util as vm_util import oneflow.python.eager.blob_register as blob_register_util blob_register = blob_register_util.GetDefaultBlobRegister() def InputOpByArgBlobDef(blob_def): assert isinstance(blob_def, input_blob_util.ArgBlobDef) op_conf = op_conf_util.OperatorConf() op_conf.name = blob_def.op_name op_conf.input_conf.out = blob_def.blob_name op_conf.input_conf.blob_conf.CopyFrom(blob_def.ToInterfaceBlobConf()) blob_def.AddAndInferOp(op_conf) return remote_blob_util.RemoteBlob(blob_def.lbi) def ReturnRemoteBlob(remote_blob, allow_cpu_return_op=True): return enable_if.unique([LazyReturnRemoteBlob, EagerReturnRemoteBlob])(remote_blob,