U
    <c
                     @   sX   d dl Z d dlZ d dlZ d dlm  m  mZ G dd dejZ	G dd dej
ZdS )    Nc                       s\   e Zd ZdZejjjZd fdd	Z	dd Z
d	d
 Ze fddZe fddZ  ZS )BNReLU2dz
    A BNReLU2d module is a fused module of BatchNorm2d and ReLU

    We adopt the same interface as :class:`torch.ao.nn.quantized.BatchNorm2d`.

    Attributes:
        Same as torch.ao.nn.quantized.BatchNorm2d

    h㈵>皙?Nc                    s   t t| j|||||d d S N)epsmomentumdevicedtype)superr   __init__selfZnum_featuresr   r   r   r	   	__class__ P/tmp/pip-unpacked-wheel-gikjz4vx/torch/nn/intrinsic/quantized/modules/bn_relu.pyr      s    zBNReLU2d.__init__c              
   C   s@   t |jdkrtdtjj|| j| j| j	| j
| j| j| jS )N   z#Input shape must be `(N, C, H, W)`!)lenshape
ValueErrortorchops	quantizedZbatch_norm2d_reluweightbiasrunning_meanrunning_varr   scale
zero_pointr   inputr   r   r   forward   s          zBNReLU2d.forwardc                 C   s   dS )NZQuantizedBNReLU2dr   r   r   r   r   	_get_name    s    zBNReLU2d._get_namec                    s   t t| |S N)r
   r   
from_floatclsmodr   r   r   r%   #   s    zBNReLU2d.from_floatc                    s   t  |d ||S Nr   r
   from_referencer'   Zbn_reluZoutput_scaleZoutput_zero_pointr   r   r   r+   (   s    zBNReLU2d.from_reference)r   r   NN)__name__
__module____qualname____doc__r   nn	intrinsicr   _FLOAT_MODULEr   r!   r#   classmethodr%   r+   __classcell__r   r   r   r   r      s   	
	r   c                       s\   e Zd ZdZejjjZd fdd	Z	dd Z
d	d
 Ze fddZe fddZ  ZS )BNReLU3dz
    A BNReLU3d module is a fused module of BatchNorm3d and ReLU

    We adopt the same interface as :class:`torch.ao.nn.quantized.BatchNorm3d`.

    Attributes:
        Same as torch.ao.nn.quantized.BatchNorm3d

    r   r   Nc                    s   t t| j|||||d d S r   )r
   r6   r   r   r   r   r   r   8   s    zBNReLU3d.__init__c              
   C   s@   t |jdkrtdtjj|| j| j| j	| j
| j| j| jS )N   z&Input shape must be `(N, C, D, H, W)`!)r   r   r   r   r   r   Zbatch_norm3d_relur   r   r   r   r   r   r   r   r   r   r   r!   ;   s          zBNReLU3d.forwardc                 C   s   dS )NZQuantizedBNReLU3dr   r"   r   r   r   r#   D   s    zBNReLU3d._get_namec                    s   t t| |S r$   )r
   r6   r%   r&   r   r   r   r%   G   s    zBNReLU3d.from_floatc                    s   t  |d ||S r)   r*   r,   r   r   r   r+   L   s    zBNReLU3d.from_reference)r   r   NN)r-   r.   r/   r0   r   r1   r2   r6   r3   r   r!   r#   r4   r%   r+   r5   r   r   r   r   r6   ,   s   	
	r6   )r   Ztorch.ao.nn.intrinsicZtorch.nn.intrinsic.qatZtorch.ao.nn.quantizedZaor1   r   ZnnqZBatchNorm2dr   ZBatchNorm3dr6   r   r   r   r   <module>   s
   $