Ë
    P/æj"6  ã                   ó´  — U d dl Z d dlmZmZmZmZmZmZ d dlZd dl	m
c m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
c mc mc mZ d dlm
c mc mc mc m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
c mc mZ d dlm
c mc mc mZ  d dl!m
c mc mc m"Z# d dl$Zd dl%mc m&Z' d dlmZ d dl(m)Z)m*Z* d dl+m,Z,m-Z- d dl.m/Z/ d dl0m1Z1 g d¢Z2e-ejf                  e,ejh                  ejj                  e#jj                  ejl                  e#jl                  ejn                  e#jn                  ejp                  e#jp                  ejr                  e#jr                  ejt                  e#jt                  ejv                  e#jv                  ejx                  e#jx                  ejz                  e#jz                  ej|                  e#j|                  ej~                  e#j~                  ej€                  e#j€                  ej‚                  e#j‚                  iZBeeef   eCd	<   i e-ejf                  “e,ejh                  “ejˆ                  ejˆ                  “ejŠ                  ejŠ                  “ejŒ                  ejŒ                  “ejl                  ejl                  “ejn                  ejn                  “ejp                  ejp                  “ejr                  ejr                  “ejt                  ejt                  “ejv                  ejv                  “ejŽ                  ejŽ                  “ejx                  ejx                  “ejz                  ejz                  “ej�                  ej�                  “ej’                  ej’                  “ej”                  ej”                  “i ej–                  ej–                  “ej˜                  ej˜                  “ejš                  ejš                  “ejœ                  ejœ                  “ejž                  j                   j¢                  ejj                  “ejj                  ejj                  “ej¤                  ej¤                  “ejŒ                  ejŒ                  “ej¦                  ej¦                  “ej¨                  ejª                  “ej¬                  ej¬                  “ej®                  ej®                  “ej°                  ej°                  “ej²                  ej²                  “ej´                  ej´                  “ej¶                  ej¶                  “ej¸                  ej¸                  “¥i ejº                  ejº                  “ej¼                  ej¼                  “ej¾                  ej¾                  “ejÀ                  ejl                  “ejÂ                  ejn                  “ejÄ                  ejp                  “ejÆ                  ej°                  “ejÈ                  ej²                  “ejÊ                  ej´                  “ej²                  ej²                  “ej´                  ej´                  “ejº                  ejº                  “ejÌ                  ejj                  “ejj                  ejj                  “ejn                  ejn                  “ejp                  ejp                  “¥Zgeeef   eCd
<   ejn                  ejn                  ejp                  ejp                  ejj                  ejj                  ejž                  j                   j¢                  ejj                  ejÀ                  ejÀ                  ejÂ                  ejÂ                  ejÄ                  ejÄ                  ejÆ                  ejÆ                  ejÈ                  ejÈ                  ejÊ                  ejÊ                  ej²                  ej²                  ej´                  ej´                  ejº                  ejº                  ejÌ                  ejÌ                  iZheeef   eCd<   ej|                  e j|                  ejj                  e jj                  ejj                  e jj                  ejž                  j                   j¢                  e jj                  ej‚                  e j‚                  ejÒ                  e jÒ                  ej~                  e j~                  ej€                  e j€                  ejº                  ejº                  ejz                  ejz                  ejx                  ejx                  iZjeeef   eCd<   ejÖ                  hZlee   eCd<   e'jÚ                  ejÜ                  j(                  jÚ                  e'jÞ                  ejÜ                  j(                  jÞ                  e'jà                  ejÜ                  j(                  jà                  e'jâ                  ejÜ                  j(                  jâ                  e'jä                  ejÜ                  j(                  jä                  e'jæ                  ejÜ                  j(                  jæ                  iZteeeeuf   ef   eCd<   ejì                  e)ejî                  e)ejð                  e)ejò                  e*iZzeeef   eCd<   ejj                  ejö                  j(                  jj                  iZ|eeef   eCd<   ejj                  ejö                  j(                  j.                  jj                  iZ}eeef   eCd<   dee   fd„Z~deeef   fd„Zdeeef   fd„Z€deeef   fd„Z�deeef   fd„Z‚	 	 d*dedeeeef      deƒdefd„Z„	 d+dedeeeef      defd„Z…deeef   fd„Z†deeef   fd„Z‡deeef   fd „Zˆdeeef   fd!„Z‰dee   fd"„ZŠdee   fd#„Z‹deeeeuf   ef   fd$„ZŒd%eeeuf   defd&„Z�d'ej                  �j                  dee   fd(„Z�d'ej                  �j                  deƒfd)„Z�y),é    N)ÚAnyÚCallableÚDictÚOptionalÚSetÚUnion)Únn)Ú+default_fixed_qparams_range_0to1_fake_quantÚ.default_fixed_qparams_range_neg1to1_fake_quant)ÚDeQuantStubÚ	QuantStub)Úget_combined_dict)Útype_before_parametrizations)Ú.DEFAULT_REFERENCE_STATIC_QUANT_MODULE_MAPPINGSÚ$DEFAULT_STATIC_QUANT_MODULE_MAPPINGSÚDEFAULT_QAT_MODULE_MAPPINGSÚ%DEFAULT_DYNAMIC_QUANT_MODULE_MAPPINGSÚ,DEFAULT_FLOAT_TO_QUANTIZED_OPERATOR_MAPPINGSÚ"DEFAULT_MODULE_TO_ACT_POST_PROCESSÚ+DEFAULT_STATIC_SPARSE_QUANT_MODULE_MAPPINGSÚ,DEFAULT_DYNAMIC_SPARSE_QUANT_MODULE_MAPPINGSÚno_observer_setÚ(get_default_static_quant_module_mappingsÚ2get_default_static_quant_reference_module_mappingsÚ*get_embedding_static_quant_module_mappingsÚ/get_default_static_sparse_quant_module_mappingsÚget_static_quant_module_classÚget_dynamic_quant_module_classÚget_default_qat_module_mappingsÚ!get_embedding_qat_module_mappingsÚ)get_default_dynamic_quant_module_mappingsÚ0get_default_dynamic_sparse_quant_module_mappingsÚ$get_default_qconfig_propagation_listÚ&get_default_compare_output_module_listÚ0get_default_float_to_quantized_operator_mappingsÚget_quantized_operatorr   r   r   r   Ú_INCLUDE_QCONFIG_PROPAGATE_LISTr   r   r   r   Úreturnc                  ón   — t         j                  j                  t         j                  j                  h} | S )z8These modules cannot have observers inserted by default.)r	   ÚquantizableÚLSTMÚMultiheadAttention)Úno_observerss    ún/root/repos/pocs/video-evals/.venv/lib/python3.12/site-packages/torch/ao/quantization/quantization_mappings.pyr   r   Ñ   s&   € ä—N‘N×'Ñ'¬¯©×)JÑ)JÐK€LØÐó    c                  ó4   — t        j                  t        «      S )z8Get module mapping for post training static quantization)ÚcopyÚdeepcopyr   © r/   r.   r   r   ×   s   € ä�=‰=Ô=Ó>Ð>r/   c                  ó4   — t        j                  t        «      S )zBGet reference module mapping for post training static quantization)r1   r2   r   r3   r/   r.   r   r   Ü   s   € ä�=‰=ÔGÓHÐHr/   c                  ó¼   — t        j                  t        «      } t        j                  | t
        j                  <   t        j                  | t
        j                  <   | S )z7Get module mapping, including mapping for embedding QAT)r1   r2   r   ÚnnqÚEmbeddingBagÚnnqatÚ	Embedding©Úmappings    r.   r   r   á   s>   € ä�m‰mÔ@ÓA€GÜ"%×"2Ñ"2€GŒE×ÑÑÜ"Ÿ}™}€GŒE�O‰OÑØ€Nr/   c                  ó4   — t        j                  t        «      S )z?Get module mapping for post training static sparse quantization)r1   r2   r   r3   r/   r.   r   r   é   s   € ä�=‰=ÔDÓEÐEr/   Úfloat_module_classÚadditional_static_quant_mappingÚis_referencec                 ó¸   — |€i }t        |rt        nt        |«      }|j                  | d«      }|€J dt	        | «      › �dz   «       ‚t        j                  |«      S )zen Get the statically quantized module class corresponding to
    the floating point module class
    NúFloating point module class ú5 does not have a corresponding quantized module class)r   r   r   ÚgetÚstrr1   r2   )r=   r>   r?   Úall_mappingsÚstatic_quant_module_classs        r.   r   r   î   s}   € ð 'Ð.Ø*,Ð'Ü$áõ 	7ä1Ø'ó	€Lð !-× 0Ñ 0Ð1CÀTÓ JÐØ$Ð0ð Ø
&¤sÐ+=Ó'>Ð&?Ð@Ø
Añ	BóÐ0ô �=‰=Ð2Ó3Ð3r/   Ú additional_dynamic_quant_mappingc                 ó¨   — |€i }t        t        |«      }|j                  | d«      }|€J dt        | «      › �dz   «       ‚t	        j
                  |«      S )zfn Get the dynamically quantized module class corresponding to
    the floating point module class
    NrA   rB   )r   r   rC   rD   r1   r2   )r=   rG   rE   Údynamic_quant_module_classs       r.   r   r     su   € ð (Ð/Ø+-Ð(Ü$Ü-Ð/Oó€Lð ".×!1Ñ!1Ð2DÀdÓ!KÐØ%Ð1ð Ø
&¤sÐ+=Ó'>Ð&?Ð@Ø
Añ	BóÐ1ô �=‰=Ð3Ó4Ð4r/   c                  ó4   — t        j                  t        «      S )z:Get default module mapping for quantization aware training)r1   r2   r   r3   r/   r.   r   r     s   € ä�=‰=Ô4Ó5Ð5r/   c                  ó¼   — t        j                  t        «      } t        j                  | t
        j                  <   t        j                  | t
        j                  <   | S )z‹Get module mapping for quantization aware training
    This is includes default values in addition to
    enabling qat for embeddings.
    )r1   r2   r   r8   r7   r	   r9   r:   s    r.   r    r      s>   € ô
 �m‰mÔ7Ó8€GÜ$×1Ñ1€GŒB�O‰OÑÜ!ŸO™O€GŒB�L‰LÑØ€Nr/   c                  ó   — t         S )z9Get module mapping for post training dynamic quantization)r   r3   r/   r.   r!   r!   *  s   € ä0Ð0r/   c                  ó   — t         S )z@Get module mapping for post training dynamic sparse quantization)r   r3   r/   r.   r"   r"   /  s   € ä7Ð7r/   c                  óì   — t        t        j                  «       «      t        t        j                  «       «      z  t        t        j                  «       «      z  t
        z  } t        j                  | «      S )z_Get the default list of module types that we'll attach qconfig
    attribute to in prepare
    )Úsetr   Úkeysr   r   r'   r1   r2   )Ú#QCONFIG_PROPAGATE_MODULE_CLASS_LISTs    r.   r#   r#   4  se   € ô
 	Ô0×5Ñ5Ó7Ó8Ü
Ô)×.Ñ.Ó0Ó
1ñ	2ä
Ô3×8Ñ8Ó:Ó
;ñ	<ô *ñ	*ð (ô �=‰=Ð<Ó=Ð=r/   c                  ó   — t        t        j                  «       «      t        t        j                  «       «      z  t        t        j                  «       «      z  t        t        j                  «       «      z  t        t        j                  «       «      z  t        t        j                  «       «      z  t        z  } t        j                  | «      S )zSGet list of module class types that we will record output
    in numeric suite
    )	rO   r   Úvaluesr   r   rP   r'   r1   r2   )Ú.NUMERIC_SUITE_COMPARE_MODEL_OUTPUT_MODULE_LISTs    r.   r$   r$   A  s°   € ô
 	Ô0×7Ñ7Ó9Ó:Ü
Ô)×0Ñ0Ó2Ó
3ñ	4ä
Ô3×:Ñ:Ó<Ó
=ñ	>ô Ô2×7Ñ7Ó9Ó
:ñ	;ô Ô)×.Ñ.Ó0Ó
1ñ		2ô
 Ô3×8Ñ8Ó:Ó
;ñ	<ô *ñ	*ð 3ô �=‰=ÐGÓHÐHr/   c                  ó4   — t        j                  t        «      S ©N)r1   r2   r   r3   r/   r.   r%   r%   Q  s   € ô �=‰=ÔEÓFÐFr/   Úfloat_opc                 ó^   — t         j                  | d«      }|€J dt        | «      › d�«       ‚|S )z>Get the quantized operator corresponding to the float operatorNz	Operator z) does not have corresponding quantized op)r   rC   rD   )rW   Úquantized_ops     r.   r&   r&   X  s@   € ä?×CÑCÀHÈdÓS€LàÐ ðLà	”3�x“=�/Ð!JÐKóLØ àÐr/   Úmodulec                 ó@   — t         j                  t        | «      d«      S )zÝGet the special activation post process for `module`, this has
    higher priority than the activation post process in `qconfig`
    e.g.
    input: torch.nn.Sigmoid
    output: default_affine_fixed_qparam_fake_quant
    N)r   rC   r   ©rZ   s    r.   Ú_get_special_act_post_processr]   a  s!   € ô .×1Ñ1Ü$ VÓ,¨dóð r/   c                 ó@   — | j                   xr t        | «      t        v S rV   )ÚtrainingÚtyper   r\   s    r.   Ú_has_special_act_post_processra   m  s   € Ø�?‰?ÒQœt F›|Ô/QÐQÐQr/   )NFrV   )‘r1   Útypingr   r   r   r   r   r   ÚtorchÚtorch.ao.nnÚaor	   Úao_nnÚtorch.ao.nn.intrinsicÚ	intrinsicÚnniÚtorch.ao.nn.intrinsic.qatÚqatÚnniqatÚtorch.ao.nn.intrinsic.quantizedÚ	quantizedÚnniqÚ'torch.ao.nn.intrinsic.quantized.dynamicÚdynamicÚnniqdÚtorch.ao.nn.qatr8   Útorch.ao.nn.qat.dynamicÚnnqatdÚtorch.ao.nn.quantizedr6   Útorch.ao.nn.quantized.dynamicÚnnqdÚtorch.ao.nn.quantized.referenceÚ	referenceÚnnqrÚtorch.ao.nn.sparseÚtorch.nn.functionalÚ
functionalÚFÚ#torch.ao.quantization.fake_quantizer
   r   Útorch.ao.quantization.stubsr   r   Útorch.ao.quantization.utilsr   Útorch.nn.utils.parametrizer   Ú__all__ÚQuantizeÚ
DeQuantizeÚLinearÚConv1dÚConv2dÚConv3dÚConvTranspose1dÚConvTranspose2dÚConvTranspose3dr9   r7   ÚGRUCellÚLSTMCellÚRNNCellr+   r   Ú__annotations__ÚBatchNorm2dÚBatchNorm3dÚDropoutÚELUÚ	GroupNormÚ	HardswishÚInstanceNorm1dÚInstanceNorm2dÚInstanceNorm3dÚ	LayerNormÚ	LeakyReLUÚmodulesÚlinearÚNonDynamicallyQuantizableLinearÚReLU6ÚPReLUÚFloatFunctionalÚQFunctionalÚBNReLU2dÚBNReLU3dÚ
ConvReLU1dÚ
ConvReLU2dÚ
ConvReLU3dÚ	ConvAdd2dÚConvAddReLU2dÚ
LinearReLUÚLinearLeakyReLUÚ
LinearTanhÚConvBn1dÚConvBn2dÚConvBn3dÚConvBnReLU1dÚConvBnReLU2dÚConvBnReLU3dÚ
LinearBn1dr   r   ÚGRUr   Ú
Sequentialr'   ÚeluÚopsÚ	hardswishÚinstance_normÚ
layer_normÚ
leaky_reluÚdropoutr   rD   ÚHardsigmoidÚSigmoidÚSoftmaxÚTanhr   Úsparser   r   r   r   r   r   r   Úboolr   r   r   r    r!   r"   r#   r$   r%   r&   ÚModuler]   ra   r3   r/   r.   ú<module>rÅ      s·
  ðÜ ß <× <ã ß Ð ß #Ó #ß *Ö *ß .Ö .ß 7× 7Ñ 7ß Ó ß (Ö (ß #Ó #ß ,Ö ,ß .Ö .ó ß Ð Ý ÷÷ ?Ý 9Ý Cò€ð8 ˆs�|‰|Ø�—‘Ø‡I�Iˆt�{‰{Ø‡I�Iˆt�{‰{Ø‡I�Iˆt�{‰{Ø‡I�Iˆt�{‰{Ø×Ñ˜×,Ñ,Ø×Ñ˜×,Ñ,Ø×Ñ˜×,Ñ,Ø‡L�L�$—.‘.Ø‡O�O�T×&Ñ&Ø‡J�J�—‘Ø‡K�K�—‘Ø‡J�J�—‘Ø‡G�GˆT�Y‰YðGÐ .°°X¸s°]Ñ0Có ð&6=Øˆs�|‰|ð6=à�—‘ð6=ð ‡N�N�C—O‘Oð6=ð ‡N�N�C—O‘Oð	6=ð
 ‡J�J�—‘ð6=ð ‡I�Iˆs�z‰zð6=ð ‡I�Iˆs�z‰zð6=ð ‡I�Iˆs�z‰zð6=ð ×Ñ˜×+Ñ+ð6=ð ×Ñ˜×+Ñ+ð6=ð ×Ñ˜×+Ñ+ð6=ð ‡F�FˆC�G‰Gð6=ð ‡L�L�#—-‘-ð6=ð ‡O�O�S×%Ñ%ð6=ð ‡L�L�#—-‘-ð6=ð  ‡L�L�#—-‘-ð!6=ð" ×Ñ�s×)Ñ)ñ#6=ð$ ×Ñ�s×)Ñ)ð%6=ð& ×Ñ�s×)Ñ)ð'6=ð( ‡L�L�#—-‘-ð)6=ð* ‡L�L�#—-‘-ð+6=ð, ‡J�J×Ñ×5Ñ5°s·z±zð-6=ð. ‡I�Iˆs�z‰zð/6=ð0 ‡H�Hˆc�i‰ið16=ð2 ‡J�J�—‘ð36=ð4 ‡H�Hˆc�i‰ið56=ð8 ×Ñ˜Ÿ™ð96=ð< ‡L�L�$—-‘-ð=6=ð> ‡L�L�$—-‘-ð?6=ð@ ‡N�N�D—O‘OðA6=ðB ‡N�N�D—O‘OðC6=ðD ‡N�N�D—O‘OðE6=ðF ‡M�M�4—>‘>ðG6=ðH ×Ñ�t×)Ñ)òI6=ðJ ‡N�N�D—O‘OðK6=ðL ×Ñ˜×-Ñ-ðM6=ðN ‡N�N�D—O‘OðO6=ðP ‡O�O�S—Z‘ZðQ6=ðR ‡O�O�S—Z‘ZðS6=ðT ‡O�O�S—Z‘ZðU6=ðV ×Ñ˜Ÿ™ðW6=ðX ×Ñ˜Ÿ™ðY6=ðZ ×Ñ˜Ÿ™ð[6=ð\ ×Ñ�t—‘ð]6=ð^ ×Ñ�t—‘ð_6=ð` ×Ñ�t—‘ða6=ðb ×Ñ�s—z‘zðc6=ðf 
‡L�L�#—*‘*ðg6=ðh 
‡L�L�#—*‘*ði6=ðj 
‡L�L�#—*‘*ñk6=Ð $ d¨8°S¨=Ñ&9ó 6ðt ‡I�Iˆu�|‰|Ø‡I�Iˆu�|‰|Ø‡I�Iˆu�|‰|Ø‡J�J×Ñ×5Ñ5°u·|±|à‡L�L�&—/‘/Ø‡L�L�&—/‘/Ø‡L�L�&—/‘/Ø×Ñ�f×)Ñ)Ø×Ñ�f×)Ñ)Ø×Ñ�f×)Ñ)Ø‡N�N�F×%Ñ%Ø‡N�N�F×%Ñ%Ø‡N�N�F×%Ñ%Ø‡N�N�F×%Ñ%ð4Ð ˜T (¨C -Ñ0ó ð( ‡J�J�—‘Ø‡I�Iˆt�{‰{Ø
‡M�M�4—;‘;Ø‡J�J×Ñ×5Ñ5°t·{±{Ø‡G�GˆT�Y‰YØ‡F�FˆD�H‰HØ‡K�K�—‘Ø‡J�J�—‘Ø‡N�N�E×$Ñ$Ø‡O�O�S×%Ñ%Ø‡L�L�#—-‘-ð>Ð % t¨H°c¨MÑ':ó ð0 ‡M�Mð2Ð   X¡ó ð ‡E�Eˆ5�9‰9×Ñ×"Ñ"Ø‡K�K�—‘×$Ñ$×.Ñ.Ø‡O�O�U—Y‘Y×(Ñ(×6Ñ6Ø‡L�L�%—)‘)×%Ñ%×0Ñ0Ø‡L�L�%—)‘)×%Ñ%×0Ñ0Ø‡I�Iˆu�y‰y×"Ñ"×*Ñ*ðVÐ ,¨d°5¸À3¸Ñ3GÈÐ3QÑ.Ró ð ‡N�NÐ?Ø‡J�JÐ;Ø‡J�JÐ;Ø‡G�GÐ;ð	@Ð " D¨°8Ð);Ñ$<ó ð ‡I�Iˆu�|‰|×%Ñ%×,Ñ,ðDÐ +¨T°(¸C°-Ñ-@ó ð ‡I�Iˆu�|‰|×%Ñ%×-Ñ-×4Ñ4ðEÐ ,¨d°8¸S°=Ñ.Aó ð
˜˜S™ó ð?°$°xÀ°}Ñ2Eó ?ð
I¸DÀÈ3ÀÑ<Oó Ið
°D¸À3¸Ñ4Gó ðF¸¸hÈ¸mÑ9Ló Fð FJØñ4Ø ð4à%-¨d°8¸S°=Ñ.AÑ%Bð4ð ð4ð 	ó	4ð4 GKñ5Ø ð5à&.¨t°H¸c°MÑ/BÑ&Cð5ð 	ó5ð(6¨¨h¸¨mÑ)<ó 6ð
¨4°¸#°Ñ+>ó ð1°4¸À#¸Ñ3Fó 1ð
8¸$¸xÈ¸}Ñ:Mó 8ð

>¨c°(©mó 
>ðI°°H±ó Ið GØˆˆx˜ˆ}Ñ	˜xÐ	'Ñ(óGð U¨8°S¨=Ñ%9ð ¸hó ð	¨%¯(©(¯/ª/ð 	¸hÀxÑ>Pó 	ðR¨%¯(©(¯/ª/ð R¸dô Rr/   