oneflow.utils.global_view.to_local

oneflow.utils.global_view.to_local(input, *, copy=False)

Returns the local part of the input.

Returns

The converted input.

For a tensor input: please refer to the examples in oneflow.Tensor.to_local().

For an input of other type (take a state dict as an example):

>>> # Run on 2 ranks respectively
>>> import oneflow as flow
>>> from oneflow import nn
>>> placement = flow.placement("cpu", ranks=[0, 1]) 
>>> sbp = (flow.sbp.broadcast,) 
>>> model = nn.Sequential(nn.Linear(8, 4), nn.ReLU(), nn.Linear(4, 2)) 
>>> model = model.to_global(placement=placement, sbp=sbp) 
>>> local_state_dict = flow.utils.global_view.to_local(model.state_dict()) 
>>> for val in local_state_dict.values(): 
>>>     print(val.is_global) 
>>> # results on rank 0
False
False
False
False
>>> # results on rank 1
False
False
False
False