U
    yh=$                     @   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 dddd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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
LinearBn1dLinearLeakyReLU
LinearTanh	ConvAdd2dConvAddReLU2dc                   @   s   e Zd ZdS )_FusedModuleN)__name__
__module____qualname__ r    r    U/var/www/html/venv/lib/python3.8/site-packages/torch/ao/nn/intrinsic/modules/fused.pyr      s   r   c                       s    e Zd ZdZ fddZ  ZS )r   zThis is a sequential container which calls the Conv1d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sD   t |tkrt |tks2tdt | t | t || d S Nz!Incorrect types for input modules)r
   r   r   AssertionError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   zThis is a sequential container which calls the Conv2d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sD   t |tkrt |tks2tdt | t | t || d S 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   zThis is a sequential container which calls the Conv3d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sD   t |tkrt |tks2tdt | t | t || d S 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   zThis is a sequential container which calls the Linear and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sD   t |tkrt |tks2tdt | t | t || d S 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   zThis 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                    sD   t |tkrt |tks2tdt | t | t || d S r"   )r
   r   r   r#   r$   r%   r'   r(   bnr*   r    r!   r%   1   s    zConvBn1d.__init__r,   r    r    r*   r!   r   .   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis 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                    sD   t |tkrt |tks2tdt | t | t || d S r"   )r
   r   r   r#   r$   r%   r0   r*   r    r!   r%   9   s    zConvBn2d.__init__r,   r    r    r*   r!   r   6   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis 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                    sZ   t |tkr$t |tkr$t |tksFtdt | t | t | t ||| d S r"   )r
   r   r   r   r#   r$   r%   r'   r(   r1   r)   r*   r    r!   r%   A   s    
zConvBnReLU1d.__init__r,   r    r    r*   r!   r   >   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis 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                    sZ   t |tkr$t |tkr$t |tksFtdt | t | t | t ||| d S r"   )r
   r   r   r   r#   r$   r%   r2   r*   r    r!   r%   I   s    
zConvBnReLU2d.__init__r,   r    r    r*   r!   r   F   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis 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                    sD   t |tkrt |tks2tdt | t | t || d S r"   )r
   r   r	   r#   r$   r%   r0   r*   r    r!   r%   Q   s    zConvBn3d.__init__r,   r    r    r*   r!   r   N   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis 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                    sZ   t |tkr$t |tkr$t |tksFtdt | t | t | t ||| d S r"   )r
   r   r	   r   r#   r$   r%   r2   r*   r    r!   r%   Y   s    
zConvBnReLU3d.__init__r,   r    r    r*   r!   r   V   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis is a sequential container which calls the BatchNorm 2d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sD   t |tkrt |tks2tdt | t | t || d S r"   )r
   r   r   r#   r$   r%   r'   Z
batch_normr)   r*   r    r!   r%   b   s    zBNReLU2d.__init__r,   r    r    r*   r!   r   _   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis is a sequential container which calls the BatchNorm 3d and ReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sD   t |tkrt |tks2tdt | t | t || d S r"   )r
   r	   r   r#   r$   r%   r3   r*   r    r!   r%   j   s    zBNReLU3d.__init__r,   r    r    r*   r!   r   g   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis is a sequential container which calls the Linear and BatchNorm1d modules.
    During quantization this will be replaced with the corresponding fused module.c                    sD   t |tkrt |tks2tdt | t | t || d S r"   )r
   r   r   r#   r$   r%   )r'   r/   r1   r*   r    r!   r%   s   s    zLinearBn1d.__init__r,   r    r    r*   r!   r   p   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis is a sequential container which calls the Linear and LeakyReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    sH   t |tkrt |tjjks6tdt | t | t || d S r"   )typer   torchnnZ	LeakyReLUr#   r$   r%   )r'   r/   Z
leaky_relur*   r    r!   r%   {   s    zLinearLeakyReLU.__init__r,   r    r    r*   r!   r   x   s   c                       s    e Zd ZdZ fddZ  ZS )r   zThis is a sequential container which calls the Linear and Tanh modules.
    During quantization this will be replaced with the corresponding fused module.c                    sH   t |tkrt |tjjks6tdt | t | t || d S r"   )r4   r   r5   r6   ZTanhr#   r$   r%   )r'   r/   tanhr*   r    r!   r%      s    zLinearTanh.__init__r,   r    r    r*   r!   r      s   c                       s(   e Zd ZdZ fddZdd Z  ZS )r   zThis is a sequential container which calls the Conv2d modules with extra Add.
    During quantization this will be replaced with the corresponding fused module.c                    s   t  | || _d S N)r$   r%   add)r'   r(   r9   r*   r    r!   r%      s    zConvAdd2d.__init__c                 C   s   |  | d ||S Nr   )r9   r'   x1Zx2r    r    r!   forward   s    zConvAdd2d.forwardr   r   r   r-   r%   r=   r.   r    r    r*   r!   r      s   c                       s(   e Zd ZdZ fddZdd Z  ZS )r   zThis is a sequential container which calls the Conv2d, add, Relu.
    During quantization this will be replaced with the corresponding fused module.c                    s   t  | || _|| _d S r8   )r$   r%   r9   r)   )r'   r(   r9   r)   r*   r    r!   r%      s    zConvAddReLU2d.__init__c                 C   s   |  | | d ||S r:   )r)   r9   r;   r    r    r!   r=      s    zConvAddReLU2d.forwardr>   r    r    r*   r!   r      s   )!r5   Ztorch.nnr   r   r   r   r   r   r   r	   Ztorch.nn.utils.parametrizer
   __all__r6   Z
Sequentialr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r    r    r!   <module>   sB   (         		
