
    Αi                        S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	J
r
Jr  \(       a  S SKJr  S SKJr  S SKJr  S	 rS
 r    S           SS jjrg)    )annotations)TYPE_CHECKING)	framework)data_feeder)_get_global_group_get_or_throw_group_rank_warn_cur_rank_not_in_group)Tensor)task)Groupc                    U(       a  UR                   R                  X5      $ UR                   R                  XU5      nU(       a  UR                  " 5         U$ )N)process_groupsend_on_calc_streamsendwait)tensordst_rank_in_groupgroupsync_opuse_calc_streamr   s         l/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/distributed/communication/stream/send.py_send_in_dygraphr   !   sN     ""66
 	
 ##FwGD		K    c                    Sn[         R                  " U S/ SQS5        Uc  SOUR                  n[        R                  " U40 [        5       D6nUR                  USU /0UUUS.S9  g )	Nsend_v2r   )float16float32float64int32int64uint16r   r   X)ring_idpeerr   )typeinputsattrs)r   check_variable_and_dtypeidr   LayerHelperlocals	append_op)r   r   r   r   r   op_typer#   helpers           r   _send_in_static_moder/   0   sx     G((E	 =aehhG""77fh7F
fX%&
  r   Nc                   [        U5      (       a  gU(       d  U(       a  [        S5      e[        R                  " 5       (       a'  Uc
  [	        5       OUn[        X5      n[        XX#U5      $ Ub   S5       e[        XX#U5      $ )a  

Send a tensor to the destination device.

Args:
    tensor (Tensor): The tensor to send. Support float16, float32, float64, int32, int64, int8, uint8 or bool as its data type.
    dst (int, optional): Rank of the destination device. If none is given, use `0` as default.
    group (Group, optional): Communicate in which group. If none is given, use the global group as default.
    sync_op (bool, optional): Indicate whether the communication is sync or not. If none is given, use true as default.
    use_calc_stream (bool, optional): Indicate whether the communication is done on calculation stream. If none is given, use false as default. This
        option is designed for high performance demand, be careful to turn it on except you are clearly know its meaning.

Returns:
    Return a task object.

Examples:
    .. code-block:: python

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

        >>> dist.init_parallel_env()
        >>> local_rank = dist.get_rank()
        >>> if local_rank == 0:
        ...     data = paddle.to_tensor([[4, 5, 6], [4, 5, 6]])
        ...     task = dist.stream.send(data, dst=1, sync_op=False)
        >>> else:
        ...     data = paddle.to_tensor([[1, 2, 3], [1, 2, 3]])
        ...     task = dist.stream.recv(data, src=0, sync_op=False)
        >>> task.wait()  # type: ignore[union-attr]
        >>> out = data.numpy()
        >>> print(out)
        [[4, 5, 6], [4, 5, 6]]
Nz5use_calc_stream can only be True in sync op behavior.z3Group can not be used in static graph mode for now.)r	   RuntimeErrorr   in_dynamic_moder   r   r   r/   )r   dstr   r   r   r   s         r   r   r   H   s    T #5))C
 	
   ""',}!#%4S@u
 	
 } 	
A	
} $
 	
r   )r   NTF)r   r
   r3   intr   zGroup | Noner   boolr   r5   returnztask | None)
__future__r   typingr   paddler   paddle.baser   &paddle.distributed.communication.groupr   r   r	   r
   paddle.base.corer   r   r   r/   r    r   r   <module>r>      s    #    #  %<4 !?
?
	?
 ?
 	?

 ?
 ?
r   