U
    KºcŸ  ã                   @   sB  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 dddddd	d
ddddddg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_parametrizationsÚ
ConvReLU1dÚ
ConvReLU2dÚ
ConvReLU3dÚ
LinearReLUÚConvBn1dÚConvBn2dÚConvBnReLU1dÚConvBnReLU2dÚConvBn3dÚConvBnReLU3dÚBNReLU2dÚBNReLU3dÚ
LinearBn1dc                   @   s   e Zd ZdS )Ú_FusedModuleN)Ú__name__Ú
__module__Ú__qualname__© r   r   úG/tmp/pip-unpacked-wheel-gikjz4vx/torch/ao/nn/intrinsic/modules/fused.pyr   	   s   r   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   zš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   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   zš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   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   zš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   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   zš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   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   z¤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"   3   s     ÿÿzConvBn1d.__init__r)   r   r   r'   r   r   0   s   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   z¤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"   <   s     ÿÿzConvBn2d.__init__r)   r   r   r'   r   r   9   s   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   z«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"   E   s    
ÿ  ÿÿzConvBnReLU1d.__init__r)   r   r   r'   r   r   B   s   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   z«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"   r0   r'   r   r   r"   N   s    
ÿ  ÿÿzConvBnReLU2d.__init__r)   r   r   r'   r   r   K   s   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   z¤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"   W   s     ÿÿzConvBn3d.__init__r)   r   r   r'   r   r   T   s   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   z«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"   r0   r'   r   r   r"   `   s    
ÿ  ÿÿzConvBnReLU3d.__init__r)   r   r   r'   r   r   ]   s   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   z 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"   j   s     ÿÿzBNReLU2d.__init__r)   r   r   r'   r   r   g   s   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   z 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"   r1   r'   r   r   r"   s   s     ÿÿzBNReLU3d.__init__r)   r   r   r'   r   r   p   s   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )r   z¡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"   }   s    ÿzLinearBn1d.__init__r)   r   r   r'   r   r   z   s   )ZtorchZtorch.nnr   r   r   r   r   r   r   r	   Ztorch.nn.utils.parametrizer
   Ú__all__ÚnnZ
Sequentialr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Ú<module>   s2   (     þ									
	
