Ë
    ÄÓ^j!«  ã                   ó˜  — d Z ddlmZmZ ddlZddlmc mc mZ	 ddl
mc mc mc mZ ddlmZ ddlmc mZ ddlmZ ddlmZ ddlmZmZmZ ddlmZ dd	lmZmZ g d
¢ZddhZde e!   de e!   fd„Z" G d„ de«      Z# G d„ de#«      Z$ G d„ de#«      Z% G d„ de#«      Z& G d„ de#«      Z' G d„ de'«      Z( G d„ de'«      Z) G d„ de'«      Z*y) zQuantized convolution modules.é    )ÚClassVarÚLiteralN)Úops)Ú	_size_1_t)Ú_pairÚ_singleÚ_triple)Úfuse_conv_bn_weightsé   )Ú_quantize_weightÚWeightedQuantizedModule)ÚConv1dÚConv2dÚConv3dÚConvTranspose1dÚConvTranspose2dÚConvTranspose3dÚzerosÚreflectÚpaddingÚreturnc                 ó�   ‡ ‡‡— g }t        ‰ «      Št        ‰«      D ]'  Š|j                  ˆˆˆ fd„t        d«      D «       «       Œ) |S )Nc              3   ó4   •K  — | ]  }‰‰‰z
  d z
     –— Œ y­w)r   N© )Ú.0Ú_ÚNÚidxr   s     €€€úm/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/torch/ao/nn/quantized/modules/conv.pyú	<genexpr>z*_reverse_repeat_padding.<locals>.<genexpr>#   s   øè ø€ Ò/WÈ°¸¸C¹À!¹Õ0DÑ/Wùs   ƒé   )ÚlenÚrangeÚextend)r   Ú _reversed_padding_repeated_twicer   r   s   ` @@r   Ú_reverse_repeat_paddingr&      sF   ú€ Ø24Ð$ÜˆG‹€AÜ�Q‹xò XˆØ(×/Ñ/Õ/WÌeÐTUËhÔ/WÕWðXà+Ð+ó    c                   ó  ‡ — e Zd Z	 	 	 	 	 	 	 	 dd„Z	 	 	 d	 dˆ fd„Zd„ Zd„ Zd„ Zd„ Zˆ fd„Z	e
j                  j                  d„ «       Zˆ fd	„Ze
j                  j                  d
„ «       Zd„ Zd„ Zedd„«       Zedd„«       Zed„ «       Zˆ xZS )Ú_ConvNdc                 ó   — t         ‚©N©ÚNotImplementedError)ÚselfÚin_channelsÚout_channelsÚkernel_sizeÚstrider   ÚdilationÚgroupsÚbiasÚpadding_modeÚdeviceÚdtypes               r   Ú__init__z_ConvNd.__init__(   s
   € ô "Ð!r'   c           
      ój  •— ||dœ}t         ‰| �  «        |dk  rt        d|› �«      ‚||	z  dk7  rt        d«      ‚||	z  dk7  rt        d«      ‚|| _        || _        || _        || _        || _        || _        || _	        || _
        |	| _        |t        vrt        d|› d�«      ‚|| _        | j                  r||| j                  z  g}n||| j                  z  g}t        j                  |t!        |«      z   fddt        j"                  d	œ|j%                  «       D ��ci c]  \  }}|d
k7  sŒ||“Œ c}}¤Ž}|
rNt        j&                  |fd
t        j(                  i|j%                  «       D ��ci c]  \  }}|d
k7  sŒ||“Œ c}}¤Žnd }| j+                  ||«       d| _        d| _        y c c}}w c c}}w )N©r7   r8   r   z)out_channels must be greater than 0, got z'in_channels must be divisible by groupsz(out_channels must be divisible by groupsz'padding_mode' z* is not supported by quantized convolutionr   )ÚscaleÚ
zero_pointr8   r8   g      ð?)Úsuperr9   Ú
ValueErrorr/   r0   r1   r2   r   r3   Ú
transposedÚoutput_paddingr4   Ú_SUPPORTED_PADDINGr6   ÚtorchÚ_empty_affine_quantizedÚlistÚqint8Úitemsr   ÚfloatÚset_weight_biasr<   r=   )r.   r/   r0   r1   r2   r   r3   r@   rA   r4   r5   r6   r7   r8   Úfactory_kwargsÚweight_shapeÚkÚvÚqweightÚ
bias_floatÚ	__class__s                       €r   Ú_initz_ConvNd._init9   sã  ø€ ð  %+°UÑ;ˆÜ‰ÑÔà˜1ÒÜÐHÈÈÐWÓXÐXØ˜Ñ 1Ò$ÜÐFÓGÐGØ˜&Ñ  AÒ%ÜÐGÓHÐHØ&ˆÔØ(ˆÔØ&ˆÔØˆŒØˆŒØ ˆŒØ$ˆŒØ,ˆÔØˆŒØÔ1Ñ1ÜØ! , Ð/YÐZóð ð )ˆÔà�?Š?Ø'¨¸¿¹Ñ)DÐE‰Là(¨+¸¿¹Ñ*DÐEˆLÜ×/Ñ/Øœ4 Ó,Ñ,ð
àØÜ—+‘+ñ	
ð
 !/× 4Ñ 4Ó 6×G™˜˜1¸!¸w»,ˆq�!‰tÓGñ
ˆñ ô �K‰KØñä—k‘kðð %3×$8Ñ$8Ó$:×K™D˜A˜q¸aÀ7»l�1�a‘4ÓKòð ð 	ð 	×Ñ˜W jÔ1ØˆŒ
Øˆ�ùó Hùó Ls   ÄF)Ä+F)Å-F/Å;F/c                 ó   — t         ‚r+   r,   )r.   rN   rO   s      r   rI   z_ConvNd.set_weight_biasz   ó   € Ü!Ð!r'   c                 ó   — t         ‚r+   r,   ©r.   s    r   r5   z_ConvNd.bias}   rS   r'   c                 ó   — t         ‚r+   r,   rU   s    r   Ú_weight_biasz_ConvNd._weight_bias€   rS   r'   c                 óŒ  — d}| j                   dt        | j                   «      z  k7  r|dz  }| j                  dt        | j                  «      z  k7  r|dz  }| j                  dt        | j                  «      z  k7  r|dz  }| j                  dk7  r|dz  }| j                  «       €|d	z  } |j                  d
i | j                  ¤ŽS )Nzq{in_channels}, {out_channels}, kernel_size={kernel_size}, stride={stride}, scale={scale}, zero_point={zero_point})r   z, padding={padding})r   z, dilation={dilation}z!, output_padding={output_padding}r   z, groups={groups}z, bias=Falser   )r   r"   r3   rA   r4   r5   ÚformatÚ__dict__)r.   Úss     r   Ú
extra_reprz_ConvNd.extra_reprƒ   sÇ   € ðHð 	
ð �<‰<˜4¤# d§l¡lÓ"3Ñ3Ò3ØÐ&Ñ&ˆAØ�=‰=˜D¤3 t§}¡}Ó#5Ñ5Ò5ØÐ(Ñ(ˆAØ×Ñ $¬¨T×-@Ñ-@Ó)AÑ"AÒAØÐ4Ñ4ˆAØ�;‰;˜!ÒØÐ$Ñ$ˆAØ�9‰9‹;ÐØ�ÑˆAØˆq�x‰xÑ(˜$Ÿ-™-Ñ(Ð(r'   c                 ó  •— t         ‰| �  |||«       | j                  «       \  }}|||dz   <   |||dz   <   t        j                  | j
                  «      ||dz   <   t        j                  | j                  «      ||dz   <   y )NÚweightr5   r<   r=   )r>   Ú_save_to_state_dictrW   rC   Útensorr<   r=   )r.   ÚdestinationÚprefixÚ	keep_varsÚwÚbrP   s         €r   r_   z_ConvNd._save_to_state_dict    s{   ø€ Ü‰Ñ# K°¸ÔCØ×"Ñ"Ó$‰ˆˆAØ)*ˆ�F˜XÑ%Ñ&Ø'(ˆ�F˜V‘OÑ$Ü(-¯©°T·Z±ZÓ(@ˆ�F˜WÑ$Ñ%Ü-2¯\©\¸$¿/¹/Ó-Jˆ�F˜\Ñ)Ò*r'   c                 óN  — | j                  «       \  }}| j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  ||| j                  | j                  | j                  fS r+   )rW   r/   r0   r1   r2   r   r3   r@   rA   r4   r6   r<   r=   Útraining©r.   rd   re   s      r   Ú__getstate__z_ConvNd.__getstate__¨   s‰   € à×"Ñ"Ó$‰ˆˆAà×ÑØ×ÑØ×ÑØ�K‰KØ�L‰LØ�M‰MØ�O‰OØ×ÑØ�K‰KØ×ÑØØØ�J‰JØ�O‰OØ�M‰Mð
ð 	
r'   c           	      ód  •— | j                  ||dz      ||dz      «       |j                  |dz   «       |j                  |dz   «       t        ||dz      «      | _        |j                  |dz   «       t	        ||dz      «      | _        |j                  |dz   «       t        ‰| �  |||d|||«       y )Nr^   r5   r<   r=   F)rI   ÚpoprH   r<   Úintr=   r>   Ú_load_from_state_dict)	r.   Ú
state_dictrb   Úlocal_metadataÚstrictÚmissing_keysÚunexpected_keysÚ
error_msgsrP   s	           €r   rm   z_ConvNd._load_from_state_dictÀ   sº   ø€ ð 	×Ñ˜Z¨°Ñ(9Ñ:¸JÀvÐPVÁÑ<WÔXØ�‰�v Ñ(Ô)Ø�‰�v ‘Ô'Ü˜: f¨wÑ&6Ñ7Ó8ˆŒ
Ø�‰�v Ñ'Ô(Ü˜j¨°,Ñ)>Ñ?Ó@ˆŒØ�‰�v Ñ,Ô-Ü‰Ñ%ØØØØØØØõ	
r'   c                 ó8  — |d   | _         |d   | _        |d   | _        |d   | _        |d   | _        |d   | _        |d   | _        |d   | _        |d	   | _        |d
   | _	        | j                  |d   |d   «       |d   | _        |d   | _        |d   | _        y )Nr   r   r!   é   é   é   é   é   é   é	   é
   é   é   é   é   )r/   r0   r1   r2   r   r3   r@   rA   r4   r6   rI   r<   r=   rg   )r.   Ústates     r   Ú__setstate__z_ConvNd.__setstate__Û   s®   € à  ™8ˆÔØ! !™HˆÔØ  ™8ˆÔØ˜A‘hˆŒØ˜Q‘xˆŒØ˜a™ˆŒØ ™(ˆŒØ# A™hˆÔØ˜A‘hˆŒØ! !™HˆÔØ×Ñ˜U 2™Y¨¨b©	Ô2Ø˜2‘YˆŒ
Ø ™)ˆŒØ˜b™	ˆ�r'   c                 óà   — t        | «      j                  t        | «      «      }t        j                  j                  j                  |«       | j                  «       }|j                  |«       |S r+   )ÚtypeÚ__new__rC   ÚnnÚModuler9   ri   r‚   )r.   ÚmemoÚnew_instancer�   s       r   Ú__deepcopy__z_ConvNd.__deepcopy__ì   sR   € Ü˜D“z×)Ñ)¬$¨t«*Ó5ˆÜ�‰�‰× Ñ  Ô.Ø×!Ñ!Ó#ˆØ×!Ñ! %Ô(ØÐr'   c                 ó$   — | j                  i «      S r+   )rŠ   rU   s    r   Ú__copy__z_ConvNd.__copy__ó   s   € Ø× Ñ  Ó$Ð$r'   c                 óÌ  — |€|j                   j                  «       } ||j                  «       |j                  t        j                  k7  rt        d|j                  › �«      ‚t        |j                  j                  «       |«      } | |j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  du|j                   «	      }|j#                  ||j                  «       |�|j                  t        j                  k(  r|S |j%                  «       \  }}t        |«      |_        t)        |«      |_        |S )z&Creates a qconv object and returns it.Nú0Weight observer must have a dtype of qint8, got )Úqconfigr^   r8   rC   rF   ÚAssertionErrorr   rH   r/   r0   r1   r2   r   r3   r4   r5   r6   rI   Úcalculate_qparamsr<   rl   r=   )ÚclsÚmodÚactivation_post_processÚweight_post_processrN   ÚqconvÚ	act_scaleÚact_zps           r   Ú	get_qconvz_ConvNd.get_qconvö   s+  € ð Ð&Ø"%§+¡+×"4Ñ"4Ó"6ÐÙ˜CŸJ™JÔ'Ø×$Ñ$¬¯©Ò3Ü ØBÐCV×C\ÑC\ÐB]Ð^óð ô # 3§:¡:×#3Ñ#3Ó#5Ð7JÓKˆáØ�O‰OØ×ÑØ�O‰OØ�J‰JØ�K‰KØ�L‰LØ�J‰JØ�H‰H˜DÐ Ø×Ñó

ˆð 	×Ñ˜g s§x¡xÔ0à#Ð+Ø&×,Ñ,´·±Ò;àˆLà 7× IÑ IÓ KÑˆI�vÜ 	Ó*ˆEŒKÜ" 6›{ˆEÔØˆLr'   c           
      ó®  — t        |d«      rÝt        |«      | j                  u r–t        |j                  |j
                  |j                  j                  |j                  j                  |j                  j                  |j                  j                  |j                  j
                  «      \  |_        |_        t        |d«      st        d«      ‚|j                  }|j                  }nÚt        |«      | j                  urEt        d| j                  › d| j                  j                  › dt        |«      j                  › �«      ‚t        |d«      st        d«      ‚t        |d«      sd n|j                  }t        |«      | j                  | j                   | j"                  fv r|d	   }|j$                  j	                  «       }| j'                  |||«      S )
NÚweight_fake_quantr”   z,Input QAT module must have observer attachedznnq.ú.from_float only works for z
 but got: r�   ú-Input float module must have qconfig defined.r   )Úhasattrr„   Ú_NNIQAT_CONV_BN_MODULEr
   r^   r5   ÚbnÚrunning_meanÚrunning_varÚepsr�   r›   r”   Ú_FLOAT_MODULEÚ__name__Ú_NNI_CONV_RELU_MODULEÚ_NNI_CONV_ADD_MODULEÚ_NNI_CONV_ADD_RELU_MODULEr�   r™   )r’   r“   Úuse_precomputed_fake_quantr•   r”   s        r   Ú
from_floatz_ConvNd.from_float  s�  € ä�3Ð+Ô,ô �C‹y˜C×6Ñ6Ñ6Ü';Ø—J‘JØ—H‘HØ—F‘F×'Ñ'Ø—F‘F×&Ñ&Ø—F‘F—J‘JØ—F‘F—M‘MØ—F‘F—K‘Kó(Ñ$�”
˜CœHô ˜3Ð 9Ô:Ü$Ð%SÓTÐTØ"%×"7Ñ"7ÐØ&)×&AÑ&AÑ#ä�C‹y × 1Ñ 1Ñ1Ü$Ø˜3Ÿ<™<˜.Ð(CØ×(Ñ(×1Ñ1Ð2°*¼TÀ#»Y×=OÑ=OÐ<PðRóð ô ˜3 	Ô*Ü$Ð%TÓUÐUô ˜sÐ$=Ô>ñ à×0Ñ0ð $ô
 �C‹yØ×)Ñ)Ø×(Ñ(Ø×-Ñ-ðñ ð
 ˜!‘f�Ø"%§+¡+×"4Ñ"4Ó"6ÐØ�}‰}˜SÐ"9Ð;NÓOÐOr'   c                 óÌ  —  | |j                   |j                  |j                  |j                  |j                  |j
                  |j                  |j                  du|j                  |j                  j                  |j                  j                  ¬«      }|j                  «       }|j                  ||j                  «       t        |«      |_        t!        |«      |_        |S )a‰  Create a (fbgemm/qnnpack) quantized module from a reference quantized module
        Args:
            ref_qconv (Module): a reference quantized  module, either produced by torch.ao.quantization
                                utilities or provided by the user
            output_scale (float): scale for output Tensor
            output_zero_point (int): zero point for output Tensor
        Nr;   )r/   r0   r1   r2   r   r3   r4   r5   r6   r^   r7   r8   Úget_quantized_weightrI   rH   r<   rl   r=   )r’   Ú	ref_qconvÚoutput_scaleÚoutput_zero_pointr–   rN   s         r   Úfrom_referencez_ConvNd.from_referenceB  sÃ   € ñ Ø×!Ñ!Ø×"Ñ"Ø×!Ñ!Ø×ÑØ×ÑØ×ÑØ×ÑØ�N‰N $Ð&Ø×"Ñ"Ø×#Ñ#×*Ñ*Ø×"Ñ"×(Ñ(ô
ˆð ×0Ñ0Ó2ˆØ×Ñ˜g y§~¡~Ô6Ü˜LÓ)ˆŒÜÐ0Ó1ˆÔØˆr'   ©r   r   r   r   Tr   NN)r   NN)r   Nr+   ©F)r¥   Ú
__module__Ú__qualname__r9   rQ   rI   r5   rW   r\   r_   rC   ÚjitÚexportri   rm   r‚   rŠ   rŒ   Úclassmethodr™   Ústaticmethodrª   r°   Ú__classcell__©rP   s   @r   r)   r)   '   sâ   ø„ ð ØØØØØØØó"ð: ØØð?ð 
õ?òB"ò"ò"ò)ô:Kð ‡Y�Y×Ññ
ó ð
ô.
ð6 ‡Y�Y×Ññ"ó ð"ò ò%ð ò ó ð ðD ò&Pó ð&PðP ñó ôr'   r)   c                   ó  ‡ — e Zd ZU dZej
                  Zeeej
                        e	d<   e
j                  Zeeej                     dz     e	d<   ej                  Zeeej                     dz     e	d<   dZeeej                     dz     e	d<   dZeeej                     dz     e	d<   	 	 	 	 	 	 	 	 dded	ed
ededededededed   fˆ fd„Zd„ Zdej4                  dej4                  dz  ddfd„Zd„ Zd„ Zd„ Zd„ Ze dd„«       Z!ˆ xZ"S )r   a`  Applies a 1D convolution over a quantized input signal composed of
    several quantized input planes.

    For details on input arguments, parameters, and implementation see
    :class:`~torch.nn.Conv1d`.

    .. note::
        Only `zeros` is supported for the :attr:`padding_mode` argument.

    .. note::
        Only `torch.quint8` is supported for the input data type.


    Attributes:
        weight (Tensor):     packed tensor derived from the learnable weight
                             parameter.
        scale (Tensor):      scalar for the output scale
        zero_point (Tensor): scalar for the output zero point

    See :class:`~torch.nn.Conv1d` for other attributes.

    Examples::

        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_QENGINE)
        >>> m = nn.quantized.Conv1d(16, 33, 3, stride=2)
        >>> input = torch.randn(20, 16, 100)
        >>> # quantize input to quint8
        >>> # xdoctest: +SKIP
        >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0,
        ...                                     dtype=torch.quint8)
        >>> output = m(q_input)

    r¤   NrŸ   r¦   r§   r¨   r/   r0   r1   r2   r   r3   r4   r5   r6   )r   r   Ú	replicateÚcircularc                 óÒ   •— |
|dœ}t        |«      }t        |«      }t        |t        «      r|n
t        |«      }t        |«      }t        ‰| �  ||||||dt        d«      |||	fi |¤Ž y ©Nr;   Fr   )r   Ú
isinstanceÚstrr>   rQ   ©r.   r/   r0   r1   r2   r   r3   r4   r5   r6   r7   r8   rJ   rP   s                €r   r9   zConv1d.__init__ˆ  s~   ø€ ð %+°UÑ;ˆÜ˜kÓ*ˆÜ˜“ˆä'¨´Ô5‘'¼7À7Ó;KˆÜ˜8Ó$ˆô 	‰‰ØØØØØØØÜ�A‹JØØØñ	
ð ó	
r'   c                  ó   — y)NÚQuantizedConv1dr   rU   s    r   Ú	_get_namezConv1d._get_name®  ó   € Ø r'   rd   re   r   c                 óŽ  — | j                   dk(  r\t        j                  j                  j	                  ||| j
                  | j                  | j                  | j                  «      | _	        y t        j                  j                  j	                  ||| j
                  t        d«      | j                  | j                  «      | _	        y ©Nr   r   )r6   rC   r   Ú	quantizedÚconv1d_prepackr2   r   r3   r4   Ú_packed_paramsr   rh   s      r   rI   zConv1d.set_weight_bias±  ó†   € Ø×Ñ Ò'Ü"'§)¡)×"5Ñ"5×"DÑ"DØ�1�d—k‘k 4§<¡<°·±ÀÇÁó#ˆDÕô #(§)¡)×"5Ñ"5×"DÑ"DØ�1�d—k‘k¤5¨£8¨T¯]©]¸D¿K¹Kó#ˆDÕr'   c                 óv   — t         j                  j                  j                  | j                  «      \  }}||fS r+   )rC   r   rÉ   Úconv1d_unpackrË   rh   s      r   rW   zConv1d._weight_bias»  ó/   € Ü�y‰y×"Ñ"×0Ñ0°×1DÑ1DÓE‰ˆˆ1Ø�!ˆtˆr'   c                 ó(   — | j                  «       d   S ©Nr   ©rW   rU   s    r   r^   zConv1d.weight¿  ó   € Ø× Ñ Ó" 1Ñ%Ð%r'   c                 ó(   — | j                  «       d   S ©Nr   rÒ   rU   s    r   r5   zConv1d.biasÂ  rÓ   r'   c                 óZ  — t        |j                  «      dk7  rt        d«      ‚| j                  dk7  r:t	        | j
                  d d «      }t        j                  ||| j                  ¬«      }t        j                  j                  || j                  | j                  | j                  «      S )Nru   ú Input shape must be `(N, C, L)`!r   r   ©Úmode)r"   Úshaper?   r6   r&   r   ÚFÚpadr   rÉ   Úconv1drË   r<   r=   ©r.   Úinputr%   s      r   ÚforwardzConv1d.forwardÅ  s“   € ô ˆu�{‰{Ó˜qÒ ÜÐ?Ó@Ð@Ø×Ñ Ò'ä/FÀtÇ|Á|ÐTVÐUVÐGWÓ/XÐ,Ü—E‘EØÐ7¸d×>OÑ>OôˆEô �}‰}×#Ñ#Ø�4×&Ñ&¨¯
©
°D·O±Oó
ð 	
r'   c                 ó2   — t         j                  | ||¬«      S ©zÚCreates a quantized module from a float module or qparams_dict.

        Args:
            mod (Module): a float module, either produced by torch.ao.quantization
              utilities or provided by the user
        )r©   ©r)   rª   ©r’   r“   r©   s      r   rª   zConv1d.from_floatÔ  ó$   € ô ×!Ñ!Ø�Ð1Kð "ó 
ð 	
r'   r±   r²   )#r¥   r³   r´   Ú__doc__r†   r   r¤   r   r„   Ú__annotations__ÚnniqatÚConvBn1drŸ   r‡   ÚnniÚ
ConvReLU1dr¦   r§   r¨   rl   r   Úboolr   r9   rÅ   rC   ÚTensorrI   rW   r^   r5   rà   r·   rª   r¹   rº   s   @r   r   r   _  st  ø… ñ ðD 02¯y©y€M�8˜D §¡™OÑ,Ó8Ø?E¿¹Ð˜H T¨"¯)©)¡_°tÑ%;Ñ<ÓNØ>A¿n¹nÐ˜8 D¨¯©¡O°dÑ$:Ñ;ÓLØ=AÐ˜( 4¨¯	©	¡?°TÑ#9Ñ:ÓAØBFÐ˜x¨¨R¯Y©Y©¸$Ñ(>Ñ?ÓFð ØØØØØMTØØñ$
àð$
ð ð$
ð ð	$
ð
 ð$
ð ð$
ð ð$
ð ð$
ð ð$
ð ÐIÑJõ$
òL!ð §¡ð °%·,±,ÀÑ2Eð È$ó òò&ò&ò
ð ò	
ó ô	
r'   r   c                   óþ  ‡ — e Zd ZU dZej
                  Zeeej
                        e	d<   e
j                  Zeeej                     dz     e	d<   ej                  Zeeej                     dz     e	d<   ej"                  Zeeej"                        e	d<   ej&                  Zeeej&                        e	d<   	 	 	 	 	 	 	 	 dˆ fd„	Zd	„ Zd
ej0                  dej0                  dz  ddfd„Zd„ Zd„ Zd„ Zd„ Zedd„«       Zˆ xZ S )r   aµ  Applies a 2D convolution over a quantized input signal composed of
    several quantized input planes.

    For details on input arguments, parameters, and implementation see
    :class:`~torch.nn.Conv2d`.

    .. note::
        Only `zeros` is supported for the :attr:`padding_mode` argument.

    .. note::
        Only `torch.quint8` is supported for the input data type.


    Attributes:
        weight (Tensor):     packed tensor derived from the learnable weight
                             parameter.
        scale (Tensor):      scalar for the output scale
        zero_point (Tensor): scalar for the output zero point

    See :class:`~torch.nn.Conv2d` for other attributes.

    Examples::

        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_QENGINE)
        >>> # With square kernels and equal stride
        >>> m = nn.quantized.Conv2d(16, 33, 3, stride=2)
        >>> # non-square kernels and unequal stride and with padding
        >>> m = nn.quantized.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
        >>> # non-square kernels and unequal stride and with padding and dilation
        >>> m = nn.quantized.Conv2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2), dilation=(3, 1))
        >>> input = torch.randn(20, 16, 50, 100)
        >>> # quantize input to quint8
        >>> # xdoctest: +SKIP
        >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
        >>> output = m(q_input)

    r¤   NrŸ   r¦   r§   r¨   c                 ó®   •— |
|dœ}t        |«      }t        |«      }t        |«      }t        |«      }t        ‰| �  ||||||dt        d«      |||	fi |¤Ž y r¿   )r   r>   rQ   rÂ   s                €r   r9   zConv2d.__init__  sq   ø€ ð %+°UÑ;ˆÜ˜KÓ(ˆÜ�v“ˆÜ˜“.ˆÜ˜“?ˆô 	‰‰ØØØØØØØÜ�!‹HØØØñ	
ð ó	
r'   c                  ó   — y)NÚQuantizedConv2dr   rU   s    r   rÅ   zConv2d._get_name2  rÆ   r'   rd   re   r   c                 óŽ  — | j                   dk(  r\t        j                  j                  j	                  ||| j
                  | j                  | j                  | j                  «      | _	        y t        j                  j                  j	                  ||| j
                  t        d«      | j                  | j                  «      | _	        y rÈ   )r6   rC   r   rÉ   Úconv2d_prepackr2   r   r3   r4   rË   r   rh   s      r   rI   zConv2d.set_weight_bias5  rÌ   r'   c                 ó6   — | j                   j                  «       S r+   ©rË   ÚunpackrU   s    r   rW   zConv2d._weight_bias?  ó   € Ø×"Ñ"×)Ñ)Ó+Ð+r'   c                 ó(   — | j                  «       d   S rÑ   rÒ   rU   s    r   r^   zConv2d.weightB  rÓ   r'   c                 ó(   — | j                  «       d   S rÕ   rÒ   rU   s    r   r5   zConv2d.biasE  rÓ   r'   c                 óT  — t        |j                  «      dk7  rt        d«      ‚| j                  dk7  r7t	        | j
                  «      }t        j                  ||| j                  ¬«      }t        j                  j                  || j                  | j                  | j                  «      S )Nrv   ú#Input shape must be `(N, C, H, W)`!r   rØ   )r"   rÚ   r?   r6   r&   r   rÛ   rÜ   r   rÉ   Úconv2drË   r<   r=   rÞ   s      r   rà   zConv2d.forwardH  sŠ   € ô ˆu�{‰{Ó˜qÒ ÜÐBÓCÐCØ×Ñ Ò'Ü/FÀtÇ|Á|Ó/TÐ,Ü—E‘EØÐ7¸d×>OÑ>OôˆEô �}‰}×#Ñ#Ø�4×&Ñ&¨¯
©
°D·O±Oó
ð 	
r'   c                 ó2   — t         j                  | ||¬«      S râ   rã   rä   s      r   rª   zConv2d.from_floatV  rå   r'   r±   r²   )!r¥   r³   r´   ræ   r†   r   r¤   r   r„   rç   rè   ÚConvBn2drŸ   r‡   rê   Ú
ConvReLU2dr¦   Ú	ConvAdd2dr§   ÚConvAddReLU2dr¨   r9   rÅ   rC   rí   rI   rW   r^   r5   rà   r·   rª   r¹   rº   s   @r   r   r   á  s  ø… ñ$ðL 02¯y©y€M�8˜D §¡™OÑ,Ó8Ø?E¿¹Ð˜H T¨"¯)©)¡_°tÑ%;Ñ<ÓNØ>A¿n¹nÐ˜8 D¨¯©¡O°dÑ$:Ñ;ÓLØ:=¿-¹-Ð˜( 4¨¯©Ñ#6Ñ7ÓGØCF×CTÑCTÐ˜x¨¨S×->Ñ->Ñ(?Ñ@ÓTð ØØØØØØØõ"
òH!ð §¡ð °%·,±,ÀÑ2Eð È$ó ò,ò&ò&ò
ð ò	
ó ô	
r'   r   c                   óâ  ‡ — e Zd ZU dZej
                  Zeeej
                        e	d<   e
j                  Zeeej                     dz     e	d<   ej                  Zeeej                     dz     e	d<   dZeeej                     dz     e	d<   dZeeej                     dz     e	d<   	 	 	 	 	 	 	 	 dˆ fd„	Zd	„ Zd
ej,                  dej,                  dz  ddfd„Zd„ Zd„ Zd„ Zd„ Zedd„«       Zˆ xZS )r   aÍ  Applies a 3D convolution over a quantized input signal composed of
    several quantized input planes.

    For details on input arguments, parameters, and implementation see
    :class:`~torch.nn.Conv3d`.

    .. note::
        Only `zeros` is supported for the :attr:`padding_mode` argument.

    .. note::
        Only `torch.quint8` is supported for the input data type.


    Attributes:
        weight (Tensor):     packed tensor derived from the learnable weight
                             parameter.
        scale (Tensor):      scalar for the output scale
        zero_point (Tensor): scalar for the output zero point

    See :class:`~torch.nn.Conv3d` for other attributes.

    Examples::

        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_QENGINE)
        >>> # With square kernels and equal stride
        >>> m = nn.quantized.Conv3d(16, 33, 3, stride=2)
        >>> # non-square kernels and unequal stride and with padding
        >>> m = nn.quantized.Conv3d(16, 33, (3, 5, 5), stride=(1, 2, 2), padding=(1, 2, 2))
        >>> # non-square kernels and unequal stride and with padding and dilation
        >>> m = nn.quantized.Conv3d(16, 33, (3, 5, 5), stride=(1, 2, 2), padding=(1, 2, 2), dilation=(1, 2, 2))
        >>> input = torch.randn(20, 16, 56, 56, 56)
        >>> # quantize input to quint8
        >>> # xdoctest: +SKIP
        >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
        >>> output = m(q_input)

    r¤   NrŸ   r¦   r§   r¨   c                 óÎ   •— |	dk(  rt        d«      ‚|
|dœ}t        |«      }t        |«      }t        |«      }t        |«      }t        ‰| �  ||||||dt        d«      |||	fi |¤Ž y )Nr   z*Conv3d does not support reflection paddingr;   Fr   )r�   r	   r>   rQ   rÂ   s                €r   r9   zConv3d.__init__�  s‡   ø€ ð ˜9Ò$Ü Ð!MÓNÐNØ$*°UÑ;ˆÜ˜kÓ*ˆÜ˜“ˆÜ˜'Ó"ˆÜ˜8Ó$ˆô 	‰‰ØØØØØØØÜ�A‹JØØØñ	
ð ó	
r'   c                  ó   — y)NÚQuantizedConv3dr   rU   s    r   rÅ   zConv3d._get_name¶  rÆ   r'   rd   re   r   c                 óŽ  — | j                   dk(  r\t        j                  j                  j	                  ||| j
                  | j                  | j                  | j                  «      | _	        y t        j                  j                  j	                  ||| j
                  t        d«      | j                  | j                  «      | _	        y rÈ   )r6   rC   r   rÉ   Úconv3d_prepackr2   r   r3   r4   rË   r	   rh   s      r   rI   zConv3d.set_weight_bias¹  s†   € Ø×Ñ Ò'Ü"'§)¡)×"5Ñ"5×"DÑ"DØ�1�d—k‘k 4§<¡<°·±ÀÇÁó#ˆDÕô #(§)¡)×"5Ñ"5×"DÑ"DØ�1�d—k‘k¤7¨1£:¨t¯}©}¸d¿k¹kó#ˆDÕr'   c                 ó6   — | j                   j                  «       S r+   rõ   rU   s    r   rW   zConv3d._weight_biasÃ  r÷   r'   c                 ó(   — | j                  «       d   S rÑ   rÒ   rU   s    r   r^   zConv3d.weightÆ  rÓ   r'   c                 ó(   — | j                  «       d   S rÕ   rÒ   rU   s    r   r5   zConv3d.biasÉ  rÓ   r'   c                 óT  — t        |j                  «      dk7  rt        d«      ‚| j                  dk7  r7t	        | j
                  «      }t        j                  ||| j                  ¬«      }t        j                  j                  || j                  | j                  | j                  «      S )Nrw   z&Input shape must be `(N, C, D, H, W)`!r   rØ   )r"   rÚ   r?   r6   r&   r   rÛ   rÜ   r   rÉ   Úconv3drË   r<   r=   rÞ   s      r   rà   zConv3d.forwardÌ  sŠ   € ô ˆu�{‰{Ó˜qÒ ÜÐEÓFÐFØ×Ñ Ò'Ü/FÀtÇ|Á|Ó/TÐ,Ü—E‘EØÐ7¸d×>OÑ>OôˆEô �}‰}×#Ñ#Ø�4×&Ñ&¨¯
©
°D·O±Oó
ð 	
r'   c                 ó2   — t         j                  | ||¬«      S râ   rã   rä   s      r   rª   zConv3d.from_floatÚ  rå   r'   r±   r²   )r¥   r³   r´   ræ   r†   r   r¤   r   r„   rç   rè   ÚConvBn3drŸ   r‡   rê   Ú
ConvReLU3dr¦   r§   r¨   r9   rÅ   rC   rí   rI   rW   r^   r5   rà   r·   rª   r¹   rº   s   @r   r   r   c  s  ø… ñ$ðL 02¯y©y€M�8˜D §¡™OÑ,Ó8Ø?E¿¹Ð˜H T¨"¯)©)¡_°tÑ%;Ñ<ÓNØ>A¿n¹nÐ˜8 D¨¯©¡O°dÑ$:Ñ;ÓLØ=AÐ˜( 4¨¯	©	¡?°TÑ#9Ñ:ÓAØBFÐ˜x¨¨R¯Y©Y©¸$Ñ(>Ñ?ÓFð ØØØØØØØõ$
òL!ð §¡ð °%·,±,ÀÑ2Eð È$ó ò,ò&ò&ò
ð ò	
ó ô	
r'   r   c            	       óÊ   ‡ — e Zd ZU eeej                  j                  j                        e	d<   	 	 d
ˆ fd„	Z
dee   dee   dee   dee   fd„Zedd„«       Zed	„ «       Zˆ xZS )Ú_ConvTransposeNdr¤   c                 ó’   •— |dk7  r"t        d| j                  j                  › �«      ‚||dœ}t        ‰| �  |||||||||	|
|fi |¤Ž y )Nr   z+Only "zeros" padding mode is supported for r;   )r?   rP   r¥   r>   rQ   )r.   r/   r0   r1   r2   r   r3   r@   rA   r4   r5   r6   r7   r8   rJ   rP   s                  €r   r9   z_ConvTransposeNd.__init__í  st   ø€ ð  ˜7Ò"ÜØ=¸d¿n¹n×>UÑ>UÐ=VÐWóð ð %+°UÑ;ˆô 	‰‰ØØØØØØØØØØØñ	
ð ó	
r'   r1   r3   r   r   c                 óØ   — t         j                  j                  t        t           g «      }t        t        |«      «      D ]'  }||   ||   dz
  z  ||   z
  }|j                  |«       Œ) |S rÕ   )rC   rµ   ÚannotaterE   rl   r#   r"   Úappend)r.   r1   r3   r   ÚresÚkdxrÜ   s          r   Ú_input_paddingz_ConvTransposeNd._input_padding  sj   € ô �i‰i× Ñ ¤¤c¡¨BÓ/ˆÜœ˜[Ó)Ó*ò 	ˆCØ˜3‘- ;¨sÑ#3°aÑ#7Ñ8¸7À3¹<ÑGˆCØ�J‰J�s�Oð	ð ˆ
r'   c                 óÞ  — d| j                   z   dz   | j                  j                   z   }t        |«      | j                  urt        |«      ‚t	        |d«      st        d«      ‚|j
                  j                  «       } ||j                  «       |j                  t        j                  k7  rt        d|j                  › �«      ‚t        |j                  j                  «       |«      } | |j                  |j                  |j                  |j                  |j                   |j"                  |j$                  |j&                  du|j(                  |j*                  «
      }|j-                  ||j&                  «       t	        |d«      r'|j.                  j                  t        j                  k(  r|S |j.                  j1                  «       \  }}t        |«      |_        t5        |«      |_        |S )zÙCreates a quantized module from a float module or qparams_dict.
        Args:
            mod (Module): a float module, either produced by torch.ao.quantization
              utilities or provided by the user
        z nnq.rœ   r�   r�   rŽ   Nr”   )r¥   r¤   r„   r�   rž   r�   r^   r8   rC   rF   r   rH   r/   r0   r1   r2   r   rA   r4   r5   r3   r6   rI   r”   r‘   r<   rl   r=   )	r’   r“   r©   Úmsgr•   rN   r–   r—   r˜   s	            r   rª   z_ConvTransposeNd.from_float  s¨  € ð Ø�l‰lñà+ñ,ð ×Ñ×(Ñ(ñ)ð 	ô �‹9˜C×-Ñ-Ñ-Ü  Ó%Ð%Ü�s˜IÔ&Ü Ð!PÓQÐQØ!Ÿk™k×0Ñ0Ó2ÐÙ˜CŸJ™JÔ'Ø×$Ñ$¬¯©Ò3Ü ØBÐCV×C\ÑC\ÐB]Ð^óð ô # 3§:¡:×#3Ñ#3Ó#5Ð7JÓKˆñ Ø�O‰OØ×ÑØ�O‰OØ�J‰JØ�K‰KØ×ÑØ�J‰JØ�H‰H˜DÐ Ø�L‰LØ×Ñó
ˆð 	×Ñ˜g s§x¡xÔ0ä˜Ð6Ô7Ø×*Ñ*×0Ñ0´E·K±KÒ?àˆLà #× ;Ñ ;× MÑ MÓ OÑˆI�vÜ 	Ó*ˆEŒKÜ" 6›{ˆEÔØˆLr'   c                 óâ  —  | |j                   |j                  |j                  |j                  |j                  |j
                  |j                  |j                  du|j                  |j                  |j                  j                  |j                  j                  ¬«      }|j                  «       }|j                  ||j                  «       t        |«      |_        t#        |«      |_        |S )a‹  Create a (fbgemm/qnnpack) quantized module from a reference quantized module
        Args:
            ref_qconvt (Module): a reference quantized  module, either produced by torch.ao.quantization
                                 utilities or provided by the user
            output_scale (float): scale for output Tensor
            output_zero_point (int): zero point for output Tensor
        Nr;   )r/   r0   r1   r2   r   rA   r4   r5   r3   r6   r^   r7   r8   r¬   rI   rH   r<   rl   r=   )r’   Ú
ref_qconvtr®   r¯   r–   rN   s         r   r°   z_ConvTransposeNd.from_referenceO  sÌ   € ñ Ø×"Ñ"Ø×#Ñ#Ø×"Ñ"Ø×ÑØ×ÑØ×%Ñ%Ø×ÑØ�O‰O 4Ð'Ø×ÑØ×#Ñ#Ø×$Ñ$×+Ñ+Ø×#Ñ#×)Ñ)ô
ˆð ×1Ñ1Ó3ˆØ×Ñ˜g z§¡Ô7Ü˜LÓ)ˆŒÜÐ0Ó1ˆÔØˆr'   )NNr²   )r¥   r³   r´   r   r„   r†   ÚmodulesÚconvr)   rç   r9   rE   rl   r  r·   rª   r¸   r°   r¹   rº   s   @r   r  r  ê  s�   ø… Ø˜D §¡§¡×!8Ñ!8Ñ9Ñ:Ó:ð Øõ$
ðLØ ™9ðØ04°S±	ðØDHÈÁIðà	ˆc‰óð ò0ó ð0ðd ñó ôr'   r  c                   óê   ‡ — e Zd ZU dZej
                  Zeeej
                        e	d<   	 	 	 	 	 	 	 	 	 dˆ fd„	Z
d„ Zdej                  dej                  dz  ddfd	„Zd
„ Zd„ Zd„ Zd„ Zed„ «       Zˆ xZS )r   aÏ  Applies a 1D transposed convolution operator over an input image
    composed of several input planes.
    For details on input arguments, parameters, and implementation see
    :class:`~torch.nn.ConvTranspose1d`.

    .. note:: Currently only the QNNPACK engine is implemented.
        Please, set the `torch.backends.quantized.engine = 'qnnpack'`

    For special notes, please, see :class:`~torch.ao.nn.quantized.Conv1d`

    Attributes:
        weight (Tensor):     packed tensor derived from the learnable weight
                             parameter.
        scale (Tensor):      scalar for the output scale
        zero_point (Tensor): scalar for the output zero point
    See :class:`~torch.nn.ConvTranspose2d` for other attributes.

    Examples::

        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_QENGINE)
        >>> torch.backends.quantized.engine = 'qnnpack'
        >>> from torch.ao.nn import quantized as nnq
        >>> # With square kernels and equal stride
        >>> m = nnq.ConvTranspose1d(16, 33, 3, stride=2)
        >>> # non-square kernels and unequal stride and with padding
        >>> m = nnq.ConvTranspose1d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
        >>> input = torch.randn(20, 16, 50)
        >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
        >>> output = m(q_input)
        >>> # exact output size can be also specified as an argument
        >>> input = torch.randn(1, 16, 12)
        >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
        >>> downsample = nnq.Conv1d(16, 16, 3, stride=2, padding=1)
        >>> upsample = nnq.ConvTranspose1d(16, 16, 3, stride=2, padding=1)
        >>> h = downsample(q_input)
        >>> h.size()
        torch.Size([1, 16, 6])
        >>> # xdoctest: +SKIP("FIXME: output_size is not a parameter)
        >>> output = upsample(h, output_size=input.size())
        >>> output.size()
        torch.Size([1, 16, 12])
    r¤   Nc                 ó²   •— ||dœ}t        |«      }t        |«      }t        |«      }t        |	«      }	t        |«      }t        ‰| �  ||||||	d||||
fi |¤Ž y ©Nr;   T)r   r>   r9   ©r.   r/   r0   r1   r2   r   rA   r4   r5   r3   r6   r7   r8   rJ   rP   s                 €r   r9   zConvTranspose1d.__init__›  óx   ø€ ð %+°UÑ;ˆÜ˜kÓ*ˆÜ˜“ˆÜ˜'Ó"ˆÜ˜8Ó$ˆÜ  Ó0ˆä‰ÑØØØØØØØØØØØñ	
ð ó	
r'   c                  ó   — y)NÚQuantizedConvTranspose1dr   rU   s    r   rÅ   zConvTranspose1d._get_nameÀ  ó   € Ø)r'   rd   re   r   c           	      óÐ   — t         j                  j                  j                  ||| j                  | j
                  | j                  | j                  | j                  «      | _	        y r+   )
rC   r   rÉ   Úconv_transpose1d_prepackr2   r   rA   r3   r4   rË   rh   s      r   rI   zConvTranspose1d.set_weight_biasÃ  óJ   € Ü#Ÿi™i×1Ñ1×JÑJØØØ�K‰KØ�L‰LØ×ÑØ�M‰MØ�K‰Kó
ˆÕr'   c                 óv   — t         j                  j                  j                  | j                  «      \  }}||fS r+   )rC   r   rÉ   Úconv_transpose1d_unpackrË   rh   s      r   rW   zConvTranspose1d._weight_biasÎ  s/   € Ü�y‰y×"Ñ"×:Ñ:¸4×;NÑ;NÓO‰ˆˆ1Ø�!ˆtˆr'   c                 ó,   — | j                  «       \  }}|S r+   rÒ   ©r.   rd   r   s      r   r^   zConvTranspose1d.weightÒ  ó   € Ø×"Ñ"Ó$‰ˆˆAØˆr'   c                 ó,   — | j                  «       \  }}|S r+   rÒ   ©r.   r   re   s      r   r5   zConvTranspose1d.biasÖ  r.  r'   c                 óÜ   — t        |j                  «      dk7  rt        d«      ‚t        j                  j
                  j                  || j                  | j                  | j                  «      S )Nru   r×   )
r"   rÚ   r?   rC   r   rÉ   Úconv_transpose1drË   r<   r=   ©r.   rß   s     r   rà   zConvTranspose1d.forwardÚ  sU   € ô ˆu�{‰{Ó˜qÒ ÜÐ?Ó@Ð@Ü�y‰y×"Ñ"×3Ñ3Ø�4×&Ñ&¨¯
©
°D·O±Oó
ð 	
r'   c                 ó2   — t         j                  | |||«      S r+   ©r  r°   ©r’   r  r®   r¯   s       r   r°   zConvTranspose1d.from_referenceã  ó   € ä×.Ñ.Ø�˜\Ð+<ó
ð 	
r'   ©	r   r   r   r   Tr   r   NN)r¥   r³   r´   ræ   r†   r   r¤   r   r„   rç   r9   rÅ   rC   rí   rI   rW   r^   r5   rà   r·   r°   r¹   rº   s   @r   r   r   m  ó¢   ø… ñ)ðV 9;×8JÑ8J€M�8˜D ×!3Ñ!3Ñ4Ñ5ÓJð ØØØØØØØØõ#
òJ*ð	
 §¡ð 	
°%·,±,ÀÑ2Eð 	
È$ó 	
òòòò
ð ñ
ó ô
r'   r   c                   óê   ‡ — e Zd ZU dZej
                  Zeeej
                        e	d<   	 	 	 	 	 	 	 	 	 dˆ fd„	Z
d„ Zdej                  dej                  dz  ddfd	„Zd
„ Zd„ Zd„ Zd„ Zed„ «       Zˆ xZS )r   a~  Applies a 2D transposed convolution operator over an input image
    composed of several input planes.
    For details on input arguments, parameters, and implementation see
    :class:`~torch.nn.ConvTranspose2d`.

    For special notes, please, see :class:`~torch.ao.nn.quantized.Conv2d`

    Attributes:
        weight (Tensor):     packed tensor derived from the learnable weight
                             parameter.
        scale (Tensor):      scalar for the output scale
        zero_point (Tensor): scalar for the output zero point
    See :class:`~torch.nn.ConvTranspose2d` for other attributes.

    Examples::

        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_QENGINE)
        >>> # QNNPACK or FBGEMM as backend
        >>> torch.backends.quantized.engine = 'qnnpack'
        >>> # With square kernels and equal stride
        >>> import torch.ao.nn.quantized as nnq
        >>> m = nnq.ConvTranspose2d(16, 33, 3, stride=2)
        >>> # non-square kernels and unequal stride and with padding
        >>> m = nnq.ConvTranspose2d(16, 33, (3, 5), stride=(2, 1), padding=(4, 2))
        >>> input = torch.randn(20, 16, 50, 100)
        >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
        >>> output = m(q_input)
        >>> # exact output size can be also specified as an argument
        >>> input = torch.randn(1, 16, 12, 12)
        >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
        >>> downsample = nnq.Conv2d(16, 16, 3, stride=2, padding=1)
        >>> upsample = nnq.ConvTranspose2d(16, 16, 3, stride=2, padding=1)
        >>> h = downsample(q_input)
        >>> h.size()
        torch.Size([1, 16, 6, 6])
        >>> # xdoctest: +SKIP("FIXME: output_size is not a parameter)
        >>> output = upsample(h, output_size=input.size())
        >>> output.size()
        torch.Size([1, 16, 12, 12])
    r¤   Nc                 ó²   •— ||dœ}t        |«      }t        |«      }t        |«      }t        |	«      }	t        |«      }t        ‰| �  ||||||	d||||
fi |¤Ž y r!  )r   r>   r9   r"  s                 €r   r9   zConvTranspose2d.__init__  sv   ø€ ð %+°UÑ;ˆÜ˜KÓ(ˆÜ�v“ˆÜ˜“.ˆÜ˜“?ˆÜ˜~Ó.ˆä‰ÑØØØØØØØØØØØñ	
ð ó	
r'   c                  ó   — y)NÚQuantizedConvTranspose2dr   rU   s    r   rÅ   zConvTranspose2d._get_name;  r&  r'   rd   re   r   c           	      óÐ   — t         j                  j                  j                  ||| j                  | j
                  | j                  | j                  | j                  «      | _	        y r+   )
rC   r   rÉ   Úconv_transpose2d_prepackr2   r   rA   r3   r4   rË   rh   s      r   rI   zConvTranspose2d.set_weight_bias>  r)  r'   c                 óv   — t         j                  j                  j                  | j                  «      \  }}||fS r+   )rC   r   rÉ   Úconv2d_unpackrË   rh   s      r   rW   zConvTranspose2d._weight_biasI  rÏ   r'   c                 ó,   — | j                  «       \  }}|S r+   rÒ   r-  s      r   r^   zConvTranspose2d.weightM  r.  r'   c                 ó,   — | j                  «       \  }}|S r+   rÒ   r0  s      r   r5   zConvTranspose2d.biasQ  r.  r'   c                 óÈ   — t        |j                  «      dk7  rt        d«      ‚t        j                  j                  || j                  | j                  | j                  «      S )Nrv   rû   )	r"   rÚ   r?   r   rÉ   Úconv_transpose2drË   r<   r=   r3  s     r   rà   zConvTranspose2d.forwardU  sO   € ô ˆu�{‰{Ó˜qÒ ÜÐBÓCÐCÜ�}‰}×-Ñ-Ø�4×&Ñ&¨¯
©
°D·O±Oó
ð 	
r'   c                 ó2   — t         j                  | |||«      S r+   r5  r6  s       r   r°   zConvTranspose2d.from_reference^  r7  r'   r8  )r¥   r³   r´   ræ   r†   r   r¤   r   r„   rç   r9   rÅ   rC   rí   rI   rW   r^   r5   rà   r·   r°   r¹   rº   s   @r   r   r   ê  s¢   ø… ñ'ðR 9;×8JÑ8J€M�8˜D ×!3Ñ!3Ñ4Ñ5ÓJð ØØØØØØØØõ#
òJ*ð	
 §¡ð 	
°%·,±,ÀÑ2Eð 	
È$ó 	
òòòò
ð ñ
ó ô
r'   r   c                   óê   ‡ — e Zd ZU dZej
                  Zeeej
                        e	d<   	 	 	 	 	 	 	 	 	 dˆ fd„	Z
d„ Zdej                  dej                  dz  ddfd	„Zd
„ Zd„ Zd„ Zd„ Zed„ «       Zˆ xZS )r   aó  Applies a 3D transposed convolution operator over an input image
    composed of several input planes.
    For details on input arguments, parameters, and implementation see
    :class:`~torch.nn.ConvTranspose3d`.

    .. note:: Currently only the FBGEMM engine is implemented.
        Please, set the `torch.backends.quantized.engine = 'fbgemm'`

    For special notes, please, see :class:`~torch.ao.nn.quantized.Conv3d`

    Attributes:
        weight (Tensor):     packed tensor derived from the learnable weight
                             parameter.
        scale (Tensor):      scalar for the output scale
        zero_point (Tensor): scalar for the output zero point
    See :class:`~torch.nn.ConvTranspose3d` for other attributes.

    Examples::

        >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_QENGINE)
        >>> torch.backends.quantized.engine = 'fbgemm'
        >>> from torch.ao.nn import quantized as nnq
        >>> # With cubic kernels and equal stride
        >>> m = nnq.ConvTranspose3d(16, 33, 3, stride=2)
        >>> # non-cubic kernels and unequal stride and with padding
        >>> m = nnq.ConvTranspose3d(16, 33, (3, 3, 5), stride=(2, 1, 1), padding=(4, 2, 2))
        >>> input = torch.randn(20, 16, 50, 100, 100)
        >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
        >>> output = m(q_input)
        >>> # exact output size can be also specified as an argument
        >>> input = torch.randn(1, 16, 12, 12, 12)
        >>> q_input = torch.quantize_per_tensor(input, scale=1.0, zero_point=0, dtype=torch.quint8)
        >>> downsample = nnq.Conv3d(16, 16, 3, stride=2, padding=1)
        >>> upsample = nnq.ConvTranspose3d(16, 16, 3, stride=2, padding=1)
        >>> h = downsample(q_input)
        >>> h.size()
        torch.Size([1, 16, 6, 6, 6])
        >>> # xdoctest: +SKIP("FIXME: output_size is not a parameter)
        >>> output = upsample(h, output_size=input.size())
        >>> output.size()
        torch.Size([1, 16, 12, 12, 12])
    r¤   Nc                 ó²   •— ||dœ}t        |«      }t        |«      }t        |«      }t        |	«      }	t        |«      }t        ‰| �  ||||||	d||||
fi |¤Ž y r!  )r	   r>   r9   r"  s                 €r   r9   zConvTranspose3d.__init__“  r#  r'   c                  ó   — y)NÚQuantizedConvTranspose3dr   rU   s    r   rÅ   zConvTranspose3d._get_name¸  r&  r'   rd   re   r   c           	      óÐ   — t         j                  j                  j                  ||| j                  | j
                  | j                  | j                  | j                  «      | _	        y r+   )
rC   r   rÉ   Úconv_transpose3d_prepackr2   r   rA   r3   r4   rË   rh   s      r   rI   zConvTranspose3d.set_weight_bias»  r)  r'   c                 óv   — t         j                  j                  j                  | j                  «      \  }}||fS r+   )rC   r   rÉ   Úconv3d_unpackrË   rh   s      r   rW   zConvTranspose3d._weight_biasÆ  rÏ   r'   c                 ó,   — | j                  «       \  }}|S r+   rÒ   r-  s      r   r^   zConvTranspose3d.weightÊ  r.  r'   c                 ó,   — | j                  «       \  }}|S r+   rÒ   r0  s      r   r5   zConvTranspose3d.biasÎ  r.  r'   c                 óÈ   — t        |j                  «      dk7  rt        d«      ‚t        j                  j                  || j                  | j                  | j                  «      S )Nrw   z&Input shape must be `(N, C, T, H, W)`!)	r"   rÚ   r?   r   rÉ   Úconv_transpose3drË   r<   r=   r3  s     r   rà   zConvTranspose3d.forwardÒ  sO   € ô ˆu�{‰{Ó˜qÒ ÜÐEÓFÐFÜ�}‰}×-Ñ-Ø�4×&Ñ&¨¯
©
°D·O±Oó
ð 	
r'   c                 ó2   — t         j                  | |||«      S r+   r5  r6  s       r   r°   zConvTranspose3d.from_referenceÛ  r7  r'   r8  )r¥   r³   r´   ræ   r†   r   r¤   r   r„   rç   r9   rÅ   rC   rí   rI   rW   r^   r5   rà   r·   r°   r¹   rº   s   @r   r   r   e  r9  r'   r   )+ræ   Útypingr   r   rC   Útorch.ao.nn.intrinsicÚaor†   Ú	intrinsicrê   Útorch.ao.nn.intrinsic.qatÚqatrè   Útorch.nnÚtorch.nn.functionalÚ
functionalrÛ   Ú
torch._opsr   Útorch.nn.common_typesr   Útorch.nn.modules.utilsr   r   r	   Útorch.nn.utilsr
   Úutilsr   r   Ú__all__rB   rE   rl   r&   r)   r   r   r   r  r   r   r   r   r'   r   ú<module>rc     sß   ðá %ç $ã ß #Ó #ß *Ö *Ý ß Ð Ý Ý +ß :Ñ :Ý /ç <ò€ð ˜yÐ)Ð ð, T¨#¡Yð ,°4¸±9ó ,ôuÐ%ô uôp	
ˆWô 
ôD
ˆWô 
ôDA
ˆWô A
ôN@�wô @ôFz
Ð&ô z
ôzx
Ð&ô x
ôvz
Ð&õ z
r'   