ó
    Î‘®ià  ã                  ó   • % S SK Jr  S SKJrJrJr  S SKrS SKJr  S SKJ	r	  \(       a"  S SK
Jr  S SKJr  S SKJr  S S	KJr  \S
   rS\S'    " S S5      rS rS r\R,                  SS4           SS jjrSS jrg)é    )Úannotations)ÚTYPE_CHECKINGÚClassVarÚLiteralN)Ú	framework)Ústream)Ú	TypeAlias)ÚTensor)Útask)ÚGroup)r   é   é   é   é   r	   Ú	_ReduceOpc                  ó`   • \ rS rSr% SrSrS\S'   SrS\S'   S	rS
\S'   Sr	S\S'   Sr
S\S'   Srg)ÚReduceOpé!   a²  

Specify the type of operation used for element-wise reductions.
It should be one of the following values:

    ReduceOp.SUM

    ReduceOp.MAX

    ReduceOp.MIN

    ReduceOp.PROD

Examples:
    .. code-block:: python

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

        >>> dist.init_parallel_env()
        >>> if dist.get_rank() == 0:
        ...     data = paddle.to_tensor([[4, 5, 6], [4, 5, 6]])
        >>> else:
        ...     data = paddle.to_tensor([[1, 2, 3], [1, 2, 3]])
        >>> dist.all_reduce(data, op=dist.ReduceOp.SUM)
        >>> print(data)
        >>> # [[5, 7, 9], [5, 7, 9]] (2 GPUs)
r   zClassVar[Literal[0]]ÚSUMr   zClassVar[Literal[1]]ÚMAXr   zClassVar[Literal[2]]ÚMINr   zClassVar[Literal[3]]ÚPRODr   zClassVar[Literal[4]]ÚAVG© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__annotations__r   r   r   r   Ú__static_attributes__r   ó    Úg/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/distributed/communication/reduce.pyr   r   !   s@   ‡ ñð< !"€CÐ	Ó!Ø !€CÐ	Ó!Ø !€CÐ	Ó!Ø!"€DÐ
Ó"Ø !€CÐ	Ö!r"   r   c                óP  • U [         R                  :X  a$  [        R                  R                   R                  $ U [         R                  :X  a$  [        R                  R                   R                  $ U [         R
                  :X  a$  [        R                  R                   R
                  $ U [         R                  :X  a$  [        R                  R                   R                  $ U [         R                  :X  a$  [        R                  R                   R                  $ [        SU  S35      e)NzUnknown reduce_op type for Ú.)
r   r   r   Úcorer   r   r   ÚPRODUCTr   Ú
ValueError)Ú	reduce_ops    r#   Ú_get_reduce_opr*   G   sÁ   € Ø”H—L‘LÓ Ü~‰~×&Ñ&×*Ñ*Ð*Ø	”h—l‘lÓ	"Ü~‰~×&Ñ&×*Ñ*Ð*Ø	”h—l‘lÓ	"Ü~‰~×&Ñ&×*Ñ*Ð*Ø	”h—m‘mÓ	#Ü~‰~×&Ñ&×.Ñ.Ð.Ø	”h—l‘lÓ	"Ü~‰~×&Ñ&×*Ñ*Ð*ä
Ð2°9°+¸QÐ?Ó
@Ð@r"   c                ó   • U  S3$ )NÚ_r   )Úop_names    r#   Ú_to_inplace_opr.   V   s   € ØˆYaˆ=Ðr"   Tc           	     ó^  • U[         R                  :X  a  [        5       (       dr  Uc(  [        R                  R
                  R                  5       OUnU R                  SUR                  -  5        [        R                  " U U[         R                  UUSS9$ [        R                  " U UUUUSS9$ )a|  

Reduce a tensor to the destination from all others. As shown below, one process is started with a GPU and the data of this process is represented
by its group rank. The destination of the reduce operator is GPU0 and the process is sum. Through reduce operator,
the GPU0 will owns the sum of all data from all GPUs.

.. image:: https://githubraw.cdn.bcebos.com/PaddlePaddle/docs/develop/docs/api/paddle/distributed/img/reduce.png
    :width: 800
    :alt: reduce
    :align: center

Args:
    tensor (Tensor): The output Tensor for the destination and the input Tensor otherwise. Its data type
        should be float16, float32, float64, int32, int64, int8, uint8, bool or bfloat16.
    dst (int): The destination rank id.
    op (ReduceOp.SUM|ReduceOp.MAX|ReduceOp.MIN|ReduceOp.PROD|ReduceOp.AVG, optional): The operation used. Default value is ReduceOp.SUM.
    group (Group|None, 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:
    Return a task object.

Examples:
    .. code-block:: python

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

        >>> dist.init_parallel_env()
        >>> if dist.get_rank() == 0:
        ...     data = paddle.to_tensor([[4, 5, 6], [4, 5, 6]])
        >>> else:
        ...     data = paddle.to_tensor([[1, 2, 3], [1, 2, 3]])
        >>> dist.reduce(data, dst=0)
        >>> print(data)
        >>> # [[5, 7, 9], [5, 7, 9]] (2 GPUs, out for rank 0)
        >>> # [[1, 2, 3], [1, 2, 3]] (2 GPUs, out for rank 1)
g      ð?F)ÚdstÚopÚgroupÚsync_opÚuse_calc_stream)r   r   Úis_avg_reduce_op_supportedÚpaddleÚdistributedÚ
collectiveÚ_get_global_groupÚscale_Únranksr   Úreducer   Ú	is_memberÚidÚget_group_rankr   r   r   Ú_C_opsr(   )Útensorr0   r1   r2   r3   r4   Úring_idÚgdsts           r#   r<   r<   Z   s¦   € ð^ 
ŒX\‰\ÓÔ#=×#?Ñ#?ð ‰}ô ×Ñ×)Ñ)×;Ñ;Ô=àð 	ð
 	‰c˜EŸL™LÑ(Ô)Ü}Š}ØØÜ|‰|ØØØ!ñ
ð 	
ô =Š=ØØØØØØñð r"   c                 óŽ   • [         R                  " 5       (       a+  [         R                  R                  R	                  5       S:¬  $ g)NiR  F)r6   Úis_compiled_with_cudaÚbaser&   Únccl_versionr   r"   r#   r5   r5   ¾   s2   € Ü×#Ò#×%Ñ%Ü{‰{×Ñ×,Ñ,Ó.°%Ñ7Ð7àr"   )rA   r
   r0   Úintr1   r   r2   zGroup | Noner3   ÚboolÚreturnr   )rJ   rI   )Ú
__future__r   Útypingr   r   r   r6   r   Ú paddle.distributed.communicationr   Útyping_extensionsr	   r
   Úpaddle.base.corer   Ú&paddle.distributed.communication.groupr   r   r    r   r*   r.   r   r<   r5   r   r"   r#   Ú<module>rQ      s¦   ðö #ç 3Ñ 3ã Ý Ý 3æÝ+åÝ%Ý<à" =Ñ1€IˆyÓ1÷#"ñ #"òLAòð —L‘LØØða6Øða6à	ða6ð 	ða6ð ð	a6ð
 ða6ð 
õa6õHr"   