U
    ‰dÌ  ã                   @   s$  d dl Z d dlmZmZmZmZmZmZmZm	Z	 d dl
mZ G dd„ de jjƒZG dd„ deƒZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS ) é    N)ÚConv1dÚConv2dÚConv3dÚReLUÚLinearÚBatchNorm1dÚBatchNorm2dÚBatchNorm3d)Útype_before_parametrizationsc                   @   s   e Zd ZdS )Ú_FusedModuleN)Ú__name__Ú
__module__Ú__qualname__© r   r   úD/tmp/pip-unpacked-wheel-ua33x9lu/torch/nn/intrinsic/modules/fused.pyr      s   r   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )Ú
ConvReLU1dzšThis is a sequential container which calls the Conv1d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sB   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tƒ  ||¡ d S ©Nz%Incorrect types for input modules{}{})r
   r   r   ÚAssertionErrorÚformatÚsuperÚ__init__©ÚselfÚconvÚrelu©Ú	__class__r   r   r      s     ÿÿzConvReLU1d.__init__©r   r   r   Ú__doc__r   Ú__classcell__r   r   r   r   r   	   s   r   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )Ú
ConvReLU2dzšThis is a sequential container which calls the Conv2d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sB   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tƒ  ||¡ d S r   )r
   r   r   r   r   r   r   r   r   r   r   r      s     ÿÿzConvReLU2d.__init__r   r   r   r   r   r       s   r    c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )Ú
ConvReLU3dzšThis is a sequential container which calls the Conv3d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sB   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tƒ  ||¡ d S r   )r
   r   r   r   r   r   r   r   r   r   r   r      s     ÿÿzConvReLU3d.__init__r   r   r   r   r   r!      s   r!   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )Ú
LinearReLUzšThis is a sequential container which calls the Linear and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sB   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tƒ  ||¡ d S r   )r
   r   r   r   r   r   r   )r   Úlinearr   r   r   r   r   '   s     ÿÿzLinearReLU.__init__r   r   r   r   r   r"   $   s   r"   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚConvBn1dz¤This is a sequential container which calls the Conv 1d and Batch Norm 1d modules.
    During quantization this will be replaced with the corresponding fused module.c                    sB   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tƒ  ||¡ d S r   )r
   r   r   r   r   r   r   ©r   r   Úbnr   r   r   r   0   s     ÿÿzConvBn1d.__init__r   r   r   r   r   r$   -   s   r$   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚConvBn2dz¤This is a sequential container which calls the Conv 2d and Batch Norm 2d modules.
    During quantization this will be replaced with the corresponding fused module.c                    sF   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tt| ƒ ||¡ d S r   )r
   r   r   r   r   r   r'   r   r%   r   r   r   r   9   s     ÿÿzConvBn2d.__init__r   r   r   r   r   r'   6   s   r'   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚConvBnReLU1dz«This is a sequential container which calls the Conv 1d, Batch Norm 1d, and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sV   t |ƒtkr$t |ƒtkr$t |ƒtksBtd t |ƒt |ƒt |ƒ¡ƒ‚tƒ  |||¡ d S ©Nz'Incorrect types for input modules{}{}{})r
   r   r   r   r   r   r   r   ©r   r   r&   r   r   r   r   r   B   s    
ÿ  ÿÿzConvBnReLU1d.__init__r   r   r   r   r   r(   ?   s   r(   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚConvBnReLU2dz«This is a sequential container which calls the Conv 2d, Batch Norm 2d, and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sV   t |ƒtkr$t |ƒtkr$t |ƒtksBtd t |ƒt |ƒt |ƒ¡ƒ‚tƒ  |||¡ d S r)   )r
   r   r   r   r   r   r   r   r*   r   r   r   r   K   s    
ÿ  ÿÿzConvBnReLU2d.__init__r   r   r   r   r   r+   H   s   r+   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚConvBn3dz¤This is a sequential container which calls the Conv 3d and Batch Norm 3d modules.
    During quantization this will be replaced with the corresponding fused module.c                    sB   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tƒ  ||¡ d S r   )r
   r   r	   r   r   r   r   r%   r   r   r   r   T   s     ÿÿzConvBn3d.__init__r   r   r   r   r   r,   Q   s   r,   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚConvBnReLU3dz«This is a sequential container which calls the Conv 3d, Batch Norm 3d, and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sV   t |ƒtkr$t |ƒtkr$t |ƒtksBtd t |ƒt |ƒt |ƒ¡ƒ‚tƒ  |||¡ d S r)   )r
   r   r	   r   r   r   r   r   r*   r   r   r   r   ]   s    
ÿ  ÿÿzConvBnReLU3d.__init__r   r   r   r   r   r-   Z   s   r-   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚBNReLU2dz This is a sequential container which calls the BatchNorm 2d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sB   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tƒ  ||¡ d S r   )r
   r   r   r   r   r   r   ©r   Z
batch_normr   r   r   r   r   g   s     ÿÿzBNReLU2d.__init__r   r   r   r   r   r.   d   s   r.   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚBNReLU3dz This is a sequential container which calls the BatchNorm 3d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sB   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tƒ  ||¡ d S r   )r
   r	   r   r   r   r   r   r/   r   r   r   r   p   s     ÿÿzBNReLU3d.__init__r   r   r   r   r   r0   m   s   r0   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )Ú
LinearBn1dz¡This is a sequential container which calls the Linear and BatchNorm1d modules.
    During quantization this will be replaced with the corresponding fused module.c                    sB   t |ƒtkrt |ƒtks0td t |ƒt |ƒ¡ƒ‚tƒ  ||¡ d S r   )r
   r   r   r   r   r   r   )r   r#   r&   r   r   r   r   z   s    ÿzLinearBn1d.__init__r   r   r   r   r   r1   w   s   r1   )ZtorchZtorch.nnr   r   r   r   r   r   r   r	   Ztorch.nn.utils.parametrizer
   ÚnnZ
Sequentialr   r   r    r!   r"   r$   r'   r(   r+   r,   r-   r.   r0   r1   r   r   r   r   Ú<module>   s    (									
	
