ó
    Eñiy  ã                   ó  • S SK Jr  S SKrS SKJrJrJrJr  S/r \R                  R                  R                  R                  \R                  R                  R                  R                  \R                  R                  R                  R                  \R                  R                  R                   R                  \R                  R                  R"                  R                  1r " S S\\R(                  R*                  \4   5      rg)é    )ÚCallableN)Ú_collect_all_valid_cia_opsÚ-_collect_all_valid_cia_ops_for_aten_namespaceÚ_get_decomp_for_ciaÚ_is_aten_opÚCustomDecompTablec                   óè   ^ • \ rS rSrSrU 4S jrS rSS jrS rSS jr	S	 r
S\4S
 jrS\4S jrS\4S jrS rS rSS jrS rS rS\\R.                  R0                  \4   4S jrSS jrSrU =r$ )r   é   a/  
This is a custom dictionary that is specifically used for handling decomp_table in export.
The reason we need this is because in the new world, you can only *delete* an op from decomp
table to preserve it. This is problematic for custom ops because we don't know when the custom
op will actually be loaded to the dispatcher. As a result, we need to record the custom ops operations
until we really need to materialize it (which is when we run decomposition pass.)

Invariants we hold are:
 1. All aten decomp is loaded at the init time
 2. We materialize ALL ops when user ever reads from the table to make it more likely
    that dispatcher picks up the custom op.
 3. If it is write operation, we don't necessarily materialize
 4. We load the final time during export, right before calling run_decompositions()

c                 óþ   >• [         TU ]  5         SSKJn  U" 5       U l        [        5        H8  nU[        ;  d  M  X R                  ;  d  M   [        U5      U R                  U'   M:     [        5       U l	        SU l
        g )Nr   )Ú'_core_aten_decompositions_post_autogradF)ÚsuperÚ__init__Útorch._decompr   Údecomp_tabler   ÚPRESERVED_ATEN_CIA_OPSr   ÚsetÚdeleted_custom_opsÚhas_materialized)Úselfr   ÚopÚ	__class__s      €ÚV/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torch/export/decomp_utils.pyr   ÚCustomDecompTable.__init__0   sj   ø€ Ü‰ÑÔÝIñ DÓEˆÔä?ÖAˆBØÔ/Õ/°B×>OÑ>OÕ4OÜ(;¸BÓ(?�×!Ñ! "Ó%ñ Bô
 #&£%ˆÔà %ˆÕó    c                 óX   • U R                  5         U R                  R                  U5      $ ©N)Ú_materialize_if_neededr   Ú__getitem__©r   Úkeys     r   r   ÚCustomDecompTable.__getitem__@   s%   € Ø×#Ñ#Ô%Ø× Ñ ×,Ñ,¨SÓ1Ð1r   Úreturnc                 ó�   • U R                   R                  X5        XR                  ;   a  U R                  R                  U5        g g r   )r   Ú__setitem__r   Úremove)r   r    Úvalues      r   r$   ÚCustomDecompTable.__setitem__D   s;   € Ø×Ñ×%Ñ% cÔ1à×)Ñ)Ó)Ø×#Ñ#×*Ñ*¨3Õ/ð *r   c                 óV   • U R                  5         U R                  R                  5       $ r   )r   r   Úkeys©r   s    r   r)   ÚCustomDecompTable.keysJ   s#   € Ø×#Ñ#Ô%Ø× Ñ ×%Ñ%Ó'Ð'r   c                 ó&   • U R                  U5        g r   )Úpopr   s     r   Ú__delitem__ÚCustomDecompTable.__delitem__N   s   € Ø�‰��r   c                 ól   • UR                  5        H   u  p#U R                  R                  X#5        M"     g r   )Úitemsr   r$   )r   Ú
other_dictÚkÚvs       r   ÚupdateÚCustomDecompTable.updateQ   s+   € Ø×$Ñ$Ö&‰DˆAØ×Ñ×)Ñ)¨!Ö/ò 'r   c                 ó.   • U R                  U5      (       + $ r   )Ú__contains__r   s     r   Ú__missing__ÚCustomDecompTable.__missing__U   s   € Ø×$Ñ$ SÓ)Ô)Ð)r   c                 óX   • U R                  5         U R                  R                  U5      $ r   )r   r   r8   r   s     r   r8   ÚCustomDecompTable.__contains__X   s%   € Ø×#Ñ#Ô%Ø× Ñ ×-Ñ-¨cÓ2Ð2r   c                 óV   • U R                  5         U R                  R                  5       $ r   )r   r   Ú__len__r*   s    r   r>   ÚCustomDecompTable.__len__\   s#   € Ø×#Ñ#Ô%Ø× Ñ ×(Ñ(Ó*Ð*r   c                 óV   • U R                  5         U R                  R                  5       $ r   )r   r   Ú__iter__r*   s    r   rA   ÚCustomDecompTable.__iter__`   s#   € Ø×#Ñ#Ô%Ø× Ñ ×)Ñ)Ó+Ð+r   c                 óV   • U R                  5         U R                  R                  5       $ r   )r   r   Ú__reversed__r*   s    r   rD   ÚCustomDecompTable.__reversed__d   s#   € Ø×#Ñ#Ô%Ø× Ñ ×-Ñ-Ó/Ð/r   c                 ó¸   • [        5       nU R                  R                  5       Ul        U R                  R                  5       Ul        U R                  Ul        U$ r   )r   r   Úcopyr   r   )r   Únew_dicts     r   rG   ÚCustomDecompTable.copyh   sK   € Ü$Ó&ˆØ $× 1Ñ 1× 6Ñ 6Ó 8ˆÔØ&*×&=Ñ&=×&BÑ&BÓ&DˆÔ#Ø$(×$9Ñ$9ˆÔ!Øˆr   c                 ó¦   ^ • U 4S jn[        U5      S:X  a  U" US   5      $ [        U5      S:X  a   U" US   5      $ g ! [         a    US   s $ f = f)Nc                 ón  >• [        U 5      (       a  TR                  R                  U 5      $ U TR                  ;   a6  TR                  R	                  U 5        TR                  R                  U 5      $ U TR                  ;   a  [        U  S35      eTR                  R	                  U 5        [        U 5      $ )Nz doesn't exist in the table)r   r   r-   r   ÚaddÚKeyErrorr   )r    r   s    €r   Ú_pop_if_canÚ*CustomDecompTable.pop.<locals>._pop_if_canp   s¢   ø€ Ü˜3×ÑØ×(Ñ(×,Ñ,¨SÓ1Ð1à�d×'Ñ'Ó'ð ×'Ñ'×+Ñ+¨CÔ0Ø×(Ñ(×,Ñ,¨SÓ1Ð1à�d×-Ñ-Ó-Ü # Ð&AÐBÓCÐCà×#Ñ#×'Ñ'¨Ô,ô ' sÓ+Ð+r   é   r   é   )ÚlenrM   )r   ÚargsrN   s   `  r   r-   ÚCustomDecompTable.popo   sb   ø€ õ	,ô( ˆt‹9˜‹>Ù˜t A™wÓ'Ð'äˆt‹9˜‹>ðÙ" 4¨¡7Ó+Ð+ð øô ó Ø˜A‘w’ðús   ²
> ¾AÁAc                 óV   • U R                  5         U R                  R                  5       $ r   )r   r   r1   r*   s    r   r1   ÚCustomDecompTable.items�   s#   € Ø×#Ñ#Ô%Ø× Ñ ×&Ñ&Ó(Ð(r   c                 ó  • [        5        HO  n[        U5      (       a  M  XR                  ;   a  M&  XR                  ;  d  M7  [	        U5      U R                  U'   MQ     SU l        [        5       U l        0 U R                  E$ )NT)r   r   r   r   r   r   r   )r   r   s     r   ÚmaterializeÚCustomDecompTable.materialize‘   sp   € Ü,Ö.ˆBÜ˜2�‰ÙØ×(Ñ(Ó(ÙØ×2Ñ2Õ2Ü(;¸BÓ(?�×!Ñ! "Ó%ñ /ð !%ˆÔÜ"%£%ˆÔØ$�$×#Ñ#Ð$Ð$r   c                 óH   • U R                   (       d  U R                  5         g g r   )r   rX   r*   s    r   r   Ú(CustomDecompTable._materialize_if_neededž   s   € Ø×$×$Ø×ÑÕð %r   )r   r   r   )r"   N)r"   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r$   r)   r.   r5   Úboolr9   r8   Úintr>   rA   rD   rG   r-   r1   ÚdictÚtorchÚ_opsÚOperatorBaser   rX   r   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r      s�   ø† ñõ &ò 2ô0ò(ôò0ð* $ô *ð3 4ô 3ð+˜ô +ò,ò0ôòò<)ð%˜T %§*¡*×"9Ñ"9¸8Ð"CÑDô %÷ò r   )Úcollections.abcr   rd   Útorch._export.utilsr   r   r   r   Ú__all__ÚopsÚatenÚupsample_bilinear2dÚvecÚupsample_nearest2dÚsilu_backwardÚdefaultÚmish_backwardÚ_fused_rms_normr   rc   re   rf   r   © r   r   Ú<module>rv      sÃ   ðå $ã ÷ó ð Ð
€ðð 
‡I�I‡N�N×&Ñ&×*Ñ*Ø	‡I�I‡N�N×%Ñ%×)Ñ)à	‡I�I‡N�N× Ñ ×(Ñ(Ø	‡I�I‡N�N× Ñ ×(Ñ(Ø	‡I�I‡N�N×"Ñ"×*Ñ*ðÐ ôA˜˜UŸZ™Z×4Ñ4°hÐ>Ñ?õ Ar   