o
    + i                    @  s&  d dl mZ d dlmZ d dlZd dlmZmZmZmZm	Z	 d dl
mZmZ d dlmZmZmZ d dlmZ d dlmZ d	d
lmZmZ d	dlmZ d	dlmZ d	dlmZ d	dlmZ d	dl m!Z!m"Z" d	dl#m$Z$m%Z%m&Z&m'Z' erd dl(m)Z) d dlm*Z* d dl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6 g Z7dd Z8dd Z9dd Z:dd Z;			 							 	dTdUd7d8Z<			 			9	dVdWd=d>Z=			 				dXdYdBdZ>			 	 				9	dZd[dFdGZ?			 	 					d\d]dIdJZ@			 			K	d^d_dOdPZA			 	 				K	d`dadRdSZBdS )b    )annotations)TYPE_CHECKINGN)_C_ops_legacy_C_ops	get_flagsin_dynamic_modepir)_global_flagsin_dynamic_or_pir_mode)get_all_custom_device_typeis_compiled_with_cudais_compiled_with_rocm)reshape)_add_with_axis   )check_dtypecheck_variable_and_dtype)LayerHelper)Variable)get_cudnn_version)no_grad)squeeze	unsqueeze)_contain_var_convert_to_tensor_list_is_symmetric_paddingconvert_to_list)Sequence)Tensor)	DataLayout1DDataLayout2DDataLayout3DDataLayoutNDSize1Size2Size3Size4Size6   )_PaddingSizeModec                 C  s   t | ttfS )N)
isinstancelisttuple)input r.   e/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/paddle/nn/functional/conv.py_is_list_or_tupleA   s   r0   c                 C  sT   |rt | d ddgkot | d ddgkS t | d ddgko)t | d ddgkS )Nr   r(   )r+   )paddingchannel_lastr.   r.   r/   "_zero_padding_in_batch_and_channelE   s   ((r4   c                 C  s.   |r| dd n| dd  }dd |D }|S )Nr(   r1      c                 S  s   g | ]	}|D ]}|qqS r.   r.   ).0Z	pad_a_dimelemr.   r.   r/   
<listcomp>N   s    z9_exclude_padding_in_batch_and_channel.<locals>.<listcomp>r.   )r2   r3   Zpadding_r.   r.   r/   %_exclude_padding_in_batch_and_channelL   s   r9   c                 C  sv  t | tr)|  } | dvrtd|  d| dkr!d}dg| } nd}dg| } n~t| rt| d| kr\t| d r\t| |sHtd|  d	d
}t| |} t| |r[| dd d } nKt| d| krt | d t	rd
}t
| d| d} t| |r| dd d } n%t| |krt | d t	rd
}t
| |d} ntd|  d
}t
| |d} tdd | D std|  | |fS )N)SAMEVALIDzUnknown padding: 'z$'. It can only be 'SAME' or 'VALID'.r;   r   r:   r5   zNon-zero padding(z6) in the batch or channel dimensions is not supported.ZEXPLICITr2   zIn valid padding: c                 s  s    | ]}|d kV  qdS )r   Nr.   )r6   pr.   r.   r/   	<genexpr>   s    z%_update_padding_nd.<locals>.<genexpr>zNInvalid padding, all value should be larger than or equal to 0, but received: )r*   strupper
ValueErrorr0   lenr4   r9   r   intr   all)r2   r3   Znum_dimspadding_algorithmr.   r.   r/   _update_padding_ndR   sR   





rE   NCHWconv2dTxr   weightbiasTensor | Nonestrideint | Sequence[int]r2   8_PaddingSizeMode | int | Sequence[int] | Sequence[Size2]dilationgroupsrB   data_formatr"   channel_dimop_typer>   	use_cudnnboolname
str | Nonereturnc                 C  s:  t  rX|
dkrXt| |||||||}|d urVdgt| j }d||	< ||}t d rPdt v rPt  t	|d}|
| W d    n1 sKw   Y  t||S |S t  r|
dkrt| |||||||}|d urdgt| j }d||	< ||}t||S |S t  r|
dkrt| |||||||}|d urdgt| j }d||	< ||}t||S |S t rd	|d
|d|d|d|ddd|d|f}tt|
| |g|R  }|d urt|||	d}|S |}|S | g|gd}|||||d||d}t| dg d|
 t|
fi t }|jdd}||}d|gi}|j|
|||d |d ur||}t|j}t|j}|	dksIt|t|kr^|jd|g|gdd|giddid |S t|t|kskJ dt|t| |	 }t|dg|	 | dg|  }|jd|g|gdd|giddid |S |}|S )NrG   r(   r1   FLAGS_npu_storage_formatnpur   depthwise_conv2dconv3dstridespaddings	dilationsrP   rT   fuse_relu_before_depthwise_convFrD   rQ   axisZInputFilterr]   r^   r_   rP   rT   r`   rD   rQ   rH   float16Zuint16float32float64Zinput_param_nameOutputtypeinputsoutputsattrselementwise_addXYOutrb   ;The length of pre_bias must greater than the length of bias)r
   r   rG   rA   shaper   r	   r   r   npu_identity_share_underline_tensor_toaddr[   r\   r   getattrr   r   r   r   localsinput_dtype"create_variable_for_type_inference	append_opr+   )rH   rI   rJ   rL   r2   rD   rO   rP   rQ   rR   rS   rT   rV   pre_biasZ	new_shapebias_storagerp   outrn   helperdtypero   x_shapey_shaper.   r.   r/   _conv_nd   s  






53






r   NCLr#   2_PaddingSizeMode | Size1 | Size2 | Sequence[Size2]r   c	                 C  sd  t  }	|	dur
d}
nd}
|dvrtd| d|dk}|r dnd	}|r&d
nd}t| jdkr7td| j | j| }|jd }|dkrItd|| dkrht sZ|dkrh|dkrhtd| d| j d| || dkrt sy|dkr|dkrtd| d|j d| t||d	\}}t|dkrddg|}nt|d	krdg|}ntd| d	gt|d	d}d	gt|d	d}ddlm} d}t	j
 dkr|jt	jkrd}|| j}|dur|jt	jkrd}|| j}||}t|dgd}d}t r||kr|d	kr|| dkrd}d}
|rdnd}t| |gd} t rW|dkr:t| |||||||}nt| |||||||dddd}|durVt|||d}nI| g|gd }|||||
d||d!}t| d"g d#d t|fi t }|jd$d%}||}d&|gi}|j||||d' |durt|||d}t||gd}|r|t	j}|S )(a  
    The convolution1D layer calculates the output based on the input, filter
    and strides, paddings, dilations, groups parameters. Input and
    Output are in NCL format, where N is batch size, C is the number of
    channels, L is the length of the feature.
    Filter is in MCK format, where M is the number of output image channels,
    C is the number of input image channels, K is the size of the kernel.
    If the groups is greater than 1, C will equal the number of input image
    channels divided by the groups. If bias attribution and activation type
    are provided, bias is added to the output of the convolution, and the
    corresponding activation function is applied to the final result.

    For each input :math:`X`, the equation is:

    .. math::

        Out = \sigma (W \ast X + b)

    Where:

    * :math:`X`: Input value, a tensor with NCL format.
    * :math:`W`: Kernel value, a tensor with MCK format.
    * :math:`\\ast`: Convolution operation.
    * :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
    * :math:`\\sigma`: Activation function.
    * :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.

    Example:

        - Input:

          Input shape: :math:`(N, C_{in}, L_{in})`

          Filter shape: :math:`(C_{out}, C_{in}, L_f)`

        - Output:

          Output shape: :math:`(N, C_{out}, L_{out})`

        Where

        .. math::

            L_{out} = \frac{(L_{in} + 2 * padding - (dilation * (L_f - 1) + 1))}{stride} + 1

    Args:
        x (Tensor): The input is 3-D Tensor with shape [N, C, L], the data type
            of input is float16 or float32 or float64.
        weight (Tensor): The convolution kernel with shape [M, C/g, K], where M is
            the number of output channels, g is the number of groups, K is the kernel's size.
        bias (Tensor, optional): The bias with shape [M,]. Default: None.
        stride (int|list|tuple, optional): The stride size. If stride is a list/tuple, it must
            contain one integers, (stride_size). Default: 1.
        padding (int|str|tuple|list, optional): The padding size. Padding could be in one of the following forms.
            1. a string in ['valid', 'same'].
            2. an int, which means the feature map is zero paded by size of `padding` on both sides.
            3. a list[int] or tuple[int] whose length is 1, which means the feature map is zero paded by size of `padding[0]` on both sides.
            4. a list[int] or tuple[int] whose length is 2. It has the form  [pad_before, pad_after].
            5. a list or tuple of pairs of ints. It has the form [[pad_before, pad_after], [pad_before, pad_after], ...]. Note that, the batch dimension and channel dimension are also included. Each pair of integers correspond to the amount of padding for a dimension of the input. Padding in batch dimension and channel dimension should be [0, 0] or (0, 0).
            The default value is 0.
        dilation (int|list|tuple, optional): The dilation size. If dilation is a list/tuple, it must
            contain one integer, (dilation_size). Default: 1.
        groups (int, optional): The groups number of the conv1d function. According to grouped
            convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
            the first half of the filters is only connected to the first half
            of the input channels, while the second half of the filters is only
            connected to the second half of the input channels. Default: 1.
        data_format (str, optional): Specify the data format of the input, and the data format of the output
            will be consistent with that of the input. An optional string from: `"NCL"`, `"NLC"`.
            The default is `"NCL"`. When it is `"NCL"`, the data is stored in the order of:
            `[batch_size, input_channels, feature_length]`.
        name(str, optional): For detailed information, please refer
           to :ref:`api_guide_Name`. Usually name is no need to set and
           None by default.

    Returns:
        A tensor representing the conv1d, whose data type is the
        same with input.

    Examples:
        .. code-block:: python

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

            >>> x = paddle.to_tensor([[[4, 8, 1, 9],
            ...                        [7, 2, 0, 9],
            ...                        [6, 9, 2, 6]]], dtype="float32")
            >>> w = paddle.to_tensor([[[9, 3, 4],
            ...                        [0, 0, 7],
            ...                        [2, 5, 6]],
            ...                       [[0, 3, 4],
            ...                        [2, 9, 7],
            ...                        [5, 6, 8]]], dtype="float32")

            >>> y = F.conv1d(x, w)
            >>> print(y)
            Tensor(shape=[1, 2, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
            [[[133., 238.],
            [160., 211.]]])
    NTFr   NLCzHAttr(data_format) should be 'NCL' or 'NLC'. Received Attr(data_format): .r   r1   r(   NHWCrF   r   >Input x should be 3D tensor, but received x with the shape of r   z'The groups of conv1d should not be zeroSThe channel of input must be divisible by groups,received: the channel of input is , the shape of input is , the groups is UThe number of filters must be divisible by groups,received: the number of filters is , the shape of weight is r5   zBThe size of padding's dimension should be 1 or 2. But got padding=rL   rO   )assigncpura   rG   r[   rc   re   r-   rg   rh   ri   rH   rj   rk   rl   )r   r@   rA   rw   r   rE   r   Ztensor.creationr   paddledeviceZ
get_devicer   rg   Zastyper   r   r
   r   rG   r[   r   r   r   r|   r}   r~   r   r   )rH   rI   rJ   rL   r2   rO   rP   rQ   rV   cudnn_versionrT   r3   rR   conv2d_data_formatnum_channelsnum_filtersrD   Zpaddle_assignZfloat16_convertl_typesqueeze_axisr   rn   rp   r   r   ro   r.   r.   r/   conv1d&  s
  p










r   r$   2_PaddingSizeMode | Size2 | Size4 | Sequence[Size2]r    c	                 C  s  |dvrt d| d|dk}	|	rdnd}
t| jdkr%t d| j | j|
 }|jd	 }|d	kr7t d
|| d	krVt sH|dkrV|dkrVt d| d| j d| || d	krut sg|dkru|dkrut d| d|j d| t }t r|durdnd}t||	d\}}t|dd}t|dd}d}||kr|dkr|| d	krd}t rd}nd}nt r1t	
| |||||||}|dur/|
d	k r|
t| j n|
}
t|jt| jk rt	|dd t|
D |j dd tt| j|
 d D  }t d r)dt v r)t  t	|d}|| W d   n	1 s$w   Y  t	||S |S t r>tdd r>d}t| |||||||||
|||S )aJ  

    The convolution2D layer calculates the output based on the input, filter
    and strides, paddings, dilations, groups parameters. Input and
    Output are in NCHW or NHWC format, where N is batch size, C is the number of
    channels, H is the height of the feature, and W is the width of the feature.
    Filter is in MCHW format, where M is the number of output image channels,
    C is the number of input image channels, H is the height of the filter,
    and W is the width of the filter. If the groups is greater than 1,
    C will equal the number of input image channels divided by the groups.
    Please refer to UFLDL's `convolution
    <http://ufldl.stanford.edu/tutorial/supervised/FeatureExtractionUsingConvolution/>`_
    for more details.
    If bias attribution and activation type are provided, bias is added to the
    output of the convolution, and the corresponding activation function is
    applied to the final result.

    For each input :math:`X`, the equation is:

    ..  math::

        Out = \sigma (W \ast X + b)

    Where:

    * :math:`X`: Input value, a tensor with NCHW or NHWC format.
    * :math:`W`: Filter value, a tensor with MCHW format.
    * :math:`\\ast`: Convolution operation.
    * :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
    * :math:`\\sigma`: Activation function.
    * :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.

    Example:

        - Input:

          Input shape: :math:`(N, C_{in}, H_{in}, W_{in})`

          Filter shape: :math:`(C_{out}, C_{in}, H_f, W_f)`

        - Output:

          Output shape: :math:`(N, C_{out}, H_{out}, W_{out})`

        Where

        ..  math::

            H_{out}&= \frac{(H_{in} + 2 * paddings[0] - (dilations[0] * (H_f - 1) + 1))}{strides[0]} + 1 \\\\
            W_{out}&= \frac{(W_{in} + 2 * paddings[1] - (dilations[1] * (W_f - 1) + 1))}{strides[1]} + 1

    Args:
        x (Tensor): The input is 4-D Tensor with shape [N, C, H, W], the data type
            of input is float16 or float32 or float64.
        weight (Tensor): The convolution kernel with shape [M, C/g, kH, kW], where M is
            the number of output channels, g is the number of groups, kH is the filter's
            height, kW is the filter's width.
        bias (Tensor, optional): The bias with shape [M,].
        stride (int|list|tuple, optional): The stride size. It means the stride in convolution.
            If stride is a list/tuple, it must contain two integers, (stride_height, stride_width).
            Otherwise, stride_height = stride_width = stride. Default: stride = 1.
        padding (string|int|list|tuple, optional): The padding size. It means the number of zero-paddings
            on both sides for each dimension.If `padding` is a string, either 'VALID' or
            'SAME' which is the padding algorithm. If padding size is a tuple or list,
            it could be in three forms: `[pad_height, pad_width]` or
            `[pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`, and when
            `data_format` is `"NCHW"`, `padding` can be in the form `[[0,0], [0,0],
            [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
            when `data_format` is `"NHWC"`, `padding` can be in the form
            `[[0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
            Default: padding = 0.
        dilation (int|list|tuple, optional): The dilation size. It means the spacing between the kernel
            points. If dilation is a list/tuple, it must contain two integers, (dilation_height,
            dilation_width). Otherwise, dilation_height = dilation_width = dilation.
            Default: dilation = 1.
        groups (int, optional): The groups number of the Conv2D Layer. According to grouped
            convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
            the first half of the filters is only connected to the first half
            of the input channels, while the second half of the filters is only
            connected to the second half of the input channels. Default: groups=1.
        data_format (str, optional): Specify the data format of the input, and the data format of the output
            will be consistent with that of the input. An optional string from: `"NCHW"`, `"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, optional): For detailed information, please refer
           to :ref:`api_guide_Name`. Usually name is no need to set and
           None by default.

    Returns:
        A Tensor representing the conv2d result, whose data type is the same with input.

    Examples:
        .. code-block:: python

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

            >>> x_var = paddle.randn((2, 3, 8, 8), dtype='float32')
            >>> w_var = paddle.randn((6, 3, 3, 3), dtype='float32')

            >>> y_var = F.conv2d(x_var, w_var)

            >>> print(y_var.shape)
            [2, 6, 6, 6]
    rF   r   zJAttr(data_format) should be 'NCHW' or 'NHWC'. Received Attr(data_format): r   r   r1   r(      >Input x should be 4D tensor, but received x with the shape of r   z+The groups of conv2d should be not be zero.r   r   r   r   r   NTFr5   rL   rO   rG   r[   c                 S     g | ]}d qS r(   r.   r6   ir.   r.   r/   r8         zconv2d.<locals>.<listcomp>c                 S  r   r   r.   r   r.   r.   r/   r8     r   rY   rZ   r   ZFLAGS_conv2d_disable_cudnn)r@   rA   rw   r   r   r   rE   r   r   r   rG   r   ranger	   r   r   rx   ry   rz   r   r   )rH   rI   rJ   rL   r2   rO   rP   rQ   rV   r3   rR   r   r   r   rT   rD   r   r   r   r.   r.   r/   rG   $  s   u




output_paddingoutput_sizeSize1 | Nonec                 C  sV  t  }|dur
d}nd}|	dvrtd|	 d|	dk}|r dnd	}t| jd
kr1td| j | j| }|dkr>td|| dkr]t sO|dkr]|dkr]td| d| j d| t||d	\}}t|dkrtg |dd}nt|d	krg |d}ntd| g t|d	dd	}g t|d	dd	}|du rg }n|dkrtdt|tt	t
frg t|d	dd	}ntd|dkrg }n
g t|d	dd}t|dkr|d |d krtd|d  d|d  t|jd
krtd|j d}|jd	 }||kr|d	kr|d	kr|sd}d}|r dnd}|r'dnd }t| |gd!} t|dgd!}t rXtt|| |||||||||
}|durWt|||d!}nJ| g|gd"}|||||||||d#	}t| d$g d%d t|fi t }|jd&d'}||}d(|gi}|j||||d) |durt|||d!}t||gd!}|S )*a^  
    The 1-D convolution transpose layer calculates the output based on the input,
    filter, and dilation, stride, padding. Input(Input) and output(Output)
    are in 'NCL' format or 'NLC' where N is batch size, C is the number of channels,
    L is the length of the feature. The details of convolution transpose
    layer, please refer to the following explanation and references
    `therein <https://arxiv.org/pdf/1603.07285.pdf>`_.
    If bias attribution and activation type are provided, bias is added to
    the output of the convolution, and the corresponding activation function
    is applied to the final result.

    For each input :math:`X`, the equation is:

    .. math::

        Out = \sigma (W \ast X + b)

    Where:

    * :math:`X`: Input value, a 3-D Tensor with 'NCL' format or 'NLC' format.
    * :math:`W`: Filter value, a 3-D Tensor with 'MCK' format.
    * :math:`\\ast`: Convolution operation.
    * :math:`b`: Bias value, a 2-D Tensor with shape [M, 1].
    * :math:`\\sigma`: Activation function.
    * :math:`Out`: Output value, a 3-D Tensor with data format 'NCL' or 'NLC', the shape of :math:`Out` and :math:`X` may be different.

    Example:

        - Input:

          Input shape: :math:`(N, C_{in}, L_{in})`

          Filter shape: :math:`(C_{in}, C_{out}, L_f)`

        - Output:

          Output shape: :math:`(N, C_{out}, L_{out})`

        Where

        .. math::

           L^\prime_{out} &= (L_{in} - 1) * stride - 2 * padding + dilation * (L_f - 1) + 1 \\
           L_{out} &\in [ L^\prime_{out}, L^\prime_{out} + stride ]

    Note:
          The conv1d_transpose can be seen as the backward of the conv1d. For conv1d,
          when stride > 1, conv1d maps multiple input shape to the same output shape,
          so for conv1d_transpose, when stride > 1, input shape maps multiple output shape.
          If output_size is None, :math:`L_{out} = L^\prime_{out}`;
          else, the :math:`L_{out}` of the output size must between :math:`L^\prime_{out}`
          and :math:`L^\prime_{out} + stride`.

    Args:
        x(Tensor): 3-D tensor with [N, C, L] or [N, L, C] format,
                         its data type is float32 or float64.
        weight(Tensor): The convolution kernel, a Tensor with shape [C, M/g, K],
            where M is the number of output channels(filters), g is the number of groups,
            K is the size of the kernel.
        bias(Tensor, optional): The bias, a Tensor with shape [M, ].
        stride(int|tuple|list, optional): The stride size. It means the stride in transposed convolution.
            If stride is a list/tuple, it must contain one integer, `(stride_size)`.
            Default: stride = 1.
        padding(int|list|str|tuple, optional): The padding size. The padding argument effectively adds
             `dilation * (kernel - 1)` amount of zero-padding on both sides of input. If `padding` is a
             string, either 'VALID' or 'SAME' supported, which is the padding algorithm.
             If `padding` is a tuple or list, it could be in two forms:
             `[pad]` or `[pad_left, pad_right]`. Default: padding = 0.
        output_padding(int|list|tuple, optional): The count of zeros to be added to tail of each dimension.
             If it is a list/tuple, it must contain one integer. Default: 0.
        groups(int, optional): The groups number of the conv1d transpose function. Inspired by
            grouped convolution in Alex Krizhevsky's Deep CNN paper, in which
            when group=2, the first half of the filters is only connected to the
            first half of the input channels, while the second half of the
            filters is only connected to the second half of the input channels.
            Default: groups = 1.
        dilation(int|tuple|list, optional): The dilation size. It means the spacing between the kernel points.
            If dilation is a list/tuple, it must contain one integer, `(dilation_size)`.
            Default: dilation = 1.
        output_size(int|tuple|list, optional): The output image size. If output size is a
            tuple/list, it must contain one integer, `(feature_length)`. None if use
            filter_size(shape of weight), padding, and stride to calculate output_size.
        data_format (str, optional): Specify the data format of the input, and the data format of the output
            will be consistent with that of the input. An optional string from: `"NCL"`, `"NLC"`.
            The default is `"NCL"`. When it is `"NCL"`, the data is stored in the order of:
            `[batch_size, input_channels, input_length]`.
        name(str, optional): For detailed information, please refer
           to :ref:`api_guide_Name`. Usually name is no need to set and
           None by default.

    Returns:
        A tensor representing the result of 1-D transpose convolution, whose
        data type is the same with input. And its shape is (num_batches, channels, length)
        when data_format is `"NCL"` and (num_batches, length, channels) when data_format is
        `"NLC"`.

    Examples:
        .. code-block:: python

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

            >>> # shape: (1, 2, 4)
            >>> x = paddle.to_tensor([[[4, 0, 9, 7],
            >>>                       [8, 0, 9, 2,]]], dtype="float32")
            >>> # shape: (2, 1, 2)
            >>> w = paddle.to_tensor([[[7, 0]],
            >>>                       [[4, 2]]], dtype="float32")

            >>> y = F.conv1d_transpose(x, w)
            >>> print(y)
            Tensor(shape=[1, 1, 5], dtype=float32, place=Place(cpu), stop_gradient=True,
            [[[60., 16., 99., 75., 4. ]]])
    NTFr   @Attr(data_format) of conv2d_transpose got wrong value: received z(, but only 'NCL' or 'NLC' are supported.r   r1   r(   r   r   r   z2The groups of conv1d_transpose should not be zero.Sthe channel of input must be divisible by groups,received: the channel of input is r   r   r5   z?The size of padding's dimension should 1 or 2. But got padding=rL   rO   <output_padding option is mutually exclusive with output_sizer   1output_size should be int, or list, tuple of intsr   zTThe size of output_padding should not be greater than stride.But got output_padding=z and stride=zHInput weight should be 3D tensor, but received weight with the shape of conv2d_transposedepthwise_conv2d_transposer   r   rF   ra   rc   	r   r   r]   r^   rD   r_   rP   rT   rQ   r-   r   rH   rj   rk   rl   )r   r@   rA   rw   r   rE   r   r*   r+   r,   rB   r   r
   r{   r   r   r   r   r|   r}   r~   r   r   )rH   rI   rJ   rL   r2   r   rP   rO   r   rQ   rV   r   rT   r3   rR   r   rD   rS   r   r   r   r   rn   rp   r   r   ro   r.   r.   r/   conv1d_transpose  s   











r   Size2 | Nonec                 C  s  |	dvrt d|	 d|	dk}|rdnd}t| jdkr%t d| j t|jdkr4t d	|j | j| }|d
krAt d|| d
kr`t sR|dkr`|dkr`t d| d| j d| t }t rl|durldnd}t||d\}}t|dd}t|dd}|du rg }nf|d
krt dt|t	t
frt|rt|}nNt|dd}nGt|trt|dd}n;t|ttjfrt|jdddgd t|jdkr|jd
 dks|jd
 dkr|jd
 dkr||g}nt dt d|d
krg }nt|dd}d}|jd }||kr|dkr|dkrd}d}t r@|dkr"tjntj}|| |||||||||	
}|dur>t|||dS |S | g|gd}|||||||||	d 	}t| d!g d"d t|fi t }|| j}d#|gi}|j||||d$ |dur|| j}t	|j}t	|j}|dkst|t|kr|jd%|g|gd&d'|gid(did$ |S t|t|ksJ d)t|t| | }t|dg| | dg|  }|jd%|g|gd&d'|gid(did$ |S |}|S )*a  

    The convolution2D transpose layer calculates the output based on the input,
    filter, and dilations, strides, paddings. Input(Input) and output(Output)
    are in NCHW or NHWC format. Where N is batch size, C is the number of channels,
    H is the height of the feature, and W is the width of the feature.
    Parameters(dilations, strides, paddings) are two elements. These two elements
    represent height and width, respectively. The details of convolution transpose
    layer, please refer to the following explanation and references
    `therein <https://arxiv.org/pdf/1603.07285.pdf>`_.
    If bias attribution and activation type are provided, bias is added to
    the output of the convolution, and the corresponding activation function
    is applied to the final result.
    See more detail in :ref:`api_paddle_nn_Conv2DTranspose` .

    For each input :math:`X`, the equation is:

    ..  math::

        Out = \sigma (W \ast X + b)

    Where:

    * :math:`X`: Input value, a 4-D Tensor with NCHW or NHWC format.
    * :math:`W`: Filter value, a 4-D Tensor with MCHW format.
    * :math:`\\ast`: Convolution operation.
    * :math:`b`: Bias value, a 2-D Tensor with shape [M, 1].
    * :math:`\\sigma`: Activation function.
    * :math:`Out`: Output value, a 4-D Tensor with data format 'NCHW' or 'NHWC', the shape of :math:`Out` and :math:`X` may be different.

    Example:

        - Input:

          Input shape: :math:`(N, C_{in}, H_{in}, W_{in})`

          Filter shape: :math:`(C_{in}, C_{out}, H_f, W_f)`

        - Output:

          Output shape: :math:`(N, C_{out}, H_{out}, W_{out})`

        Where

        ..  math::

           H^\prime_{out} &= (H_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (H_f - 1) + 1 \\
           W^\prime_{out} &= (W_{in} - 1) * strides[1] - 2 * paddings[1] + dilations[1] * (W_f - 1) + 1 \\
           H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[0] ] \\
           W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[1] ]

    Note:
          The conv2d_transpose can be seen as the backward of the conv2d. For conv2d,
          when stride > 1, conv2d maps multiple input shape to the same output shape,
          so for conv2d_transpose, when stride > 1, input shape maps multiple output shape.
          If output_size is None, :math:`H_{out} = H^\prime_{out}, W_{out} = W^\prime_{out}`;
          else, the :math:`H_{out}` of the output size must between :math:`H^\prime_{out}`
          and :math:`H^\prime_{out} + strides[0]`, and the :math:`W_{out}` of the output size must
          between :math:`W^\prime_{out}` and :math:`W^\prime_{out} + strides[1]`.

    Args:
        x(Tensor): 4-D Tensor with [N, C, H, W] or [N, H, W, C] format,
            whose data type is float32 or float64.
        weight(Tensor): The convolution kernel, a Tensor with shape [C, M/g, kH, kW],
            where M is the number of output channels(filters), g is the number of groups,
            kH is the height of the kernel, and kW is the width of the kernel.
        bias(Tensor, optional): The bias, a Tensor with shape [M, ].
        stride(int|list|tuple, optional): The stride size. It means the stride in transposed convolution.
            If stride is a list/tuple, it must contain two integers, (stride_height, stride_width).
            Otherwise, stride_height = stride_width = stride. Default: stride = 1.
        padding(str|int|list|tuple, optional): The padding size. It means the number of zero-paddings
            on both sides for each dimension. If `padding` is a string, either 'VALID' or
            'SAME' which is the padding algorithm. If padding size is a tuple or list,
            it could be in three forms: `[pad_height, pad_width]` or
            `[pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`,
            and when `data_format` is `"NCHW"`, `padding` can be in the form
            `[[0,0], [0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
            when `data_format` is `"NHWC"`, `padding` can be in the form
            `[[0,0], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
            Default: padding = 0.
        output_padding(int|list|tuple, optional): Additional size added to one side
            of each dimension in the output shape. Default: 0.
        groups(int, optional): The groups number of the Conv2D transpose layer. Inspired by
            grouped convolution in Alex Krizhevsky's Deep CNN paper, in which
            when group=2, the first half of the filters is only connected to the
            first half of the input channels, while the second half of the
            filters is only connected to the second half of the input channels.
            Default: groups = 1.
        dilation(int|list|tuple, optional): The dilation size. It means the spacing between the kernel points.
            If dilation is a list/tuple, it must contain two integers, (dilation_height, dilation_width).
            Otherwise, dilation_height = dilation_width = dilation. Default: dilation = 1.
        output_size(int|tuple|list, optional): The output image size. If output size is a
            tuple/list, it must contain two integers, (image_height, image_width). None if use
            filter_size(shape of weight), padding, and stride to calculate output_size.
        data_format (str, optional): Specify the data format of the input, and the data format of the output
            will be consistent with that of the input. An optional string from: `"NCHW"`, `"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, optional): For detailed information, please refer
           to :ref:`api_guide_Name`. Usually name is no need to set and
           None by default.

    Returns:
        A Tensor representing the conv2d_transpose, whose
        data type is the same with input and shape is (num_batches, channels, out_h,
        out_w) or (num_batches, out_h, out_w, channels). The tensor variable storing
        transposed convolution result.

    Examples:
        .. code-block:: python

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

            >>> x_var = paddle.randn((2, 3, 8, 8), dtype='float32')
            >>> w_var = paddle.randn((3, 6, 3, 3), dtype='float32')

            >>> y_var = F.conv2d_transpose(x_var, w_var)

            >>> print(y_var.shape)
            [2, 6, 10, 10]
    r   r   z*, but only 'NCHW' or 'NHWC' are supported.r   r1   r(   r   r   zHInput weight should be 4D tensor, but received weight with the shape of r   z2The groups of conv2d_transpose should not be zero.r   r   r   NTFr5   rL   rO   r   r   Zint32Zint64r   z-output_size must contain one or two integers.zDoutput_size should be int or Tensor or list, tuple of ints or Tensorr   r   ra   rc   r   rH   rf   rk   rl   rq   rr   ru   rb   rv   )r@   rA   rw   r   r   r   rE   r   r*   r+   r,   r   r   rB   r   r   Valuer   r   r
   r   r   r   r   r   r   r|   r~   r   r   )rH   rI   rJ   rL   r2   r   rO   rP   r   rQ   rV   r3   rR   r   r   rT   rD   rS   r   opr   rn   rp   r   ro   r   r   r   r.   r.   r/   r      s0   	











	r   NCDHWr%   2_PaddingSizeMode | Size3 | Size6 | Sequence[Size2]r!   c	                 C  sF  |dvrt d| d|dk}	|	rdnd}
t| jdkr%t d| j | j|
 }|jd	 }|d	kr7t d
|| d	krSt sH|dkrS|dkrSt d| d| d|| d	krot sd|dkro|dkrot d| d| dt }t r{|dur{dnd}t||	d\}}t|dd}t|dd}d}t| |||||||||
|||S )aC  

    The convolution3D layer calculates the output based on the input, filter
    and strides, paddings, dilations, groups parameters. Input(Input) and
    Output(Output) are in NCDHW or NDHWC format. Where N is batch size C is the number of
    channels, D is the depth of the feature, H is the height of the feature,
    and W is the width of the feature. Convolution3D is similar with Convolution2D
    but adds one dimension(depth). If bias attribution and activation type are
    provided, bias is added to the output of the convolution, and the
    corresponding activation function is applied to the final result.

    For each input :math:`X`, the equation is:

    ..  math::

        Out = \sigma (W \ast X + b)

    In the above equation:

    * :math:`X`: Input value, a tensor with NCDHW or NDHWC format.
    * :math:`W`: Filter value, a tensor with MCDHW format.
    * :math:`\\ast`: Convolution operation.
    * :math:`b`: Bias value, a 2-D tensor with shape [M, 1].
    * :math:`\\sigma`: Activation function.
    * :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.

    Example:

        - Input:

          Input shape: :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})`

          Filter shape: :math:`(C_{out}, C_{in}, D_f, H_f, W_f)`

        - Output:
          Output shape: :math:`(N, C_{out}, D_{out}, H_{out}, W_{out})`

        Where

        ..  math::

            D_{out}&= \frac{(D_{in} + 2 * paddings[0] - (dilations[0] * (D_f - 1) + 1))}{strides[0]} + 1 \\
            H_{out}&= \frac{(H_{in} + 2 * paddings[1] - (dilations[1] * (H_f - 1) + 1))}{strides[1]} + 1 \\
            W_{out}&= \frac{(W_{in} + 2 * paddings[2] - (dilations[2] * (W_f - 1) + 1))}{strides[2]} + 1

    Args:
        x (Tensor): The input is 5-D Tensor with shape [N, C, D, H, W], the data
            type of input is float16 or float32 or float64.
        weight (Tensor): The convolution kernel, a Tensor with shape [M, C/g, kD, kH, kW],
            where M is the number of filters(output channels), g is the number of groups,
            kD, kH, kW are the filter's depth, height and width respectively.
        bias (Tensor, optional): The bias, a Tensor of shape [M, ].
        stride (int|list|tuple, optional): The stride size. It means the stride in convolution. If stride is a
            list/tuple, it must contain three integers, (stride_depth, stride_height, stride_width).
            Otherwise, stride_depth = stride_height = stride_width = stride. Default: stride = 1.
        padding (string|int|list|tuple, optional): The padding size. It means the number of zero-paddings
            on both sides for each dimension. If `padding` is a string, either 'VALID' or
            'SAME' which is the padding algorithm. If padding size is a tuple or list,
            it could be in three forms: `[pad_depth, pad_height, pad_width]` or
            `[pad_depth_front, pad_depth_back, pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`,
            and when `data_format` is `"NCDHW"`, `padding` can be in the form
            `[[0,0], [0,0], [pad_depth_front, pad_depth_back], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
            when `data_format` is `"NDHWC"`, `padding` can be in the form
            `[[0,0], [pad_depth_front, pad_depth_back], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
            Default: padding = 0.
        dilation (int|list|tuple, optional): The dilation size. It means the spacing between the kernel points.
            If dilation is a list/tuple, it must contain three integers, (dilation_depth, dilation_height,
            dilation_width). Otherwise, dilation_depth = dilation_height = dilation_width = dilation.
            Default: dilation = 1.
        groups (int, optional): The groups number of the Conv3D Layer. According to grouped
            convolution in Alex Krizhevsky's Deep CNN paper: when group=2,
            the first half of the filters is only connected to the first half
            of the input channels, while the second half of the filters is only
            connected to the second half of the input channels. Default: groups=1
        data_format (str, optional): Specify the data format of the input, and the data format of the output
            will be consistent with that of the input. An optional string from: `"NCDHW"`, `"NDHWC"`.
            The default is `"NCDHW"`. When it is `"NCDHW"`, the data is stored in the order of:
            `[batch_size, input_channels, input_depth, input_height, input_width]`.
        name(str|None, optional): For detailed information, please refer
           to :ref:`api_guide_Name`. Usually name is no need to set and
           None by default.

    Returns:
        A Tensor representing the conv3d, whose data type is
        the same with input. If act is None, the tensor storing the
        convolution result, and if act is not None, the tensor storing
        convolution and non-linearity activation result.

    Examples:
        .. code-block:: python

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

            >>> x_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32')
            >>> w_var = paddle.randn((6, 3, 3, 3, 3), dtype='float32')

            >>> y_var = F.conv3d(x_var, w_var)

            >>> print(y_var.shape)
            [2, 6, 6, 6, 6]
    r   NDHWCLAttr(data_format) should be 'NCDHW' or 'NDHWC'. Received Attr(data_format): r   r   r1   r(      >Input x should be 5D tensor, but received x with the shape of r   z%The groups of conv3d should not be 0.]The number of input channels must be divisible by Attr(groups). Received: number of channels(
), groups().zUThe number of filters must be divisible by Attr(groups). Received: number of filters(NTFr   rL   rO   r\   )	r@   rA   rw   r   r   r   rE   r   r   )rH   rI   rJ   rL   r2   rO   rP   rQ   rV   r3   rR   r   r   r   rT   rD   rS   r.   r.   r/   r\   N  s   r


r\   Size3 | Nonec                 C  s>  |	dvrt d|	 d|	dk}|rdnd}t| jdkr%t d| j t|jdkr4t d	|j | j| }|d
krAt d|| d
kr]t sR|dkr]|dkr]t d| d| dt||d\}}t|dd}t|dd}|du rxg }n|d
krt dt|ttt	frt|dd}nt d|d
krg }nt|dd}t
 }t r|durdnd}d}|rdnd}t rt| |||||||||
}|durt|||dS |S | g|gd}|||||||||d	}t|fi t }t| dg d d! || j}d"|gi}|j||||d# |durt|||d}|S |}|S )$a  
    The convolution3d transpose layer calculates the output based on the input,
    filter, and dilations, strides, paddings. Input(Input) and output(Output)
    are in NCDHW or NDHWC format. Where N is batch size, C is the number of channels,
    D is the depth of the feature, H is the height of the feature, and W
    is the width of the feature. Parameters(dilations, strides, paddings) are
    two elements. These two elements represent height and width, respectively.
    The details of convolution transpose layer, please refer to the following
    explanation and references `therein <https://arxiv.org/pdf/1603.07285.pdf>`_.
    If bias attribution and activation type are provided, bias is added to
    the output of the convolution, and the corresponding activation function
    is applied to the final result.
    See more detail in :ref:`api_paddle_nn_Conv3DTranspose` .

    For each input :math:`X`, the equation is:

    ..  math::

        Out = \sigma (W \ast X + b)

    In the above equation:

    * :math:`X`: Input value, a Tensor with NCDHW or NDHWC format.
    * :math:`W`: Filter value, a Tensor with NCDHW format.
    * :math:`\ast`: Convolution operation.
    * :math:`b`: Bias value, a 2-D Tensor with shape [M, 1].
    * :math:`\sigma`: Activation function.
    * :math:`Out`: Output value, the shape of :math:`Out` and :math:`X` may be different.

    Example:

        - Input:

          Input shape: :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})`

          Filter shape: :math:`(C_{in}, C_{out}, D_f, H_f, W_f)`

        - Output:

          Output shape: :math:`(N, C_{out}, D_{out}, H_{out}, W_{out})`

        Where

        ..  math::

           D^\prime_{out} &= (D_{in} - 1) * strides[0] - 2 * paddings[0] + dilations[0] * (D_f - 1) + 1 \\
           H^\prime_{out} &= (H_{in} - 1) * strides[1] - 2 * paddings[1] + dilations[1] * (H_f - 1) + 1 \\
           W^\prime_{out} &= (W_{in} - 1) * strides[2] - 2 * paddings[2] + dilations[2] * (W_f - 1) + 1 \\
           D_{out} &\in [ D^\prime_{out}, D^\prime_{out} + strides[0] ] \\
           H_{out} &\in [ H^\prime_{out}, H^\prime_{out} + strides[1] ] \\
           W_{out} &\in [ W^\prime_{out}, W^\prime_{out} + strides[2] ]

    Note:
        The conv3d_transpose can be seen as the backward of the conv3d. For conv3d,
        when stride > 1, conv3d maps multiple input shape to the same output shape,
        so for conv3d_transpose, when stride > 1, input shape maps multiple output shape.
        If output_size is None, :math:`H_{out} = H^\prime_{out}, W_{out} = W^\prime_{out}`;
        else, the :math:`D_{out}` of the output size must between :math:`D^\prime_{out}` and
        :math:`D^\prime_{out} + strides[0]`, the :math:`H_{out}` of the output size must
        between :math:`H^\prime_{out}` and :math:`H^\prime_{out} + strides[1]`, and the
        :math:`W_{out}` of the output size must between :math:`W^\prime_{out}` and
        :math:`W^\prime_{out} + strides[2]`.

    Args:
        x (Tensor): The input is 5-D Tensor with shape [N, C, D, H, W] or [N, D, H, W, C], the data type
            of input is float32 or float64.
        weight (Tensor): The convolution kernel, a Tensor with shape [C, M/g, kD, kH, kW],
            where M is the number of filters (output channels), g is the number of groups,
            kD, kH, kW are the filter's depth, height and width respectively.
        bias (Tensor, optional): The bias, a Tensor of shape [M, ]. Default: None.
        stride (int|list|tuple, optional): The stride size. It means the stride in transposed convolution.
            If stride is a list/tuple, it must contain three integers, (stride_depth, stride_height,
            stride_width). Otherwise, stride_depth = stride_height = stride_width = stride.
            Default: 1.
        padding (str|int|list|tuple, optional): The padding size. It means the number of zero-paddings
            on both sides for each dimension. If `padding` is a string, either 'VALID' or
            'SAME' which is the padding algorithm. If padding size is a tuple or list,
            it could be in three forms: `[pad_depth, pad_height, pad_width]` or
            `[pad_depth_front, pad_depth_back, pad_height_top, pad_height_bottom, pad_width_left, pad_width_right]`,
            and when `data_format` is `"NCDHW"`, `padding` can be in the form
            `[[0,0], [0,0], [pad_depth_front, pad_depth_back], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right]]`.
            when `data_format` is `"NDHWC"`, `padding` can be in the form
            `[[0,0], [pad_depth_front, pad_depth_back], [pad_height_top, pad_height_bottom], [pad_width_left, pad_width_right], [0,0]]`.
            Default: 0.
        output_padding (int|list|tuple, optional): Additional size added to one side
            of each dimension in the output shape. Default: 0.
        groups (int, optional): The groups number of the Conv3D transpose layer. Inspired by
            grouped convolution in `Alex Krizhevsky's Deep CNN paper <https://papers.nips.cc/paper/2012/file/c399862d3b9d6b76c8436e924a68c45b-Paper.pdf>`_, in which
            when groups = 2, the first half of the filters is only connected to the
            first half of the input channels, while the second half of the
            filters is only connected to the second half of the input channels.
            Default: 1.
        dilation (int|list|tuple, optional): The dilation size. It means the spacing between the kernel points.
            If dilation is a list/tuple, it must contain three integers, (dilation_depth, dilation_height,
            dilation_width). Otherwise, dilation_depth = dilation_height = dilation_width = dilation.
            Default: 1.
        output_size (int|list|tuple, optional): The output image size. If output size is a
            list/tuple, it must contain three integers, (image_depth, image_height, image_width).
            None if use filter_size(shape of weight), padding, and stride to calculate output_size.
        data_format (str, optional): Specify the data format of the input, and the data format of the output
            will be consistent with that of the input. 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, optional): For detailed information, please refer
           to :ref:`api_guide_Name`. Usually name is no need to set.
           Default: None.

    Returns:
        A Tensor representing the conv3d_transpose, whose data
        type is the same with input and shape is (num_batches, channels, out_d, out_h,
        out_w) or (num_batches, out_d, out_h, out_w, channels). If act is None, the tensor
        variable storing the transposed convolution result, and if act is not None, the tensor
        variable storing transposed convolution and non-linearity activation result.

    Examples:
        .. code-block:: python

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

            >>> x_var = paddle.randn((2, 3, 8, 8, 8), dtype='float32')
            >>> w_var = paddle.randn((3, 6, 3, 3, 3), dtype='float32')

            >>> y_var = F.conv3d_transpose(x_var, w_var)

            >>> print(y_var.shape)
            [2, 6, 10, 10, 10]
    r   r   r   r   r1   r(   r   r   zHInput weight should be 5D tensor, but received weight with the shape of r   z2The groups of conv3d_transpose should not be zero.r   r   r   r   rL   rO   Nr   r   r   r   TFconv3d_transposer   rF   ra   rc   )	r   r   r^   rD   r]   r_   rP   rT   rQ   rH   r   r\   rk   rl   )r@   rA   rw   r   rE   r   r*   r+   r,   rB   r   r   r
   r   r   r   r   r|   r   r~   r   r   )rH   rI   rJ   rL   r2   r   rP   rO   r   rQ   rV   r3   rR   r   rD   r   rT   rS   Zdata_format_r   rn   rp   r   ro   r   r.   r.   r/   r     s    




r   )Nr(   r   Nr(   r(   rF   r(   rG   TN)rH   r   rI   r   rJ   rK   rL   rM   r2   rN   rO   rM   rP   rB   rQ   r"   rR   rB   rS   r>   rT   rU   rV   rW   rX   r   )Nr(   r   r(   r(   r   N)rH   r   rI   r   rJ   rK   rL   r#   r2   r   rO   r#   rP   rB   rQ   r   rV   rW   rX   r   )Nr(   r   r(   r(   rF   N)rH   r   rI   r   rJ   rK   rL   r$   r2   r   rO   r$   rP   rB   rQ   r    rV   rW   rX   r   )	Nr(   r   r   r(   r(   Nr   N)rH   r   rI   r   rJ   rK   rL   r#   r2   r   r   r#   rP   rB   rO   r#   r   r   rQ   r   rV   rW   rX   r   )	Nr(   r   r   r(   r(   NrF   N)rH   r   rI   r   rJ   rK   rL   r$   r2   r   r   r$   rO   r$   rP   rB   r   r   rQ   r    rV   rW   rX   r   )Nr(   r   r(   r(   r   N)rH   r   rI   r   rJ   rK   rL   r%   r2   r   rO   r%   rP   rB   rQ   r!   rV   rW   rX   r   )	Nr(   r   r   r(   r(   Nr   N)rH   r   rI   r   rJ   rK   rL   r%   r2   r   r   r%   rP   rB   rO   r%   r   r   rQ   r!   rV   rW   rX   r   )C
__future__r   typingr   r   r   r   r   r   r   Zpaddle.base.frameworkr	   r
   Zpaddle.devicer   r   r   Zpaddle.tensor.manipulationr   Zpaddle.tensor.mathr   Zbase.data_feederr   r   Zbase.layer_helperr   Zcommon_ops_importr   r   r   Z	frameworkr   Ztensor.manipulationr   r   utilsr   r   r   r   collections.abcr   r   Zpaddle._typingr   r    r!   r"   r#   r$   r%   r&   r'   commonr)   __all__r0   r4   r9   rE   r   r   rG   r   r   r\   r   r.   r.   r.   r/   <module>   s   ,7 $   t    3 3