scatter_object_list

paddle.distributed. scatter_object_list ( out_object_list, in_object_list=None, src=0, group=None ) [source]

Scatter picklable objects from the source to all others. Similiar to scatter(), but python object can be passed in.

Parameters
  • out_object_list (list) – The list of objects to store the scattered objects.

  • in_object_list (list) – The list of objects to scatter. Only objects on the src rank will be scattered.

  • src (int) – The source rank in global view.

  • group (Group) – The group instance return by new_group or None for global default group.

Returns

None.

Warning

This API only supports the dygraph mode.

Examples

>>> 
>>> import paddle.distributed as dist

>>> dist.init_parallel_env()
>>> out_object_list = []
>>> if dist.get_rank() == 0:
...     in_object_list = [{'foo': [1, 2, 3]}, {'foo': [4, 5, 6]}]
>>> else:
...     in_object_list = [{'bar': [1, 2, 3]}, {'bar': [4, 5, 6]}]
>>> dist.scatter_object_list(out_object_list, in_object_list, src=1)
>>> print(out_object_list)
>>> # [{'bar': [1, 2, 3]}] (2 GPUs, out for rank 0)
>>> # [{'bar': [4, 5, 6]}] (2 GPUs, out for rank 1)