+
    –°³j0)  ã                   ó®   € ^ RI t ^ RIt^ RIHtHt ^ RIt^ RIHtHtH	t	H
t
Ht ^ RIHt ^ RIHt ^ RIHtHt ]'       d   ^ RIHt RR R	 lltRR
 R lltR# )é    N)ÚAnyÚTYPE_CHECKING)Údefault_weight_fake_quantÚdefault_weight_observerÚFakeQuantizeBaseÚQConfigÚQConfigMapping)ÚBackendConfig)Ú_PartialWrapper)Úconvert_to_reference_fxÚ
prepare_fx)ÚCallablec                óv  € V ^8„  d   QhR\         P                  P                  R\        \        R3,          R\
        R,          R\        R,          R\        R,          R\        R,          R	\        R,          R
\        R,          R\        R\         P                  P                  P                  P                  /
# )é   Ú
float_lstmÚexample_inputs.Úbackend_configNÚlinear_output_obs_ctrÚsigmoid_obs_ctrÚtanh_obs_ctrÚcell_state_obs_ctrÚhidden_state_obs_ctrÚsplit_gatesÚreturn)
ÚtorchÚnnÚLSTMÚtupler   r
   r   ÚboolÚaoÚquantizable)Úformats   "Úd/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/ao/quantization/fx/lstm_utils.pyÚ__annotate__r$      sº   € ÷ Nñ NÜ—‘—‘ðNäœ#˜s˜(•OðNô " DÕ(ðNô +¨TÕ1ð	Nô
 % tÕ+ðNô " DÕ(ðNô (¨$Õ.ðNô *¨DÕ0ðNô ðNô ‡X�X‡[�[×Ñ×!Ñ!ñNó    c	                ó†  € R R lp	\         P                  P                  P                  P	                  V P
                  V P                  V P                  V P                  V P                  V P                  V P                  VR7      p
V P                  V
n        \        V P                  4       Fp  p\         P                  P                  P                  P                  P                  P                   P#                  V VV P                  RVR7      V
P$                  V&   Kr  	  \'        4       P)                  V P                  4      pVeI   VP+                  RV	! V4      4       VP+                  RV	! V4      4       VP+                  R	V	! V4      4       Ve   VP+                  R
V	! V4      4       V
P$                   EFƒ  pVP,                  P.                  p\1        V\         P                  P2                  4      '       g   \5        R4      h\7        WìWR7      pV'       g^   \         P8                  ^ 3V\         P:                  ^ 3V\         P:                  ^3V\         P8                  ^3V\         P:                  ^3V/pM’\         P8                  ^ 3V\         P8                  ^3V\         P8                  ^3V\         P8                  ^3V\         P:                  ^ 3V\         P:                  ^3V\         P8                  ^3V\         P:                  ^3V/p^ p^ pVP<                  P>                   EF  pRpVP@                  \         P8                  J d   \         P8                  V3pV^,          pM<VP@                  \         P:                  J d   \         P:                  V3pV^,          pMK|  VV9  d   K…  \C        VPD                  4      ^8w  d   \5        R4      h\G        \I        VPD                  PK                  4       4      4      PL                  pVV,          pVf   Kï  \O        VVV! 4       4       EK  	  WíP,                  n        EK†  	  V
# )aë  
Return an observed `torch.ao.nn.quantizable.LSTM` created from a `torch.nn.LSTM`
with specific observers or fake quantizes assigned to the inner ops or submodules.

In both eager and FX graph mode quantization, `torch.ao.nn.quantizable.LSTM` is
used as an observed custom module, which is responsible for inserting its own
observers. By default, all inner ops inherit the parent custom module's QConfig.
Users who wish to override this behavior may extend `torch.ao.nn.quantizable.LSTM`
and use this helper function to customize the observer insertion logic.

This is meant to be used to convert a float module to an observed module in the
custom module flow.

Args:
    `float_lstm`: The float LSTM module
    `example_inputs`: example inputs for the forward function of the LSTM module
    `backend_config`: BackendConfig to use to observe the LSTM module
    `linear_output_obs_ctr`: observer or fake quantize for linear outputs Wx + b,
        where W is the weight matrix, b is the bias, and x is either the inputs
        or the hidden state from the previous layer (if any)
    `sigmoid_obs_ctr`: observer or fake quantize for sigmoid activations
    `tanh_obs_ctr`: observer or fake quantize for tanh activations
    `cell_state_obs_ctr`: observer or fake quantize for the cell state
    `hidden_state_obs_ctr`: observer or fake quantize for the hidden state and
        the output

Return:
    A `torch.ao.nn.quantizable.LSTM` with the specified observers or fake quantizes
    assigned to the inner ops.
c                ó0   € V ^8„  d   QhR\         R\        /# )r   Úobs_ctrr   )r   r   )r"   s   "r#   r$   Ú@_get_lstm_with_individually_observed_parts.<locals>.__annotate__A   s   € ÷ :ñ :œoð :´'ñ :r%   c                ój   € \        V ! 4       \        4      '       d   \        pM\        p\	        WR7      # )z@
Make a QConfig with fixed qparams observers or fake quantizes.
)Ú
activationÚweight)Ú
isinstancer   r   r   r   )r(   r,   s   & r#   Úmake_qconfigÚ@_get_lstm_with_individually_observed_parts.<locals>.make_qconfigA   s)   € ô ‘g“iÔ!1×2Ò2Ü.‰Fä,ˆFÜ 'Ô9Ð9r%   )r   F)Úbatch_firstr   NÚ
input_gateÚforget_gateÚoutput_gateÚ	cell_gatezcell should be a nn.Module©r   z&expected exactly one user for the node)(r   r    r   r!   r   Ú
input_sizeÚhidden_sizeÚ
num_layersÚbiasr0   ÚdropoutÚbidirectionalÚqconfigÚrangeÚmodulesÚrnnÚ
_LSTMLayerÚ
from_floatÚlayersr	   Ú
set_globalÚset_module_nameÚlayer_fwÚcellr-   ÚModuleÚAssertionErrorr   ÚaddÚmulÚgraphÚnodesÚtargetÚlenÚusersÚnextÚiterÚkeysÚnameÚsetattr)r   r   r   r   r   r   r   r   r   r.   Úquantizable_lstmÚidxÚcell_qmÚlayerrF   Ú'op_index_to_activation_post_process_ctrÚ	add_countÚ	mul_countÚnodeÚop_indexÚactivation_post_process_nameÚactivation_post_process_ctrs   &&&&&&&&&             r#   Ú*_get_lstm_with_individually_observed_partsr`      s„  € õT:ô —x‘x—{‘{×.Ñ.×3Ñ3Ø×ÑØ×ÑØ×ÑØ�‰Ø×ÑØ×ÑØ× Ñ Øð 4ó 	Ðð  *×1Ñ1ÐÔä�Z×*Ñ*Ö+ˆä�H‰H�K‰K×#Ñ#×+Ñ+×/Ñ/×:Ñ:×EÑEØØØ×"Ñ"Ø!Ø'ð Fó ð 	×Ñ Ó$ñ ,ô Ó×)Ñ)¨*×*<Ñ*<Ó=€GØÒ"Ø×Ñ ©l¸?Ó.KÔLØ×Ñ ©|¸OÓ/LÔMØ×Ñ ©|¸OÓ/LÔMØÒØ×Ñ ©\¸,Ó-GÔHð "×(Õ(ˆØ�~‰~×"Ñ"ˆÜ˜$¤§¡§¡×0Ò0Ü Ð!=Ó>Ð>Ü˜$¨ÔWˆ÷ ä—‘˜A�Ð 5Ü—‘˜A�Ð 2Ü—‘˜A�Ð 2Ü—‘˜A�Ð 2Ü—‘˜A�Ð 4ð7Ñ3ô —‘˜A�Ð 5Ü—‘˜A�Ð 5Ü—‘˜A�Ð 5Ü—‘˜A�Ð 5Ü—‘˜A�Ð 2Ü—‘˜A�Ð 2Ü—‘˜A�Ð 2Ü—‘˜A�Ð 4ð	7Ð3ð ˆ	Øˆ	Ø—J‘J×$Õ$ˆDØ48ˆHØ�{‰{œeŸi™iÓ'Ü!ŸI™I yÐ1�Ø˜Q•‘	Ø—‘¤§	¡	Ó)Ü!ŸI™I yÐ1�Ø˜Q•‘	ñ ØÐFÔFÙÜ�4—:‘:‹ !Ô#Ü$Ð%MÓNÐNÜ+/´°T·Z±Z·_±_Ó5FÓ0GÓ+H×+MÑ+MÐ(Ø*QØõ+Ð'ð +Ô6ÜØÐ6Ñ8SÓ8U÷ñ) %ð. #�‰×ñm )ðn Ðr%   c                óê   € V ^8„  d   QhR\         P                  P                  P                  P                  R\
        R,          R\         P                  P                  P                  P                  /# )r   Úobserved_lstmr   Nr   )r   r    r   r!   r   r
   Ú	quantized)r"   s   "r#   r$   r$   ¨   sS   € ÷ <ñ <Ü—8‘8—;‘;×*Ñ*×/Ñ/ð<ä! DÕ(ð<ô ‡X�X‡[�[×Ñ×Ññ<r%   c           
     ó  € \         P                  P                  P                  P	                  V P
                  V P                  V P                  V P                  V P                  V P                  V P                  4      p\        VP                  4       EFA  w  r4\        P                  ! V P                  P!                  \#        V4      4      P$                  P&                  4      p\)        WQR7      p\+        V\         P,                  P.                  4      '       g   \1        R4      hVP2                  P4                   EFY  pVP6                  \         P8                  J d½   VP:                  ^ ,          pVP6                  R8X  gA   VP6                  \<        P>                  J d{   VP:                  ^ ,          P6                  R8X  dY   VP2                  PA                  V4      ;_uu_ 4        VPC                  V4       VP2                  PE                  V4       RRR4       VP6                  R8X  g   Kñ  VP:                  ^ ,           FQ  pVP2                  PA                  V4      ;_uu_ 4        VPG                  WwP:                  ^ ,          4       RRR4       KS  	  EK\  	  VP2                  PI                  4        VPK                  4        WTP$                  n        EKD  	  V#   + '       g   i     LÑ; i  + '       g   i     K¿  ; i)a#  
Return a `torch.ao.nn.quantized.LSTM` created from a `torch.ao.nn.quantizable.LSTM`
with observers or fake quantizes inserted through `prepare_fx`, e.g. from
`_get_lstm_with_individually_observed_parts`.

This is meant to be used to convert an observed module to a quantized module in the
custom module flow.

Args:
    `observed_lstm`: a `torch.ao.nn.quantizable.LSTM` observed through `prepare_fx`
    `backend_config`: BackendConfig to use to produce the reference quantized model

Return:
    A reference `torch.ao.nn.quantized.LSTM` module.
r5   z0cell must be converted to a torch.fx.GraphModuleÚxÚhiddenNÚoutput)&r   r    r   rc   r   r6   r7   r8   r9   r0   r:   r;   Ú	enumeraterB   ÚcopyÚdeepcopyÚget_submoduleÚstrrE   rF   r   r-   ÚfxÚGraphModulerH   rK   rL   rM   Úquantize_per_tensorÚargsÚoperatorÚgetitemÚinserting_beforeÚreplace_all_uses_withÚ
erase_nodeÚreplace_input_withÚeliminate_dead_codeÚ	recompile)rb   r   Úquantized_lstmÚirX   rF   r\   Úargs   &&      r#   Ú$_get_reference_quantized_lstm_moduler|   ¨   s  € ô& —X‘X—[‘[×*Ñ*×/Ñ/Ø× Ñ Ø×!Ñ!Ø× Ñ Ø×ÑØ×!Ñ!Ø×ÑØ×#Ñ#ó€Nô ˜n×3Ñ3×4‰ˆÜ�}Š}˜]×1Ñ1×?Ñ?ÄÀAÃÓG×PÑP×UÑUÓVˆÜ& tÔKˆÜ˜$¤§¡× 4Ñ 4×5Ò5Ü Ð!SÓTÐTð —J‘J×$Õ$ˆDØ�{‰{œe×7Ñ7Ó7Ø—i‘i •l�à—:‘: Ô$Ø—J‘J¤(×"2Ñ"2Ó2°s·x±xÀµ{×7IÑ7IÈXÔ7UàŸ™×4Ñ4°T×:Õ:Ø×2Ñ2°3Ô7ØŸ
™
×-Ñ-¨dÔ3÷ ;ð �{‰{˜hÖ&àŸ9™9 QŸ<˜<�CØŸ™×4Ñ4°T×:Õ:Ø×/Ñ/°·X±X¸aµ[ÔA÷ ;Ñ:ô (ñ %ð 	�
‰
×&Ñ&Ô(Ø�‰ÔØ"�‰×ñ= 5ð> Ð÷ ;×:ú÷ ;×:Ð:ús   Ç'-K	É(#K0ËK-Ë0L)NNNNNNF)N)ri   rq   Útypingr   r   r   Útorch.ao.quantizationr   r   r   r   r	   Ú$torch.ao.quantization.backend_configr
   Útorch.ao.quantization.observerr   Ú!torch.ao.quantization.quantize_fxr   r   Úcollections.abcr   r`   r|   © r%   r#   Ú<module>r„      s?   ðÛ Û ß %ã ÷õ õ ?Ý :ß Q÷ Ý(÷N÷b<ñ <r%   