
    ёis4                    B   S SK Jr  S SKJr  S SKrS SKJrJr  S SKJr  S SK	J
r
Jr  SSKJr  SS	KJr  SS
KJr  SSKJrJr  \(       a  S SKJr  S SKJr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_CHECKINGN)_C_opsin_dynamic_mode)grid_sample)in_dynamic_or_pir_modein_pir_mode   )check_variable_and_dtype)LayerHelper)Variable)get_cudnn_versionis_compiled_with_rocm)Tensor)DataLayout2D	ShapeLikec                
   [        U [        [        R                  R                  45      (       d  [        S5      e[        5       nUb  US:  a
  U(       a  SnOSnU R                  S   S:X  a  Sn[        5       (       a  Sn[        R                  " S/5      R                  SS5      (       a  Sn[        5       (       a  [        U[        5      (       a  UR                  5       OUn[        U[        R                  5      (       a  UR                  S	:X  a  [        S
5      eU R!                  U5      n ["        R$                  " XU5      $ ['        5       (       a  ["        R$                  " U UU5      $ [)        S0 [+        5       D6n[-        U SSS/S5        UR/                  U R0                  S9nSU 0n	X%S.n
[        U[        5      (       a  XS'   [-        USS/S5        OXS'   UR3                  SU	SU0[5        U
5      S	:X  a  SOU
S9  U$ )a	  
It generates a grid of (x,y) or (x,y,z) coordinates using the parameters of
the affine transformation that correspond to a set of points where
the input feature map should be sampled to produce the transformed
output feature map.

Args:
    theta (Tensor): A tensor with shape [N, 2, 3] or [N, 3, 4]. It contains a batch of affine transform parameters.
                       The data type can be float32 or float64.
    out_shape (Tensor | list | tuple): Type can be a 1-D Tensor, list, or tuple. It is used to represent the shape of the output in an affine transformation, in the format ``[N, C, H, W]`` or ``[N, C, D, H, W]``.
                                       When the format is ``[N, C, H, W]``, it represents the batch size, number of channels, height and width. When the format is ``[N, C, D, H, W]``, it represents the batch size, number of channels, depth, height and width.
                                       The data type must be int32.
    align_corners(bool, optional): if True, aligns the centers of the 4 (4D) or 8 (5D) corner pixels of the input and output tensors, and preserves the value of the corner pixels. Default: True
    name(str|None, optional): The default value is None.  Normally there is no need for user to set this property.  For more information, please refer to :ref:`api_guide_Name`.

Returns:
    Tensor, A Tensor with shape [batch_size, H, W, 2] or [batch, D, H, W, 3] while ('D')'H', 'W' are the (depth)height, width of feature map in affine transformation. The data type is the same as `theta`.

Examples:

    .. code-block:: python

        >>> import paddle
        >>> import paddle.nn.functional as F
        >>> # theta.shape = [1, 2, 3]
        >>> theta = paddle.to_tensor([[[-0.7, -0.4, 0.3],
        ...                            [ 0.6,  0.5, 1.5]]], dtype="float32")
        >>> y_t = F.affine_grid(
        ...     theta,
        ...     [1, 2, 3, 3],
        ...     align_corners=False
        ... )
        >>> print(y_t)
        Tensor(shape=[1, 3, 3, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[[ 1.03333330,  0.76666665],
           [ 0.56666672,  1.16666663],
           [ 0.10000002,  1.56666672]],
          [[ 0.76666665,  1.09999990],
           [ 0.30000001,  1.50000000],
           [-0.16666666,  1.90000010]],
          [[ 0.50000000,  1.43333328],
           [ 0.03333333,  1.83333337],
           [-0.43333334,  2.23333335]]]])
zThe theta should be a Tensor.Nip  TF   r
   $FLAGS_use_accuracy_compatible_kernelr   zThe out_shape cannot be empty.affine_gridthetafloat32float64dtypeTheta)align_corners	use_cudnnOutputShape	out_shapeint32output_shapeOutputtypeinputsoutputsattrs)r   )
isinstancer   paddlepirValue	TypeErrorr   shaper   	get_flagsgetr   tolistr   size
ValueError_use_gpudnnr   r   r	   r   localsr   "create_variable_for_type_inferencer   	append_oplen)r   r    r   namecudnn_versionr   
_out_shapehelperoutr&   r(   s              [/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/paddle/nn/functional/vision.pyr   r   '   s   d eh

(8(89::788%'M ]d%:}		{{1~	 	 ?@AEE.  	",Y"A"AIy 	 j&--00Z__5I=>>!!),!!%]CC	!!
 	
 7fh7 7Y	2M	
 77ekk7J5!"/Hi**$-=!$;	= %..!sOe*/$u	 	 	
 
    c                f   [        U[        5      (       d  [        S5      eUS;  a  [        SU S35      e[	        5       (       a  [
        R                  " XU5      $ [        S0 [        5       D6n[        U S/ SQS5        UR                  U R                  S9nUR                  SS	U 0S
U0UUS.S9  U$ )a  
This API implements pixel shuffle operation.
See more details in :ref:`PixelShuffle <api_paddle_nn_PixelShuffle>` .


Parameters:
    x(Tensor): 4-D tensor, the data type should be float32 or float64.
    upscale_factor(int): factor to increase spatial resolution.
    data_format (str, optional): The data format of the input and output data. An optional string from: ``"NCHW"``, ``"NHWC"``. When it is ``"NCHW"``, the data is stored in the order of: [batch_size, input_channels, input_height, input_width]. Default: ``"NCHW"``.
    name (str|None, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.

Returns:
    Out(tensor): Reshaped tensor according to the new dimension.

Examples:
    .. code-block:: pycon

        >>> import paddle
        >>> import paddle.nn.functional as F

        >>> x = paddle.randn(shape=[2, 9, 4, 4])
        >>> out_var = F.pixel_shuffle(x, 3)
        >>> print(out_var.shape)
        paddle.Size([2, 1, 12, 12])
zupscale factor must be int typeNCHWNHWCLAttr(data_format) should be 'NCHW' or 'NHWC'.But receive Attr(data_format):  pixel_shufflex)float16r   r   r   XOut)upscale_factordata_formatr$   )rF   )r)   intr-   r3   r   r   rF   r   r5   r   r6   r   r7   )rG   rK   rL   r9   r<   r=   s         r>   rF   rF      s    > nc**9::**..9]!=
 	
 ##A{CC99 s5	
 77agg7F 8CL"0*	 	 	
 
r?   c                   [        U R                  5      S:w  a  [        SU R                   35      e[        U[        5      (       d  [        S5      eUS::  a  [        S5      eUS;  a  [        SU S35      e[        5       (       a  [        R                  " XU5      $ [        S0 [        5       D6n[        U S
/ SQS	5        UR                  U R                  S9nUR                  S	SU 0SU0UUS.S9  U$ )a2  
This API implements pixel unshuffle operation.
See more details in :ref:`PixelUnShuffle <api_paddle_nn_PixelUnshuffle>` .

Parameters:
    x (Tensor): 4-D tensor, the data type should be float32 or float64.
    downscale_factor (int): Factor to decrease spatial resolution.
    data_format (str, optional): The data format of the input and output data. An optional string of ``'NCHW'`` or ``'NHWC'``. When it is ``'NCHW'``, the data is stored in the order of [batch_size, input_channels, input_height, input_width]. Default: ``'NCHW'``.
    name (str|None, optional): Name for the operation (optional, default is None). Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`.

Returns:
    Out (Tensor): Reshaped tensor according to the new dimension.

Examples:
    .. code-block:: pycon

        >>> import paddle
        >>> import paddle.nn.functional as F
        >>> x = paddle.randn([2, 1, 12, 12])
        >>> out = F.pixel_unshuffle(x, 3)
        >>> print(out.shape)
        paddle.Size([2, 9, 4, 4])
   >Input x should be 4D tensor, but received x with the shape of z!Downscale factor must be int typer   z!Downscale factor must be positiverA   rD   rE   pixel_unshufflerG   )rH   r   r   uint16r   rI   rJ   )downscale_factorrL   r$   )rQ   )r8   r.   r3   r)   rM   r-   r   r   rQ   r   r5   r   r6   r   r7   )rG   rS   rL   r9   r<   r=   s         r>   rQ   rQ      s   : 177|qLQWWIV
 	
 &,,;<<1<==**..9]!=
 	

 %%a;GG7fh7F	3;=N 
3
3!''
3
BC
Qx 0&
	   Jr?   c                   [        U R                  5      S:w  a  [        SU R                   35      e[        U[        5      (       d  [        S5      eUS::  a  [        S5      eUS;  a  [        SU S35      e[        5       (       a  [        R                  " XU5      $ [        S0 [        5       D6n[        U S
SS/S	5        UR                  U R                  S9nUR                  S	SU 0SU0XS.S9  U$ )a  
This API implements channel shuffle operation.
See more details in :ref:`api_paddle_nn_ChannelShuffle`.

Parameters:
    x (Tensor): 4-D tensor, the data type should be float32 or float64.
    groups (int): Number of groups to divide channels in.
    data_format (str, optional): The data format of the input and output data. An optional string of NCHW or NHWC. The default is NCHW. When it is NCHW, the data is stored in the order of [batch_size, input_channels, input_height, input_width].
    name (str|None, optional): Name for the operation (optional, default is None). Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`.

Returns:
    Out (Tensor): Rearranged tensor keeping the original tensor shape.

Examples:
    .. code-block:: python

        >>> import paddle
        >>> import paddle.nn.functional as F
        >>> x = paddle.arange(0, 0.6, 0.1, 'float32')
        >>> x = paddle.reshape(x, [1, 6, 1, 1])
        >>> print(x)
        Tensor(shape=[1, 6, 1, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[[0.        ]],
          [[0.10000000]],
          [[0.20000000]],
          [[0.30000001]],
          [[0.40000001]],
          [[0.50000000]]]])
        >>> y = F.channel_shuffle(x, 3)
        >>> print(y)
        Tensor(shape=[1, 6, 1, 1], dtype=float32, place=Place(cpu), stop_gradient=True,
        [[[[0.        ]],
          [[0.20000000]],
          [[0.40000001]],
          [[0.10000000]],
          [[0.30000001]],
          [[0.50000000]]]])
rO   rP   zgroups must be int typer   zgroups must be positiverA   rD   rE   channel_shufflerG   r   r   r   rI   rJ   )groupsrL   r$   )rU   )r8   r.   r3   r)   rM   r-   r   r   rU   r   r5   r   r6   r   r7   )rG   rV   rL   r9   r<   r=   s         r>   rU   rU     s   X 177|qLQWWIV
 	
 fc""122{233**..9]!=
 	

 %%a==7fh7FQi%;=NO

3
3!''
3
BC
Qx<	   Jr?   )TN)
r   r   r    r   r   boolr9   
str | Nonereturnr   )rB   N)
rG   r   rK   rM   rL   r   r9   rX   rY   r   )
rG   r   rS   rM   rL   r   r9   rX   rY   r   )
rG   r   rV   rM   rL   r   r9   rX   rY   r   )
__future__r   typingr   r*   r   r   paddle._C_opsr   paddle.base.frameworkr   r	   base.data_feederr   base.layer_helperr   common_ops_importr   devicer   r   r   paddle._typingr   r   __all__r   rF   rQ   rU    r?   r>   <module>re      s2   #    * %
 9 , ) >6
 	jjj j 	j
 j` !'	888 8 	8
 8| !'	??? ? 	?
 ?J !'	III I 	I
 Ir?   