
    ȅi)6                     z   % S SK r S SKJr  S SKJr  S SKrS SKJs  Jr	  S SK
Js  Js  Jr  S SKJs  Js  Js  Jr  S SKJs  Js  Js  Jr  S SKJs  Js  Js  Js  Jr  S SKJs  Js  Jr  S SKJs  Js  Js  Jr  S SKJs  Js  Jr  S SKJs  Js  Js  Jr  S SKJs  Js  Js  Jr   S SK!rS SK"Js  J#r$  S SKJr  S SK%J&r&J'r'  S SK(J)r)J*r*  S SK+J,r,  S SK-J.r.  / S	Qr/\*\R`                  \)\Rb                  \Rd                  \ Rd                  \Rf                  \ Rf                  \Rh                  \ Rh                  \Rj                  \ Rj                  \Rl                  \ Rl                  \Rn                  \ Rn                  \Rp                  \ Rp                  \Rr                  \ Rr                  \Rt                  \ Rt                  \Rv                  \ Rv                  \Rx                  \ Rx                  \Rz                  \ Rz                  \R|                  \ R|                  0r?\@\\4   \AS
'   0 \*\R`                  _\)\Rb                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\Rf                  \Rf                  _\Rh                  \Rh                  _\Rj                  \Rj                  _\Rl                  \Rl                  _\Rn                  \Rn                  _\Rp                  \Rp                  _\R                  \R                  _\Rr                  \Rr                  _\Rt                  \Rt                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _0 \R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  R                  R                  \Rd                  _\Rd                  \Rd                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _\R                  \R                  _E\R                  \R                  \R                  \R                  \R                  \Rf                  \R                  \Rh                  \R                  \Rj                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \Rd                  \Rd                  \Rd                  \Rh                  \Rh                  \Rj                  \Rj                  0Ere\@\\4   \AS'   \Rh                  \Rh                  \Rj                  \Rj                  \Rd                  \Rd                  \R                  R                  R                  \Rd                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  0rf\@\\4   \AS'   \Rv                  \Rv                  \Rd                  \Rd                  \Rd                  \Rd                  \R                  R                  R                  \Rd                  \R|                  \R|                  \R                  \R                  \Rx                  \Rx                  \Rz                  \Rz                  \R                  \R                  \Rt                  \Rt                  \Rr                  \Rr                  0rh\@\\4   \AS'   \R                  1rj\k\   \AS'   \$R                  \R                  R"                  R                  \$R                  \R                  R"                  R                  \$R                  \R                  R"                  R                  \$R                  \R                  R"                  R                  \$R                  \R                  R"                  R                  \$R                  \R                  R"                  R                  0rs\@\\t-  \4   \AS'   \R                  \&\R                  \&\R                  \&\R                  \'0ry\@\\4   \AS'   \Rd                  \	R                  R"                  Rd                  0r{\@\\4   \AS'   \Rd                  \	R                  R"                  R(                  Rd                  0r|\@\\4   \AS'   S\k\   4S jr}S\@\\4   4S jr~S\@\\4   4S jrS\@\\4   4S jrS\@\\4   4S jr  S+S\S\@\\4   S-  S\S\4S jjr S,S\S\@\\4   S-  S\4S jjrS\@\\4   4S jrS\@\\4   4S  jrS\@\\4   4S! jrS\@\\4   4S" jrS\k\   4S# jrS\k\   4S$ jrS\@\\t-  \4   4S% jrS&\\t-  S\4S' jrS(\R                  GR                  S\S-  4S) jrS(\R                  GR                  S\4S* jrg)-    N)Callable)Any)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_mappings2get_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_mappings0get_default_dynamic_sparse_quant_module_mappings$get_default_qconfig_propagation_list&get_default_compare_output_module_list0get_default_float_to_quantized_operator_mappingsget_quantized_operatorr   r   r   r   _INCLUDE_QCONFIG_PROPAGATE_LISTr   r   r   r   returnc                  n    [         R                  R                  [         R                  R                  1n U $ )z8These modules cannot have observers inserted by default.)r   quantizableLSTMMultiheadAttention)no_observerss    e/home/james-whalen/.local/lib/python3.13/site-packages/torch/ao/quantization/quantization_mappings.pyr   r      s&    NN'')J)JKL    c                  6    [         R                  " [        5      $ )z8Get module mapping for post training static quantization)copydeepcopyr    r+   r*   r   r      s    ===>>r+   c                  6    [         R                  " [        5      $ )zBGet reference module mapping for post training static quantization)r-   r.   r   r/   r+   r*   r   r      s    ==GHHr+   c                      [         R                  " [        5      n [        R                  U [
        R                  '   [        R                  U [
        R                  '   U $ )z7Get module mapping, including mapping for embedding QAT)r-   r.   r   nnqEmbeddingBagnnqat	Embeddingmappings    r*   r   r      s>    mm@AG"%"2"2GE"}}GEOONr+   c                  6    [         R                  " [        5      $ )z?Get module mapping for post training static sparse quantization)r-   r.   r   r/   r+   r*   r   r      s    ==DEEr+   float_module_classadditional_static_quant_mappingis_referencec                     Uc  0 n[        U(       a  [        O[        U5      nUR                  U S5      nUc  [	        S[        U 5       3S-   5      e[        R                  " U5      $ )z]n 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AssertionErrorstrr-   r.   )r9   r:   r;   all_mappingsstatic_quant_module_classs        r*   r   r      s}     '.*,'$ 	71'	L !- 0 01CT J (*3/A+B*CDEF
 	
 ==233r+    additional_dynamic_quant_mappingc                     Uc  0 n[        [        U5      nUR                  U S5      nUc  [        S[	        U 5       3S-   5      e[
        R                  " U5      $ )z^n Get the dynamically quantized module class corresponding to
the floating point module class
Nr=   r>   )r
   r   r?   r@   rA   r-   r.   )r9   rD   rB   dynamic_quant_module_classs       r*   r   r     su     (/+-($-/OL ".!1!12Dd!K!)*3/A+B*CDEF
 	
 ==344r+   c                  6    [         R                  " [        5      $ )z:Get default module mapping for quantization aware training)r-   r.   r   r/   r+   r*   r   r     s    ==455r+   c                      [         R                  " [        5      n [        R                  U [
        R                  '   [        R                  U [
        R                  '   U $ )zGet module mapping for quantization aware training
This is includes default values in addition to
enabling qat for embeddings.
)r-   r.   r   r4   r3   r   r5   r6   s    r*   r   r   !  s>    
 mm78G$11GBOO!OOGBLLNr+   c                      [         $ )z9Get module mapping for post training dynamic quantization)r   r/   r+   r*   r   r   ,  s    00r+   c                      [         $ )z@Get module mapping for post training dynamic sparse quantization)r   r/   r+   r*   r   r   1  s    77r+   c                      [        [        R                  5       5      [        [        R                  5       5      -  [        [        R                  5       5      -  [
        -  n [        R                  " U 5      $ )zWGet the default list of module types that we'll attach qconfig
attribute to in prepare
)setr   keysr   r   r#   r-   r.   )#QCONFIG_PROPAGATE_MODULE_CLASS_LISTs    r*   r   r   6  se    
 	05578
)..0
1	2
388:
;	< *	* ( ==<==r+   c                     [        [        R                  5       5      [        [        R                  5       5      -  [        [        R                  5       5      -  [        [        R                  5       5      -  [        [        R                  5       5      -  [        [        R                  5       5      -  [        -  n [        R                  " U 5      $ )zKGet list of module class types that we will record output
in numeric suite
)	rL   r   valuesr   r   rM   r#   r-   r.   ).NUMERIC_SUITE_COMPARE_MODEL_OUTPUT_MODULE_LISTs    r*   r    r    C  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                  6    [         R                  " [        5      $ N)r-   r.   r   r/   r+   r*   r!   r!   S  s     ==EFFr+   float_opc                 f    [         R                  U 5      nUc  [        S[        U 5       S35      eU$ )z>Get the quantized operator corresponding to the float operatorz	Operator z) does not have corresponding quantized op)r   r?   r@   rA   )rT   quantized_ops     r*   r"   r"   Z  s>    ?CCHMLH&OP
 	
 r+   modulec                 >    [         R                  [        U 5      5      $ )zGet 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
)r   r?   r   rW   s    r*   _get_special_act_post_processrZ   d  s     .112Nv2VWWr+   c                 L    U R                   =(       a    [        U 5      [        ;   $ rS   )trainingtyper   rY   s    r*   _has_special_act_post_processr^   n  s    ??QtF|/QQQr+   )NFrS   )r-   collections.abcr   typingr   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.qatr4   torch.ao.nn.qat.dynamicnnqatdtorch.ao.nn.quantizedr2   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ConvTranspose3dr5   r3   GRUCellLSTMCellRNNCellr'   r   dict__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#   rL   eluops	hardswishinstance_norm
layer_norm
leaky_reludropoutr   rA   HardsigmoidSigmoidSoftmaxTanhr   sparser   r   r   r   r   r   r   boolr   r   r   r   r   r   r   r    r!   r"   ModulerZ   r^   r/   r+   r*   <module>r      s
    $     # # * * . . 7 7 7   ( ( # # , , . .     ? 9 C8 s||IIt{{IIt{{IIt{{IIt{{,,,,,,LL$..OOT&&JJKKJJGGTYYG .Xs]0C &5=s||5=5= NNCOO5= NNCOO	5=
 JJ5= IIszz5= IIszz5= IIszz5= ++5= ++5= ++5= FFCGG5= LL#--5= OOS%%5= LL#--5=  LL#--!5=" s))#5=$ s))%5=& s))'5=( LL#--)5=* LL#--+5=, JJ55szz-5=. IIszz/5=0 HHcii15=2 HHcii35=6 75=: LL$--;5=< LL$--=5=> NNDOO?5=@ NNDOOA5=B NNDOOC5=D MM4>>E5=F t))G5=H NNDOOI5=J --NNDOO
OOSZZ
OOSZZ
OOSZZ



t
t
t
szz	LL#**	LL#**	LL#**i5= $d8S=&9 5r IIu||IIu||IIu||JJ55u||LL&//LL&//LL&//f))f))f))NNF%%NNF%%NNF%%NNF%%4 T(C-0 ( JJIIt{{
MM4;;JJ55t{{GGTYYFFDHHKKJJNNE$$OOS%%LL#--> %tHcM': 0 MM2 X  EE599""KK$$..OOUYY((66LL%))%%00LL%))%%00IIuyy""**P ,d8c>83K.L  NN?JJ;JJ;GG;	@ "D8);$<  IIu||%%,,D +T(C--@  IIu||%%--44E ,d8S=.A 
S ?$x}2E ?
ID3<O I
D34G Fhm9L F CG4 4%)(C-%84%?4 4 		46 DH5 5&*8S=&9D&@5 	5*6hm)< 6
4#+> 14#3F 1
8$x}:M 8

>c(m 
>IH I G$sNH; GX^  X%((// Xho XR%((// Rd Rr+   