o
    ‡ZŽh?&  ã                   @   sl  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¢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)ÚBatchNorm1dÚBatchNorm2dÚBatchNorm3dÚConv1dÚConv2dÚConv3dÚLinearÚReLU)Ú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    úR/var/www/auris/lib/python3.10/site-packages/torch/ao/nn/intrinsic/modules/fused.pyr   &   s    r   c                       ó    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                    óD   t |ƒtkrt |ƒtksJ dt |ƒ› t |ƒ› ƒ‚tƒ  ||¡ d S ©Nz!Incorrect types for input modules)r
   r   r	   ÚsuperÚ__init__©ÚselfÚconvÚrelu©Ú	__class__r    r!   r&   .   ó
   ÿzConvReLU1d.__init__©r   r   r   Ú__doc__r&   Ú__classcell__r    r    r+   r!   r   *   ó    r   c                       r"   )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                    r#   r$   )r
   r   r	   r%   r&   r'   r+   r    r!   r&   :   r-   zConvReLU2d.__init__r.   r    r    r+   r!   r   6   r1   r   c                       r"   )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                    r#   r$   )r
   r   r	   r%   r&   r'   r+   r    r!   r&   F   r-   zConvReLU3d.__init__r.   r    r    r+   r!   r   B   r1   r   c                       r"   )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                    r#   r$   )r
   r   r	   r%   r&   )r(   Úlinearr*   r+   r    r!   r&   R   r-   zLinearReLU.__init__r.   r    r    r+   r!   r   N   r1   r   c                       r"   )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                    r#   r$   )r
   r   r   r%   r&   ©r(   r)   Úbnr+   r    r!   r&   ^   r-   zConvBn1d.__init__r.   r    r    r+   r!   r   Z   r1   r   c                       r"   )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                    r#   r$   )r
   r   r   r%   r&   r3   r+   r    r!   r&   j   r-   zConvBn2d.__init__r.   r    r    r+   r!   r   f   r1   r   c                       r"   )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                    óZ   t |ƒtkrt |ƒtkrt |ƒtks#J dt |ƒ› t |ƒ› t |ƒ› ƒ‚tƒ  |||¡ d S r$   )r
   r   r   r	   r%   r&   ©r(   r)   r4   r*   r+   r    r!   r&   v   ó   ÿzConvBnReLU1d.__init__r.   r    r    r+   r!   r   r   r1   r   c                       r"   )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                    r5   r$   )r
   r   r   r	   r%   r&   r6   r+   r    r!   r&   ƒ   r7   zConvBnReLU2d.__init__r.   r    r    r+   r!   r      r1   r   c                       r"   )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                    r#   r$   )r
   r   r   r%   r&   r3   r+   r    r!   r&      r-   zConvBn3d.__init__r.   r    r    r+   r!   r   Œ   r1   r   c                       r"   )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                    r5   r$   )r
   r   r   r	   r%   r&   r6   r+   r    r!   r&   œ   r7   zConvBnReLU3d.__init__r.   r    r    r+   r!   r   ˜   r1   r   c                       r"   )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                    r#   r$   )r
   r   r	   r%   r&   ©r(   Z
batch_normr*   r+   r    r!   r&   ©   r-   zBNReLU2d.__init__r.   r    r    r+   r!   r   ¥   r1   r   c                       r"   )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                    r#   r$   )r
   r   r	   r%   r&   r8   r+   r    r!   r&   µ   r-   zBNReLU3d.__init__r.   r    r    r+   r!   r   ±   r1   r   c                       r"   )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                    r#   r$   )r
   r   r   r%   r&   )r(   r2   r4   r+   r    r!   r&   Á   r-   zLinearBn1d.__init__r.   r    r    r+   r!   r   ½   r1   r   c                       r"   )r   zŸThis is a sequential container which calls the Linear and LeakyReLU modules.
    During quantization this will be replaced with the corresponding fused module.c                    óH   t |ƒtkrt |ƒtjjksJ dt |ƒ› t |ƒ› ƒ‚tƒ  ||¡ d S r$   )Útyper   ÚtorchÚnnZ	LeakyReLUr%   r&   )r(   r2   Z
leaky_relur+   r    r!   r&   Í   ó   ÿzLinearLeakyReLU.__init__r.   r    r    r+   r!   r   É   r1   r   c                       r"   )r   zšThis is a sequential container which calls the Linear and Tanh modules.
    During quantization this will be replaced with the corresponding fused module.c                    r9   r$   )r:   r   r;   r<   ZTanhr%   r&   )r(   r2   Útanhr+   r    r!   r&   Ø   r=   zLinearTanh.__init__r.   r    r    r+   r!   r   Ô   r1   r   c                       ó(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )r   z This 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)   rA   r+   r    r!   r&   ã   s   
zConvAdd2d.__init__c                 C   s   |   | d |ƒ|¡S ©Nr   )rA   ©r(   Úx1Zx2r    r    r!   Úforwardç   s   zConvAdd2d.forward©r   r   r   r/   r&   rE   r0   r    r    r+   r!   r   ß   s    r   c                       r?   )r   z”This 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 r@   )r%   r&   rA   r*   )r(   r)   rA   r*   r+   r    r!   r&   ï   s   
zConvAddReLU2d.__init__c                 C   s   |   |  | d |ƒ|¡¡S rB   )r*   rA   rC   r    r    r!   rE   ô   s   zConvAddReLU2d.forwardrF   r    r    r+   r!   r   ë   s    r   )!r;   Ztorch.nnr   r   r   r   r   r   r   r	   Ztorch.nn.utils.parametrizer
   Ú__all__r<   Z
Sequentialr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r    r    r!   Ú<module>   s,   (
