def GetGlobalModePlacementScope(device_tag, machine_device_ids): if isinstance(machine_device_ids, (list, tuple)) == False: machine_device_ids = [machine_device_ids] sess = session_ctx.GetDefaultSession() def BuildScope(old_scope, builder): return old_scope.BuildWithNewParallelDesc(builder, device_tag, machine_device_ids) scope_ctx = scope_util.ScopeContext(scope_util.MakeScope(BuildScope)) return placement_ctx.GlobalModePlacementScope(scope_ctx)
def GetGlobalModePlacementScope(device_tag, machine_device_ids, hierarchy=None): if isinstance(machine_device_ids, (list, tuple)) == False: machine_device_ids = [machine_device_ids] sess = session_ctx.GetDefaultSession() if hierarchy is not None: hierarchy = oneflow_api.Size(tuple(hierarchy)) def BuildScope(old_scope, builder): return builder.BuildScopeWithNewParallelDesc( old_scope, device_tag, machine_device_ids, hierarchy ) scope_ctx = scope_util.ScopeContext(scope_util.MakeScope(BuildScope)) return placement_ctx.GlobalModePlacementScope(scope_ctx)