§
    z”jú
  ã                  óp   — d dl mZ d dlmZ d dlmZ d dlmZ erd dlmZ d dl	m
Z
 d dlmZ 	 	 	 	 ddd„ZdS )é    )Úannotations)ÚTYPE_CHECKING)Ú	framework)Ústream)ÚTensor)Útask)ÚGroupNTÚtensorr   Úgather_listúlist[Tensor] | NoneÚdstÚintÚgroupúGroup | NoneÚsync_opÚboolÚreturnútask | Nonec                ól   — t          j        ¦   «         s
J d¦   «         ‚t          j        | ||||¦  «        S )a  

    Gather tensors from all participators.

    Args:
        tensor (Tensor): The input Tensor. Its data type
            should be float16, float32, float64, int32, int64, int8, uint8, bool or bfloat16.
        gather_list (list): A list of Tensors to hold the gathered tensors. Every element in the list must be a Tensor whose data type
            should be float16, float32, float64, int32, int64, int8, uint8, bool or bfloat16. Default value is None.
        dst (int): The dst rank id. Default value is 0.
        group (Group, optional): The group instance return by new_group or None for global default group.
        sync_op (bool, optional): Whether this op is a sync op. The default value is True.

    Returns:
        Async work handle,which can be wait on, if async_op is set to True.
        None, if not async_op

    Examples:
        .. code-block:: python

            >>> # doctest: +REQUIRES(env: DISTRIBUTED)
            >>> import paddle
            >>> import paddle.distributed as dist

            >>> dist.init_parallel_env()
            >>> gather_list = [] # type: ignore
            >>> if dist.get_rank() == 0:
            ...     data = paddle.to_tensor([1, 2, 3])
            ...     dist.gather(data, gather_list, dst=0)
            >>> else:
            ...     data = paddle.to_tensor([4, 5, 6])
            ...     dist.gather(data, gather_list, dst=0)
            >>> print(gather_list)
            >>> # [[1, 2, 3], [4, 5, 6]] (2 GPUs, out for rank 0)
            >>> # [] (2 GPUs, out for rank 1)
    z-gather doesn't support static graph mode yet.)r   Úin_dynamic_moder   Úgather)r
   r   r   r   r   s        úw/lsinfo/ai/hellotax_ai/data_center/backend/venv/lib/python3.11/site-packages/paddle/distributed/communication/gather.pyr   r      sE   € õV Ô$Ñ&Ô&ð ð Ø7ñô Ð&õ Œ=˜ ¨c°5¸'ÑBÔBÐBó    )Nr   NT)r
   r   r   r   r   r   r   r   r   r   r   r   )Ú
__future__r   Útypingr   Úpaddler   Ú paddle.distributed.communicationr   r   Úpaddle.base.corer   Ú&paddle.distributed.communication.groupr	   r   © r   r   ú<module>r!      sÅ   ðð  #Ð "Ð "Ð "Ð "Ð "à  Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð Ð Ð Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3àð =ØÐÐÐÐÐØ%Ð%Ð%Ð%Ð%Ð%Ø<Ð<Ð<Ð<Ð<Ð<ð
 (,ØØØð.Cð .Cð .Cð .Cð .Cð .Cð .Cr   