ó
    Î‘®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	  S SK
Jr  \(       a  S SKJr  / r S       SS	 jjr S       SS
 jjr S       SS jjr S       SS jjrg)é    )Úannotations)ÚTYPE_CHECKING)Ú_C_ops)Úcheck_variable_and_dtype)ÚLayerHelper)Úin_dynamic_or_pir_mode)ÚTensorNc                óD  • [        5       (       a  [        R                  " XS5      $ [        U SSS5        [        USSS5        [	        S0 [        5       D6nUR                  U R                  S9nUR                  U R                  S9nUR                  SXS.XES	.S
S0S9  U$ )aE  
Segment Sum Operator.

This operator sums the elements of input `data` which with
the same index in `segment_ids`.
It computes a tensor such that $out_i = \\sum_{j} data_{j}$
where sum is over j such that `segment_ids[j] == i`.

Args:
    data (Tensor): A tensor, available data type float32, float64, int32, int64, float16.
    segment_ids (Tensor): A 1-D tensor, which have the same size
                        with the first dimension of input data.
                        Available data type is int32, int64.
    name (str, optional): Name for the operation (optional, default is None).
                        For more information, please refer to :ref:`api_guide_Name`.

Returns:
    - output (Tensor), the reduced result.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> data = paddle.to_tensor([[1, 2, 3], [3, 2, 1], [4, 5, 6]], dtype='float32')
        >>> segment_ids = paddle.to_tensor([0, 0, 1], dtype='int32')
        >>> out = paddle.geometric.segment_sum(data, segment_ids)
        >>> print(out.numpy())
        [[4. 4. 4.]
         [4. 5. 6.]]

ÚSUMÚX©Úfloat32Úfloat64Úint32Úint64Úfloat16Úuint16Úsegment_poolÚ
SegmentIds©r   r   ©Údtype©r   r   ©ÚOutÚ	SummedIdsÚpooltype©ÚtypeÚinputsÚoutputsÚattrs)Úsegment_sum©	r   r   r   r   r   ÚlocalsÚ"create_variable_for_type_inferencer   Ú	append_op©ÚdataÚsegment_idsÚnameÚhelperÚoutÚ
summed_idss         ÚU/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/geometric/math.pyr#   r#      s¹   € ôD ×ÑÜ×"Ò" 4°eÓ<Ð<ä ØØØIØô		
ô 	!Ø˜Ð'9¸>ô	
ô Ñ7¬f«hÑ7ˆØ×7Ñ7¸d¿j¹jÐ7ÐIˆØ×>Ñ>ÀTÇZÁZÐ>ÐPˆ
Ø×ÑØØÑ9ØÑ9Ø˜uÐ%ð	 	ñ 	
ð ˆ
ó    c                óD  • [        5       (       a  [        R                  " XS5      $ [        U SSS5        [        USSS5        [	        S0 [        5       D6nUR                  U R                  S9nUR                  U R                  S9nUR                  SXS.XES	.S
S0S9  U$ )a˜  
Segment mean Operator.

This operator calculate the mean value of input `data` which
with the same index in `segment_ids`.
It computes a tensor such that $out_i = \\frac{1}{n_i}  \\sum_{j} data[j]$
where sum is over j such that 'segment_ids[j] == i' and $n_i$ is the number
of all index 'segment_ids[j] == i'.

Args:
    data (tensor): a tensor, available data type float32, float64, int32, int64, float16.
    segment_ids (tensor): a 1-d tensor, which have the same size
                        with the first dimension of input data.
                        available data type is int32, int64.
    name (str, optional): Name for the operation (optional, default is None).
                        For more information, please refer to :ref:`api_guide_Name`.

Returns:
    - output (Tensor), the reduced result.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> data = paddle.to_tensor([[1, 2, 3], [3, 2, 1], [4, 5, 6]], dtype='float32')
        >>> segment_ids = paddle.to_tensor([0, 0, 1], dtype='int32')
        >>> out = paddle.geometric.segment_mean(data, segment_ids)
        >>> print(out.numpy())
        [[2. 2. 2.]
         [4. 5. 6.]]

ÚMEANr   r   r   r   r   r   r   r   r   r   )Úsegment_meanr$   r(   s         r/   r3   r3   X   s¹   € ôH ×ÑÜ×"Ò" 4°fÓ=Ð=ä ØØØIØô		
ô 	!Ø˜Ð'9¸>ô	
ô Ñ8¬v«xÑ8ˆØ×7Ñ7¸d¿j¹jÐ7ÐIˆØ×>Ñ>ÀTÇZÁZÐ>ÐPˆ
Ø×ÑØØÑ9ØÑ9Ø˜vÐ&ð	 	ñ 	
ð ˆ
r0   c                óD  • [        5       (       a  [        R                  " XS5      $ [        U SSS5        [        USSS5        [	        S0 [        5       D6nUR                  U R                  S9nUR                  U R                  S9nUR                  SXS.XES	.S
S0S9  U$ )aR  
Segment min operator.

This operator calculate the minimum elements of input `data` which with
the same index in `segment_ids`.
It computes a tensor such that $out_i = \\min_{j} data_{j}$
where min is over j such that `segment_ids[j] == i`.

Args:
    data (tensor): a tensor, available data type float32, float64, int32, int64, float16.
    segment_ids (tensor): a 1-d tensor, which have the same size
                        with the first dimension of input data.
                        available data type is int32, int64.
    name (str, optional): Name for the operation (optional, default is None).
                        For more information, please refer to :ref:`api_guide_Name`.

Returns:
    - output (Tensor), the reduced result.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> data = paddle.to_tensor([[1, 2, 3], [3, 2, 1], [4, 5, 6]], dtype='float32')
        >>> segment_ids = paddle.to_tensor([0, 0, 1], dtype='int32')
        >>> out = paddle.geometric.segment_min(data, segment_ids)
        >>> print(out.numpy())
        [[1. 2. 1.]
         [4. 5. 6.]]

ÚMINr   r   r   r   r   r   r   r   r   r   )Úsegment_minr$   r(   s         r/   r6   r6   •   ó¹   € ôF ×ÑÜ×"Ò" 4°eÓ<Ð<ä ØØØIØô		
ô 	!Ø˜Ð'9¸>ô	
ô Ñ7¬f«hÑ7ˆØ×7Ñ7¸d¿j¹jÐ7ÐIˆØ×>Ñ>ÀTÇZÁZÐ>ÐPˆ
Ø×ÑØØÑ9ØÑ9Ø˜uÐ%ð	 	ñ 	
ð ˆ
r0   c                óD  • [        5       (       a  [        R                  " XS5      $ [        U SSS5        [        USSS5        [	        S0 [        5       D6nUR                  U R                  S9nUR                  U R                  S9nUR                  SXS.XES	.S
S0S9  U$ )aR  
Segment max operator.

This operator calculate the maximum elements of input `data` which with
the same index in `segment_ids`.
It computes a tensor such that $out_i = \\max_{j} data_{j}$
where max is over j such that `segment_ids[j] == i`.

Args:
    data (tensor): a tensor, available data type float32, float64, int32, int64, float16.
    segment_ids (tensor): a 1-d tensor, which have the same size
                        with the first dimension of input data.
                        available data type is int32, int64.
    name (str, optional): Name for the operation (optional, default is None).
                        For more information, please refer to :ref:`api_guide_Name`.

Returns:
    - output (Tensor), the reduced result.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> data = paddle.to_tensor([[1, 2, 3], [3, 2, 1], [4, 5, 6]], dtype='float32')
        >>> segment_ids = paddle.to_tensor([0, 0, 1], dtype='int32')
        >>> out = paddle.geometric.segment_max(data, segment_ids)
        >>> print(out.numpy())
        [[3. 2. 3.]
         [4. 5. 6.]]

ÚMAXr   r   r   r   r   r   r   r   r   r   )Úsegment_maxr$   r(   s         r/   r:   r:   Ñ   r7   r0   )N)r)   r	   r*   r	   r+   z
str | NoneÚreturnr	   )Ú
__future__r   Útypingr   Úpaddler   Úpaddle.base.data_feederr   Úpaddle.base.layer_helperr   Úpaddle.frameworkr   r	   Ú__all__r#   r3   r6   r:   © r0   r/   Ú<module>rD      sÏ   ðõ #å  å Ý <Ý 0Ý 3æÝà
€ð ;?ð8Ø
ð8Ø%ð8Ø-7ð8àõ8ðx ;?ð:Ø
ð:Ø%ð:Ø-7ð:àõ:ð| ;?ð9Ø
ð9Ø%ð9Ø-7ð9àõ9ðz ;?ð9Ø
ð9Ø%ð9Ø-7ð9àö9r0   