+
    AåûjqÆ  ã                   óš  a € RV tO0 t ^ RIt^ RIt^ RIHtHt ^ RIHtHt ^ RI	H
t
Ht ^ RIt. RWOt]P                  ! ]4      t]
! R4      t]! R4      t]]]3,          t]]]3,          t]. ]3,          tR R ltR	 R
 lt] ! R R4      4       t]]]]],          .]],          3,          t] ! R R4      4       t]! 4       t] ^ k / s ] ^k / t!] ^k ]PD                  ! 4       t#R R lt$]%]&]]]3,          ]],          3,          t'/ s(] ^k ]%]]]&]]]3,          ,          3,          t)/ s*] ^k / s+] ^k / s,] ^k ^ s-] ^k ].! 0 RXm4      t/] ^k ].! RR04      t0] ^	k R R lt1RR/R R llt2/ t3] ^
k ]4! 4       t5] ^k / t6] ^k R R lt7R R lt8R R lt9R R  lt:R! R" lt;R# R$ lt<R% R& lt=R' R( lt>R) R* lt?R+RR,RR-R/R. R/ llt@R0RR1RR2R/R3 R4 lltARYR5 R6 lltBR7 R8 ltCR9 R: ltDR;RR<RR=R/R> R? lltER@R/RA RB lltFRCR/RD RE lltGRFRRGRRCR/RH RI lltHRZRJ RK lltIRCR/RL RM lltJRN RO ltKRGR/RP RQ lltLRGR/RR RS lltMRGR/RT RU lltNR# )[é    N)ÚCallableÚIterable)Ú	dataclassÚfield)Ú	ParamSpecÚTypeVarÚPÚRc                ó$   € V ^8„  d   QhR\         /# ©é   Úreturn©Úbool)Úformats   "ÚRC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\torch\_native\registry.pyÚ__annotate__r      s   € ÷ 	;ñ 	;¤$ñ 	;ó    c                 ó>   € \         P                  P                  4       # )a£  Whether unconditional overrides are currently masked.

The flag itself lives on the C++ Context, where the generated AOT gates read it,
so overrides and AOT kernels cannot disagree about whether the exemption is
lifted. A getter, so a caller can read it before mutating anything and restore it
even if a later step of its setup raises. Flipped only by
torch._native._unconditional_masked(), for reference computations.
)ÚtorchÚ_CÚ$_get_native_aot_unconditional_masked© r   r   Ú_unconditional_is_maskedr      s   € ô �8‰8×8Ñ8Ó:Ð:r   c                ó0   € V ^8„  d   QhR\         R\         /# )r   Úmaskedr   r   )r   s   "r   r   r   *   s   € ÷ ñ ¤Dð ¬Tñ r   c           	     ó¼   € \        4       p\        P                  P                  V 4       \        P                  4        F  w  w  r#rE\        W#WE\        R7       K  	  V# )züSet the mask and rebuild every router, returning the previous value, which the
caller must restore.

The rebuild is required because check_enabled runs at graph registration, not per
call: flipping the flag alone leaves the installed routers untouched.©Úfilter_state)r   r   r   Ú$_set_native_aot_unconditional_maskedÚ_graphsÚitemsÚ_cleanup_and_reregister_graphÚ_filter_state)r   ÚpreviousÚ
lib_symbolÚ	op_symbolÚdispatch_keyÚgraphs   &     r   Ú_set_mask_unconditionalr*   *   sM   € ô (Ó)€HÜ	‡H�H×1Ñ1°&Ô9Ü8?¿¹¾Ñ4Ñ-ˆ Ü%Ø <Ä]÷	
ñ 9Hð €Or   c                   ó<   a € ] tR t^9t o RtRtRtRtV 3R ltRt	V t
R# )Ú_OverrideNodezTrack function override data.FTNc                ó    <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   S[;R&   S[ ;R&   S[;R&   S[;R	&   S[R
,          ;R&   # )r   Údsl_namer&   r'   r(   Úcond_fnÚimpl_fnÚnode_idÚunconditional_overrideÚactiveNÚtry_initialize_runtime)ÚstrÚ	_OpCondFnÚ	_OpImplFnr   Ú_OpRuntimeInitFn)r   Ú__classdict__s   "€r   r   Ú_OverrideNode.__annotate__9   sˆ   ø‡ ‚ ñ �Mñ	 ñ
 �Oñ ñ �Nñ ñ Ññ ñ Ññ ñ Ññ ñ �Lñ ñ !Ñ(ñ ñ  Ññ! ñ" -¨tÕ3Ñ:ò# r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r2   r3   r4   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r9   s   @r   r,   r,   9   s"   ø‡ € á'ð $)ÐØ€FØ6:Ð÷# ƒ r   r,   c                   ó²   a € ] tR t^St o Rt]! ]R7      t]! ]R7      t]! ]R7      t	V 3R lR lt
RV 3R lR lltV 3R lR ltV 3R	 lR
 ltV 3R ltRtV tR# )Ú_FilterStatez+Manages filtering state for override nodes.)Údefault_factoryc                ó&   <€ V ^8„  d   QhRS[ RS[/# )r   Únoder   )r,   r   )r   r9   s   "€r   r   Ú_FilterState.__annotate__[   s   ø€ ÷ ñ ¡-ð ±Dñ r   c                óü   € VP                   '       d   \        4       '       g   R# VP                  V P                  9   d   R# VP                  V P
                  9   d   R# VP                  V P                  9   d   R# R# )a'  
Check if a node is enabled based on current filter state.

Args:
    node: The override node to check

Returns:
    bool: True if the node should be enabled, False if filtered out

An unconditional override is exempt from every filter: its impl is
the op's implementation, not an accelerated route to the same
answer, so disabling by DSL name / op / dispatch key must not
silently change what the op computes. The private mask read by
_unconditional_is_masked() is the sole exception, and exists only so
tests can obtain stock aten reference values.
TF)r2   r   r.   Ú
_dsl_namesr'   Ú_op_symbolsr(   Ú_dispatch_keys)ÚselfrH   s   &&r   Úcheck_enabledÚ_FilterState.check_enabled[   s^   € ð" ×&×&Ð&Ô/G×/IÒ/IÙà�=‰=˜DŸO™OÔ+Ùà�>‰>˜T×-Ñ-Ô-Ùà×Ñ × 3Ñ 3Ô3Ùár   c          
      óÀ   <€ V ^8„  d   QhRS[ S[S[ ,          ,          R,          RS[ S[S[ ,          ,          R,          RS[ S[S[ ,          ,          R,          RS[RR/# )r   Ú	dsl_namesNÚ
op_symbolsÚdispatch_keysÚremove_keysr   )r5   r   r   )r   r9   s   "€r   r   rI   z   sn   ø€ ÷ Iñ Iá™¡#�Õ&¨Õ-ðIñ ™(¡3�-Õ'¨$Õ.ðIñ ™X¡c�]Õ*¨TÕ1ð	Iñ
 ðIð 
ñIr   c                ó  € V'       d„   V ;P                   \        \        V4      4      ,          un         V ;P                  \        \        V4      4      ,          un        V ;P                  \        \        V4      4      ,          un        R# V ;P                   \        \        V4      4      ,          un         V ;P                  \        \        V4      4      ,          un        V ;P                  \        \        V4      4      ,          un        R# )a£  
Update filter sets as (current | new) or (current ~ new).

Args:
    dsl_names: DSL names to add/remove from filter
    op_symbols: Operation symbols to add/remove from filter
    dispatch_keys: Dispatch keys to add/remove from filter
    remove_keys: If True, remove keys from filter; if False, add them

Note:
    Uses set.discard as it doesn't raise an exception if the element
    wasn't in the set to begin with.
N)rK   ÚsetÚ_resolve_iterablerL   rM   )rN   rR   rS   rT   rU   s   &&&&&r   ÚupdateÚ_FilterState.updatez   s©   € ÷( Ø�OŠOœsÔ#4°YÓ#?Ó@Õ@�OØ×Ò¤Ô$5°jÓ$AÓ BÕBÕØ×Ò¤3Ô'8¸Ó'GÓ#HÕH×à�OŠOœsÔ#4°YÓ#?Ó@Õ@�OØ×Ò¤Ô$5°jÓ$AÓ BÕBÕØ×Ò¤3Ô'8¸Ó'GÓ#HÕH×r   c                óJ   <€ V ^8„  d   QhRS[ S[S[S[S[3,          ,          /# r   )rW   Útupler5   )r   r9   s   "€r   r   rI   —   s$   ø€ ÷ 
ñ 
¡s©5±±c¹3°Õ+?Õ'@ñ 
r   c                óX   € \        V P                  V P                  V P                  4      # )z’
Build a set of dictionary keys based on the current filter state.

Returns:
    set[tuple[str, str, str]]: (lib_symbol, op_symbol, dispatch_key)
)Ú_build_key_setrK   rL   rM   )rN   s   &r   Úbuild_disable_key_setÚ"_FilterState.build_disable_key_set—   s*   € ô Ø�O‰OØ×ÑØ×Ñó
ð 	
r   c                ó    <€ V ^8„  d   QhRS[ /# r   ©r5   )r   r9   s   "€r   r   rI   ¤   s   ø€ ÷ ñ ™ñ r   c                óf  € RpVR,          pVR,          p\        V P                  4       F  w  r#VRV RV R2,          pK  	  VR,          p\        V P                  4       F  w  r$VRV RV R2,          pK  	  VR,          p\        V P                  4       F  w  r%VRV RV R2,          pK  	  V# )	z-Return string representation of filter state.Ú zFilter State:
z  === DSL: ===
ú    z: Ú
z  === OP SYMBOL: ===
z  === DISPATCH KEYS: ===
)Ú	enumeraterK   rL   rM   )rN   ÚsÚiÚdslÚopÚkeys   &     r   Ú__str__Ú_FilterState.__str__¤   sÈ   € àˆØ	ÐÕˆØ	ÐÕˆÜ §¡Ö0‰FˆAØ�4˜�s˜"˜S˜E Ð$Õ$ŠAñ 1à	Ð%Õ%ˆÜ˜t×/Ñ/Ö0‰EˆAØ�4˜�s˜"˜R˜D Ð#Õ#ŠAñ 1à	Ð)Õ)ˆÜ × 3Ñ 3Ö4‰FˆAØ�4˜�s˜"˜S˜E Ð$Õ$ŠAñ 5ð ˆr   c                ón   <€ V ^8„  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r   rK   rL   rM   )rW   r5   )r   r9   s   "€r   r   rI   S   s8   ø‡ ‚ ñ ‘C•Ñ5ñ	 ñ
 ‘S•Ñ6ñ ñ ™•HÑ9ò r   r   N©F)r;   r<   r=   r>   r?   r   rW   rK   rL   rM   rO   rY   r_   rm   r@   rA   rB   rC   s   @r   rE   rE   S   sX   ø‡ € á5á °Ô5€JÙ!°#Ô6€KÙ$°SÔ9€N÷ð ÷>Iò I÷:
ð 
÷ð ÷c ƒ r   rE   c                ó$   € V ^8„  d   QhR\         /# r   r   )r   s   "r   r   r   Ù   s   € ÷ ñ ¬ñ r   c                  óF  a€ R  V3R llo\         ;QJ d    V3R lV  4       F  '       g   K   RM	  RM! V3R lV  4       4      ;'       gW    \         ;QJ d-    V3R lVP                  4        4       F  '       g   K   R# 	  R# ! V3R lVP                  4        4       4      # )c                ó$   € V ^8„  d   QhR\         /# r   r   )r   s   "r   r   Ú%_has_cow_tensor.<locals>.__annotate__Ú   s   € ÷ ñ œdñ r   c                 ó
  <€ \        V \        P                  4      '       d    \        P                  P	                  V 4      # \        V \
        \        34      '       d;   \        ;QJ d    V3R  lV  4       F  '       g   K   R# 	  R# ! V3R  lV  4       4      # \        V \        4      '       dW   \        ;QJ d-    V3R lV P                  4        4       F  '       g   K   R# 	  R# ! V3R lV P                  4        4       4      # R# )c              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5i©Nr   ©Ú.0ÚitemÚis_cow_tensors   & €r   Ú	<genexpr>Ú9_has_cow_tensor.<locals>.is_cow_tensor.<locals>.<genexpr>Þ   s   øé € Ð;±s¨t‘} T×*Ð*³sùó   ƒTFc              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5irw   r   rx   s   & €r   r|   r}   à   s   øé € ÐD±|¨t‘} T×*Ð*³|ùr~   )
Ú
isinstancer   ÚTensorr   Ú_is_cow_tensorÚlistr\   ÚanyÚdictÚvalues)Úargr{   s   &€r   r{   Ú&_has_cow_tensor.<locals>.is_cow_tensorÚ   s¨   ø€ Ü�cœ5Ÿ<™<×(Ò(Ü—8‘8×*Ñ*¨3Ó/Ð/Ü�cœD¤%˜=×)Ò)ß“3Ô;±sÓ;—3”3Ð;’3Ð;�3Ô;±sÓ;Ó;Ð;Ü�cœ4× Ò ß“3ÔD°s·z±z´|ÓD—3”3ÐD’3ÐD�3ÔD°s·z±z´|ÓDÓDÐDÙr   c              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5irw   r   ©ry   r‡   r{   s   & €r   r|   Ú"_has_cow_tensor.<locals>.<genexpr>ã   s   øé € Ð2©T c‰}˜S×!Ð!«Tùr~   TFc              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5irw   r   rŠ   s   & €r   r|   r‹   ã   s   øé € ð :Ù&5˜s‰�c×Ð£oùr~   )r„   r†   )ÚargsÚkwargsr{   s   *,@r   Ú_has_cow_tensorr�   Ù   s}   ø€ ÷ð ÷ ‹3Ô2©TÓ2�3�3Š3Ô2©TÓ2Ó2÷ ð ·c³cô :Ø&,§m¡m¤oó:·c´cð ²cð °cô :Ø&,§m¡m¤oó:ó 7ð r   ÚatenÚtorch_nnc                ó8  € V ^8„  d   QhR\         \        \         ,          ,          R,          R\         \        \         ,          ,          R,          R\         \        \         ,          ,          R,          R\        \        \         \         \         3,          ,          /# )r   rR   NrS   rT   r   )r5   r   rW   r\   )r   s   "r   r   r     sj   € ÷ !ñ !Ü”Xœc•]Õ" TÕ)ð!ä”hœs•mÕ# dÕ*ð!ô œ¤#�Õ&¨Õ-ð!ô 	ŒŒs”Cœˆ}Õ	Õñ	!r   c                ó|   a€ \        4       oR V3R llpV! V \        4       V! V\        4       V! V\        4       S# )a.  
Build a set of dictionary keys based on filter criteria.

Args:
    dsl_names: DSL names to include in key set
    op_symbols: Operation symbols to include in key set
    dispatch_keys: Dispatch keys to include in key set

Returns:
    set[tuple[str, str, str]]: (lib_symbol, op_symbol, dispatch_key)
c                ón   € V ^8„  d   QhR\         \        \         ,          ,          R,          R\        RR/# )r   ÚentriesNÚgraph_lib_dictr   )r5   r   Ú_MappingType)r   s   "r   r   Ú$_build_key_set.<locals>.__annotate__#  s2   € ÷ 	%ñ 	%Ü”x¤•}Õ$ tÕ+ð	%Ü=Ið	%à	ñ	%r   c                ó€   <€ \        V 4      pV F+  pW19   g   K  W,           F  pSP                  V4       K  	  K-  	  R# )z;Helper to add matching keys from graph_lib_dict to key_set.N)rX   Úadd)r•   r–   Úresolved_entriesÚentryrl   Úkey_sets   &&   €r   Ú_append_to_setÚ&_build_key_set.<locals>._append_to_set#  s<   ø€ ô -¨WÓ5Ðã%ˆEØÖ&Ø)×0Ð0�CØ—K‘K Ö$ó 1ó &r   )rW   Ú_dsl_name_to_lib_graphÚ_op_symbol_to_lib_graphÚ_dispatch_key_to_lib_graph)rR   rS   rT   rž   r�   s   &&& @r   r^   r^     s>   ø€ ô  *-«€G÷	%ð 	%ñ �9Ô4Ô5Ù�:Ô6Ô7Ù�=Ô"<Ô=à€Nr   Úprint_inactiveFc                ó(   € V ^8„  d   QhR\         RR/# )r   r£   r   Nr   )r   s   "r   r   r   5  s   € ÷ ñ ¬dð ¸tñ r   c           	     ój  € \         P                  4        Fš  w  w  rr4\        RV: RV: RV: 24       \        V4       Fl  w  rVVP                  '       g   V '       g   K!  RV RVP
                  : RVP                  : 2pV '       d   VRVP                  : 2,          p\        V4       Kn  	  Kœ  	  R# )	zn
Print all override graphs for debugging purposes.

Args:
    print_inactive: Whether to print inactive nodes
zlib=z, op=z, key=re   z: node.dsl_name=z, node.unconditional_override=z node.active=N)r!   r"   Úprintrg   r3   r.   r2   )r£   Úlibrk   rl   Ú	node_listri   rH   rh   s   $       r   Ú_print_override_graphsr©   5  s™   € ô &-§]¡]¦_Ñ!‰ˆ�#Ü��‘�f˜™˜W ™vÐ&Ô'ä  Ö+‰GˆAØ�{�{ˆ{Ÿn™nØ ˜sÐ"3 T§]¡]Ñ$4Ð4S°t×7RÑ7RÑ6TÐU�ß!Ø˜>˜TŸ[™[™NÐ+Õ+�Aä�a–ó ,ó &5r   c                óX   € V ^8„  d   QhR\         R\        P                  P                  /# )r   Ú	namespacer   ©r5   r   ÚlibraryÚLibrary)r   s   "r   r   r   U  s$   € ÷  ñ  ¤ð  ¬¯©×(=Ñ(=ñ  r   c                 ó€   € V \         9  d(   \        P                  P                  V R 4      \         V &   \         V ,          # )ÚFRAGMENT)Ú	_def_libsr   r­   r®   )r«   s   &r   Ú_get_def_libraryr²   U  s0   € Øœ	Ô!Ü$Ÿ}™}×4Ñ4°YÀ
ÓKŒ	�)ÑÜ�YÕÐr   c                óX   € V ^8„  d   QhR\         R\        P                  P                  /# )r   r(   r   r¬   )r   s   "r   r   r   [  s$   € ÷ ñ ¬ð ´·±×1FÑ1Fñ r   c                óŠ   € RV 3pV\         9  d)   \        P                  P                  RRV 4      \         V&   \         V,          # )z…
Get or create the _native IMPL library for a given dispatch key.

One library per dispatch key is shared across all overridden ops.
Ú_nativeÚIMPL)Ú_libsr   r­   r®   )r(   rl   s   & r   Ú_get_or_create_libraryr¸   [  s<   € ð �lÐ
#€CØ
”%ÔÜ—]‘]×*Ñ*¨9°f¸lÓKŒˆc‰
ä��:Ðr   c          
      óL   € V ^8„  d   QhR\         R\         R\         R\        RR/# )r   r&   r'   r(   Úkernelr   N)r5   r   )r   s   "r   r   r   j  s4   € ÷ ñ ÜðÜ #ðÜ36ðÜ@Hðà	ñr   c                óÞ   € WV3p\         P                  VR4      pVe   VP                  4        \        P                  P                  V RV4      pVP                  WVRR7       V\         V&   R# )z÷
Install (or replace) a kernel at (lib_symbol, op_symbol, dispatch_key).

Creates a fresh Library per (lib, op, key) so we can tear down just this
one override via `_destroy_override` without affecting any other
override at the same dispatch key.
Nr¶   T)Úwith_keyset)Ú_override_libsÚpopÚ_destroyr   r­   r®   Úimpl)r&   r'   r(   rº   rl   Úexistingr§   s   &&&&   r   Ú_install_overriderÂ   j  sh   € ð  ,Ð
/€Cô ×!Ñ! # tÓ,€HØÒØ×ÑÔä
�-‰-×
Ñ
 
¨F°LÓ
A€CØ‡H�HˆY ¸$€HÔ?Ø„N�3Ór   c                ó@   € V ^8„  d   QhR\         R\         R\         RR/# )r   r&   r'   r(   r   Nrb   )r   s   "r   r   r   �  s(   € ÷ ñ ¤#ð ´#ð ÄSð ÈTñ r   c                ób   € \         P                  WV3R4      pVe   VP                  4        R# R# )zHTear down the override at (lib_symbol, op_symbol, dispatch_key), if any.N)r½   r¾   r¿   )r&   r'   r(   r§   s   &&& r   Ú_destroy_overriderÅ   �  s,   € ä
×
Ñ
˜j°\ÐBÀDÓ
I€CØ
‚Ø�‰Žñ r   c                ó4   € V ^8„  d   QhR\         R\         RR/# )r   r&   r'   r   ztorch._ops.OpOverload | Nonerb   )r   s   "r   r   r   ˆ  s$   € ÷ ñ ÜðÜ #ðà#ñr   c                óÆ   € VP                  R4      w  r#pT;'       g    Rp \        \        \        P                  V 4      V4      p\        WT4      #   \         d     R# i ; i)ud  
Resolve `op_symbol` to a concrete OpOverload on `torch.ops.<lib_symbol>`.

Accepts bare names ("bmm" â†’ aten.bmm.default) and overload-qualified
names ("add_.Tensor" â†’ aten.add_.Tensor). Returns None if the op is not
registered (e.g. a test-only op_symbol that never hit the C++ dispatcher,
or a namespace whose defining module has not been imported).
Ú.ÚdefaultN)Ú	partitionÚgetattrr   ÚopsÚAttributeError)r&   r'   ÚnameÚ_Úoverload_nameÚpackets   &&    r   Ú_resolve_overloadrÒ   ˆ  s_   € ð '×0Ñ0°Ó5Ñ€Dˆ]Ø!×.Ð. Y€MðÜœ¤§¡¨JÓ7¸Ó>ˆÜ�vÓ-Ð-øÜô Úðús   ¢.A ÁA ÁA c                ó<   € V ^8„  d   QhR\         R\         R\         /# )r   r&   r'   r   rb   )r   s   "r   r   r   œ  s!   € ÷ ñ œSð ¬Sð ´Sñ r   c                óÆ   € \        W4      pVf   \        V  RV R24      h\        VP                  4      pVP	                  R^4      w  rEVP	                  R^4      w  rFRV 2# )uÔ   Return the schema of <lib_symbol>::<op_symbol> with the
`<lib_symbol>::<name>` prefix stripped.

Accepts bare names ("bmm" â†’ aten.bmm.default) and overload-qualified
names ("add_.Tensor" â†’ aten.add_.Tensor).
ú::zQ not found; is the namespace correct and the module that defines the op imported?Ú()rÒ   rÍ   r5   Ú_schemaÚsplit)r&   r'   Úoverloadrh   rÏ   Úrestr�   s   &&     r   Ú_schema_tailrÛ   œ  sx   € ô ! Ó7€HØÒÜØˆl˜"˜Y˜Kð (7ð 7ó
ð 	
ô 	ˆH×ÑÓ€Aà�g‰g�d˜AÓ�G€AØ�j‰j˜˜aÓ �G€AØˆtˆfˆ:Ðr   c                ó@   € V ^8„  d   QhR\         R\         R\         RR/# )r   rÎ   r&   r'   r   Nrb   )r   s   "r   r   r   °  s(   € ÷ "ñ "¤ð "´#ð "Ä#ð "È$ñ "r   c                 ó  € V \         9   d   R # \        R4      P                  V  \        W4       24       \	        W4      p\
        P                  P                  RV  24      ! RV/R l4       \         P                  V 4       R # )Nrµ   z	_native::Ú_orig_overloadc                 ó   € V ! V/ VB # rw   r   )rÞ   r�   rŽ   s   $*,r   Ú<lambda>Ú(_define_native_op_once.<locals>.<lambda>¾  s   € ¹nØð?
Øò?
r   )	Ú_defined_native_opsr²   ÚdefinerÛ   rÒ   r   r­   Úregister_fakerš   )rÎ   r&   r'   Úorig_overloads   &&& r   Ú_define_native_op_onceræ   °  sx   € ð Ô"Ô"ÙÜ�YÓ×&Ñ&¨$¨´¸ZÓ0SÐ/TÐ'UÔVô & jÓ<€MÜ	‡M�M×Ñ )¨D¨6Ð 2Ô3ð	
 ]ó 	
ôô ×Ñ˜DÖ!r   c                óh   € V ^8„  d   QhR\         P                  P                  R\        R\        RR/# )r   r§   rH   r(   r   N)r   r­   r®   r,   r5   )r   s   "r   r   r   Ì  s6   € ÷ ñ Ü	�‰×	Ñ	ðÜ&3ðÜCFðà	ñr   c                ó$  € VP                   '       g)   \        RVP                  : RVP                  : R24      h\	        VP                   VP
                  VP                  4       V P                  VP                   VP                  VRRR7       R# )zÈ
Register a single node implementation with the library.

Args:
    lib: The torch.library.Library instance
    node: The override node to register
    dispatch_key: The dispatch key for registration
zJ_OverrideNode must have a non-empty node_id before registration (dsl_name=z, op_symbol=Ú)FT)r¼   Úallow_overrideN)r1   Ú
ValueErrorr.   r'   ræ   r&   rÀ   r0   )r§   rH   r(   s   &&&r   Ú_register_node_implrì   Ì  s~   € ð �<�<ˆ<ÜðØŸ™Ñ)¨°d·n±nÑ5GÀqðJó
ð 	
ô ˜4Ÿ<™<¨¯©¸$¿.¹.ÔIØ‡H�HØ�‰Ø�‰ØØØð ö r   c                ó€   € V ^8„  d   QhR\         \        \         ,          ,          R,          R\        \         ,          /# )r   ÚiterableNr   )r5   r   )r   s   "r   r   r   æ  s,   € ÷ ñ ¤¤h¬s¥mÕ 3°dÕ :ð ¼xÌ½}ñ r   c                óp   € V f   . # \        V \        4      '       d   \        V \        4      '       d   V 3# V # )z´
Resolve various input types to a consistent iterable of strings.

Args:
    iterable: String, iterable of strings, or None

Returns:
    Iterable[str]: Consistent iterable output
)r€   r   r5   )rî   s   &r   rX   rX   æ  s5   € ð ÒØˆ	ä�h¤×)Ò)¬Z¸Ä#×-FÒ-FØˆ{Ðà€Or   Úenable_dsl_namesÚenable_op_symbolsÚenable_dispatch_keysc                óî   € V ^8„  d   QhR\         \        \         ,          ,          R,          R\         \        \         ,          ,          R,          R\         \        \         ,          ,          R,          RR/# )r   rð   Nrñ   rò   r   ©r5   rƒ   )r   s   "r   r   r   ù  sY   € ÷ 9ñ 9äœD¤�I•o¨Õ,ð9ô œT¤#�Y•¨Õ-ð9ô ¤¤S¥	�/¨DÕ0ð	9ð
 
ñ9r   c           	     óö   € \         P                  RV VV4       \        P                  V VVRR7       \	        V VV4      pV F4  pVw  rVpV\
        9   g   K  \        VVV\
        V,          \        R7       K6  	  R# )a  
Re-enable overrides by removing them from filter state and reregistering.

Args:
    enable_dsl_names: DSL names to re-enable
    enable_op_symbols: Operation symbols to re-enable. Matched as bare op
        symbols against every namespace, so ``"scatter_add"`` re-enables
        it wherever it is registered; a qualified ``"ns::op"`` string
        matches nothing.
    enable_dispatch_keys: Dispatch keys to re-enable

Note:
    This function uses reverse filter state management (removing from
    filters to enable).
z>Re-registering ops by dsl: %s, op_symbol: %s, dispatch_key: %sT)rU   r   N)ÚlogÚinfor$   rY   r^   r!   Ú_register_overrides_from_graph)rð   rñ   rò   r�   rl   r&   r'   r(   s   $$$     r   Úreenable_op_overridesrù   ù  sŒ   € ô* ‡H�HØHØØØô	ô ×ÑØØØØð	 ô ô *8ØØØó*€Gó ˆØ.1Ñ+ˆ
˜|à”'Ž>ô +ØØØÜ˜•Ü*÷ó r   Údisable_dsl_namesÚdisable_op_symbolsÚdisable_dispatch_keysc                óî   € V ^8„  d   QhR\         \        \         ,          ,          R,          R\         \        \         ,          ,          R,          R\         \        \         ,          ,          R,          RR/# )r   rú   Nrû   rü   r   rô   )r   s   "r   r   r   5  sY   € ÷ -ñ -äœT¤#�Y•¨Õ-ð-ô œd¤3�i�¨$Õ.ð-ô ¤¤c¥�?¨TÕ1ð	-ð
 
ñ-r   c           	     óþ   € \         P                  RV VV4       \        P                  WV4       \        P	                  4       pV F4  pVw  rVpV\
        9   g   K  \        VVV\
        V,          \        R7       K6  	  R# )aý  
De-register overrides by updating filter state and reregistering graphs.

Args:
    disable_dsl_names: DSL names to disable
    disable_op_symbols: Operation symbols to disable. Matched as bare op
        symbols against every namespace, so ``"scatter_add"`` disables it
        wherever it is registered; a qualified ``"ns::op"`` string matches
        nothing.
    disable_dispatch_keys: Dispatch keys to disable

Note:
    This function uses filter state management to selectively disable
    operations.
z>De-registering ops by dsl: %s, op_symbol: %s, dispatch_key: %sr   N)rö   r÷   r$   rY   r_   r!   r#   )rú   rû   rü   r�   rl   r&   r'   r(   s   $$$     r   Úderegister_op_overridesrÿ   5  sx   € ô* ‡H�HØHØØØô	ô ×ÑÐ*Ð@UÔVô *7×)LÑ)LÓ)N€Gó ˆØ.1Ñ+ˆ
˜|à”'Ž>Ü)ØØØÜ˜•Ü*÷ó	 r   c                óR   € V ^8„  d   QhR\         R\         R\        \         ,          /# )r   r.   r&   r   rô   )r   s   "r   r   r   e  s%   € ÷ ñ ¤ð ´#ð Ä4ÌÅ9ñ r   c                óØ   € \        4       p\        P                  4        F>  w  w  r4rVW18w  d   K  V F(  pVP                  V 8X  g   K  VP	                  V4        K<  	  K@  	  \        V4      # )a«  Get list of operations registered by a specific DSL in one namespace.

Args:
    dsl_name: Name of the DSL to query.
    lib_symbol: Namespace to report on. One namespace per call: op symbols
        are unique within a namespace but not across them, so merging
        would produce a list whose entries cannot be resolved back to an
        op.

Returns:
    Sorted list of op symbols the DSL has registered on `lib_symbol`.
)rW   r!   r"   r.   rš   Úsorted)r.   r&   Ú
operationsr§   r'   rÏ   ÚnodesrH   s   &&      r   Úget_dsl_operationsr  e  s^   € ô “€JÜ&-§m¡m¦oÑ"Ñˆ˜ØÔÙÛˆDØ�}‰} Ö(Ø—‘˜yÔ)Úó ñ '6ô �*ÓÐr   c                óx   € V ^8„  d   QhR\         R\         R\         R\        \         \         \         3,          RR/# )r   r.   r'   r(   rl   r   N)r5   r\   )r   s   "r   r   r   }  sL   € ÷ #Lñ #LÜð#Läð#Lô ð#Lô 
Œs”Cœˆ}Õ	ð	#Lð
 
ñ#Lr   c                ó`   € R R lpV! \         W4       V! \        W4       V! \        W#4       R# )zº
Update the registration mapping dictionaries.

Args:
    dsl_name: The DSL name
    op_symbol: The operation symbol
    dispatch_key: The dispatch key
    key: The dictionary key tuple
c          	      óÐ   € V ^8„  d   QhR\         \        \        \        \        \        \        3,          ,          3,          R\        R\        \        \        \        3,          RR/# )r   ÚregistrationÚsymbolrl   r   N)r…   r5   rƒ   r\   )r   s   "r   r   Ú/_update_registration_maps.<locals>.__annotate__�  sU   € ÷ #ñ #Üœ3¤¤U¬3´´S¨=Õ%9Õ :Ð:Õ;ð#äð#ô ”3œœS�=Õ!ð#ð 
ñ	#r   c                ód   € V P                  V4      pVf
   V.pW0V&   R# VP                  V4       R# )z;Helper to add key to registration list or create new entry.N)ÚgetÚappend)r	  r
  rl   Ú
entry_lists   &&& r   Ú_get_new_entry_or_appendÚ;_update_registration_maps.<locals>._get_new_entry_or_append�  s7   € ð "×%Ñ% fÓ-ˆ
àÒØ˜ˆJØ#-˜Ó à×Ñ˜cÖ"r   N)r    r¡   r¢   )r.   r'   r(   rl   r  s   &&&& r   Ú_update_registration_mapsr  }  s*   € õ&#ñ Ô3°XÔCÙÔ4°iÔEÙÔ7¸ÖKr   c                ó<   € V ^8„  d   QhR\         R\         R\        /# )r   r�   rŽ   r   )Úobjectr   )r   s   "r   r   r   £  s!   € ÷ ñ œð ¬&ð ´Tñ r   c                  ó   € R # )Tr   )r�   rŽ   s   *,r   Ú_always_truer  £  s   € Ùr   r4   Úallow_multiple_overrider2   c                ó¤   € V ^8„  d   QhR\         R\         R\         R\         R\        R,          R\        R\        R,          R	\        R
\        RR/
# )r   Úbackendr&   r'   r(   ÚcondNrÀ   r4   r  r2   r   )r5   r6   r7   r8   r   )r   s   "r   r   r   §  sŽ   € ÷ fIñ fIÜðfIäðfIô ðfIô ð	fIô
 �dÕ
ðfIô ðfIô -¨tÕ3ðfIô "ðfIô !ðfIð 
ñfIr   c               óú  € V\         9  d!   \        RV: R\        \         4       R24      hV\        9   d   \        RV: R24      hV'       d   Ve   \        R4      hVf   V'       g   \        R4      h\        pWV3p	\
        P                  V	. 4      p
VP                  R	R
4      pV R
V  R
\         2p\        ^,          sV
P                  \        V VVVVVVVVR7	      4       V
\
        V	&   \        WW9R7       R# )a­  
Register a passed override function to the dispatcher.

Actually a graph-building operation; real registration happens later.

Args:
    backend: The backend name (DSL name)
    lib_symbol: Namespace of the op you're overriding. Must be listed in
        `_ALLOWED_LIB_SYMBOLS`; see the comment there before adding one.
        The op must already be defined in the dispatcher when overrides
        are installed, so a namespace defined by a lazily-imported module
        has to be imported by the caller first.
    op_symbol: Name of the operation you're overriding
    dispatch_key: Dispatch key to override
    cond: Predicate choosing whether `impl` applies to a given call. May
        be None if `unconditional_override=True`.
    impl: Implementation function for the override
    try_initialize_runtime: Optional initialization hook run after `cond`
        matches and immediately before `impl`. A false result continues
        routing; the hook is not run during compile/export routing.
    allow_multiple_override: Allow overriding an existing override
    unconditional_override: This impl IS the op's implementation, not a
        faster route to the same answer. It doesn't have a fallback and
        doesn't require torch.DispatchKeySet as the first argument. When
        True, a trivially-True predicate is supplied for the router if
        `cond` is None, AND the override becomes exempt from the
        user-facing filters -- deregister_op_overrides() and
        python_native.<dsl>.disabled() leave it installed, because
        masking it would change results rather than just performance.

Raises:
    ValueError: If lib_symbol is not in _ALLOWED_LIB_SYMBOLS, if
        dispatch_key is in _DISALLOWED_DISPATCH_KEYS (Meta /
        CompositeImplicitAutograd / CompositeExplicitAutograd), or if cond
        is None without unconditional_override=True, or if
        try_initialize_runtime is provided with unconditional_override=True.
zlib_symbol=z% is not overridable; expected one of zI. Namespace support is opt-in -- see the comment on _ALLOWED_LIB_SYMBOLS.zdispatch_key=z® is not supported. Overrides must be installed at a backend key (e.g. CPU, CUDA, XPU); the router's fake kernel redispatches to the overridden op and would recurse otherwise.NzJtry_initialize_runtime cannot be provided with unconditional_override=Truez8cond must be provided unless unconditional_override=TruerÈ   rÏ   )	r.   r&   r'   r(   r/   r0   r4   r2   r1   )rl   )Ú_ALLOWED_LIB_SYMBOLSrë   r  Ú_DISALLOWED_DISPATCH_KEYSr  r!   r  ÚreplaceÚ_node_id_counterr  r,   r  )r  r&   r'   r(   r  rÀ   r4   r  r2   rl   Úop_graphÚ
_sanitizedr1   s   &&&&&&$$$    r   Úregister_op_overrider"  §  s2  € ðb Ô-Ô-ÜØ˜*™Ð'LÜÔ*Ó+Ð,ð -7ð8ó
ð 	
ð Ô0Ô0ÜØ˜LÑ+ð ,ð ó
ð 	
÷ Ð"8Ò"DÜØXó
ð 	
ð ‚|ß%ÜÐWÓXÐXÜˆà ,Ð
/€Cô �{‰{˜3 Ó#€Hð ×"Ñ" 3¨Ó,€JØ�˜A˜g˜Y aÔ(8Ð'9Ð:€GÜ˜ÕÐà‡O�OÜØØ!ØØ%ØØØ#9Ø#9Øô
	
ôð „GˆC�Lä˜g°,×Hr   Úforce_reregisterc                ót   € V ^8„  d   QhR\         \        ,          R\         \        ,          R\        R\        /# )r   Úoriginal_graphÚ	new_graphr#  r   )rƒ   r,   r   )r   s   "r   r   r     s:   € ÷ 'ñ 'ÜœÕ'ð'ä”MÕ"ð'ô ð	'ô
 
ñ'r   c               ó   € V'       d   R# W8g  # )a'  
Determine if a graph needs reregistration based on changes.

Args:
    original_graph: The original graph before modification
    new_graph: The graph after modification
    force_reregister: If True, always reregister regardless of changes

Returns:
    bool: True if reregistration is needed
Tr   )r%  r&  r#  s   &&$r   Ú_should_reregister_graphr(    s   € ÷" Ùð Ñ&Ð&r   r   c                ó|   € V ^8„  d   QhR\         R\         R\         R\        \        ,          R\        R,          RR/# ©r   r&   r'   r(   r)   r   Nr   ©r5   rƒ   r,   rE   )r   s   "r   r   r   (  sN   € ÷ ñ Üðäðô ðô ”Õð	ô  Õ%ðð 
ñr   c               ó&   € \        V VVVVR7       R# )aš  
Reregister a graph's routes from scratch.

Used by reorder / deregister / reenable. Libraries are intentionally
long-lived singletons; we rebuild the per-op router closure here.

Args:
    lib_symbol: The namespace of the overridden op
    op_symbol: The operation symbol
    dispatch_key: The dispatch key
    graph: The graph to register
    filter_state: Optional filter state for conditional registration
r   N)rø   )r&   r'   r(   r)   r   s   &&&&$r   r#   r#   (  s   € ô* #ØØØØØ!÷r   Úkeys_to_processÚreregister_overridesc          
      óª   € V ^8„  d   QhR\         R\        \        \        \        \        3,          ,          R,          R\        R\
        R,          RR/# )r   Útransformation_fnr-  Nr.  r   r   )ÚUserOrderingFnrW   r\   r5   r   rE   )r   s   "r   r   r   F  s]   € ÷ Oñ OÜ%ðOô œœs¤C¬˜}Õ-Õ.°Õ5ðOô ð	Oô
  Õ%ðOð 
ñOr   c          	     ó’  € Ve   TM\        \        P                  4       4      p\        V4       F´  w  rVpWVV3\        9  d   K  \        \        WVV3,          4      p V ! WgV4      p	\        T	\        4      '       g.   \        P                  R\        T	4      P                  TT4       Kz  T	\        YVT3&   T'       g   K�  \        Y‰RR7      '       g   K¤  \!        TTTT	TR	7       K¶  	  R#   \        \
        \        \        3 d    \        P                  RTTRR7        Kñ  \         d    \        P                  RTT4        EK  i ; i)
ad  
Apply a transformation function to graphs and optionally reregister.

This is the core pattern used by reorder_graphs_from_user_function and
can be reused for other graph transformation operations.

Args:
    transformation_fn: Function to transform each graph
    keys_to_process: Keys to process, or None for all graphs
    reregister_overrides: Whether to reregister changed graphs
    filter_state: Optional filter state for conditional registration

Note:
    If transformation_fn raises an exception for a specific graph, that graph
    will be skipped and processing will continue with remaining graphs.
NúAGraph transformation failed for %s/%s. Preserving original graph.T©Úexc_infoúNUnexpected error in graph transformation for %s/%s. Preserving original graph.zbGraph transformation returned invalid type %s for %s/%s. Expected list. Preserving original graph.F)r#  r   )rW   r!   Úkeysrƒ   Ú	TypeErrorrë   rÍ   ÚRuntimeErrorrö   ÚwarningÚ	ExceptionÚ	exceptionr€   Útyper;   r(  r#   )
r0  r-  r.  r   Útarget_keysr&   r'   r(   r%  r&  s
   &$$$      r   Ú_apply_graph_transformationr?  F  sD  € ð6 +Ò6‰¼CÄÇÁÃÓ<Oð ô
 04°KÖ/@Ñ+ˆ
˜|Ø <Ð0¼Ô?Ùäœg z¸lÐ&KÕLÓMˆð	Ù)¨)À>ÓRˆIô$ ˜)¤T×*Ò*Ü�K‰KØtÜ�Y“×(Ñ(ØØô	ñ ð :CŒ�¨Ð5Ñ6÷  ÑÔ$<Ø¸÷%
õ %
ô *ØØØØØ)÷óU 0Aøô œ:¤~´|ÐDô 	Ü�K‰KØSØØØð	 ô ò Üô 	Ü�M‰MØ`ØØôó
 ð	ús   Á	C)Ã)4EÄ EÄ)EÅEc                óR   € V ^8„  d   QhR\         R\        \        \        3,          /# )r   Úoverrides_onlyr   )r   r…   r  r   )r   s   "r   r   r   ˜  s&   € ÷ 3ñ 3Üð3ä	Œ&”(Ð
Õñ3r   c                ór   € V '       d   / pM^ RI Hp \        V! 4       4      pVP                  \        4       V# )aT  
Return a decomposition table suitable for passing to
``ExportedProgram.run_decompositions`` or to Inductor / Dynamo as a
decomposition set for ``torch.compile``.

This is the canonical way to apply native overrides outside of eager.
Callers opt in explicitly -- the registry does **not** install into any
global compile/export decomp table on its own. This preserves three
properties:

  * ``import torch._native`` doesn't transitively import inductor /
    dynamo / triton.
  * No other consumer (ONNX, tests, third-party backends) accidentally
    picks up our overrides.
  * Scoping is up to the caller: pass the table only where routing is
    desired.

By default, the returned table contains
``torch.export.default_decompositions()`` with native-registered
overrides layered on top -- matching typical "run the usual
decompositions, plus my overrides" intent. The override entries win
over any same-op default, because they're merged last.

Example:

    ep = torch.export.export(model, args)
    ep = ep.run_decompositions(
        torch._native.registry.native_decomp_table()
    )

Args:
    overrides_only: If True, return only the native-registered overrides
        and no default aten decompositions. Useful for inspection /
        debugging, or when composing tables manually.

Returns:
    A dict mapping ``OpOverload`` to decomposition callable.
)Údefault_decompositions)Útorch.exportrC  r…   rY   Ú_native_decomp_overrides)rA  ÚtablerC  s   &  r   Únative_decomp_tablerG  ˜  s2   € ÷R Ø(*‰õ 	8äÑ+Ó-Ó.ˆà	‡L�LÔ)Ô*Ø€Lr   c                ó|   € V ^8„  d   QhR\         R\         R\         R\        \        ,          R\        R,          RR/# r*  r+  )r   s   "r   r   r   Î  sV   € ÷ A<ñ A<ÜðA<äðA<ô ðA<ô ”Õð	A<ô  Õ%ðA<ð 
ñA<r   c               ó’  aaaa€ \        V4      p. oV Ft  pRpV'       d   VP                  V4      pV'       dH   \        WVV4       SP                  VP                  VP
                  VP                  34       RVn        Km  RVn        Kv  	  \        W4      p\        WV4       S'       g   Ve   \        P                  VR4       R# \        P                  P                  V  RV 2V4      p	\        4       o^RIHp
 V
P%                  W4      oR VVV3R lloRV	R	V/VV3R
 llpVV3R lp\'        WW+4       Ve   V\        V&   R# R# )a  
Register all overrides in a single graph.

Args:
    lib_symbol: The namespace of the overridden op
    op_symbol: The operation symbol
    dispatch_key: The dispatch key
    graph: List of override nodes to register
    filter_state: Optional filter state for conditional registration
TFNrÕ   )Úaot_manifestc                ó0   € V ^8„  d   QhR\         R\         /# )r   Úswallow_cond_exceptionsÚinitialize_runtimer   )r   s   "r   r   Ú4_register_overrides_from_graph.<locals>.__annotate__)  s    € ÷ ñ ô "&ð	ô
 !ñr   c                óD  <€ Se   SP                  W4      '       d   S	# S
 F`  w  rEp V! V / VB pT'       g   K  T'       d   Te   T! 4       '       g   K4  \        \        P                  P
                  T4      pT! T / TB u # 	  S	#   \         d    T'       g   h  K}  i ; irw   )Úcoversr;  rË   r   rÌ   rµ   )r�   rŽ   rL  rM  r  Ú	impl_namer4   ÚmatchedÚnative_implÚ	_NO_MATCHÚ	cond_implÚcoverages   &&$$     €€€r   Ú	_dispatchÚ1_register_overrides_from_graph.<locals>._dispatch)  s¨   ø€ ð Ò H§O¡O°D×$AÒ$AØÐÛ7@Ñ3ˆDÐ3ðÙ Ð/¨Ñ/�÷
 ‰wç&Ø.Ò:Ù2×4Ò4áÜ%¤e§i¡i×&7Ñ&7¸ÓC�Ù" DÐ3¨FÑ3Ò3ñ 8Að  Ðøô ô ß.ØÚðús   ¨BÂBÂBÂBÚ	_fallbackrÞ   c               óV  <€ \         P                  P                  4       '       dL   VeH   \        \        RR4      '       g1   \        V/ VB '       g    R\        n         V! V/ VB R\        n        # S! VVRRR7      pVSJ d   VP                  ! V .VO5/ VB # V#   R\        n        i ; i)aÝ  Boxed eager kernel: divert to the original op while Dynamo traces,
else dispatch.

The shortcut is only safe while Dynamo is actively tracing this
Python router. The broader compile-session flag can be true when this
router executes eagerly; redispatching to the original op there would
re-enter us.

`is_dynamo_compiling()` cannot tell those apart on its own: it is not a
runtime flag but `return False`, which Dynamo folds to a True constant
at trace time (tracing_state_functions in _dynamo/variables/torch.py).
A frame carrying that folded constant can still execute eagerly -- then
`_orig_overload(...)` re-enters the dispatcher from the top, lands back
in this router, and recurses until RecursionError. Reproduced by OpInfo
test_out_warning_scatter_add under PYTORCH_TEST_WITH_INDUCTOR once a
native override is installed for the op.

`_router_active` breaks that cycle: the outer call takes the shortcut
(so real tracing still records the plain original op and avoids the
graph breaks of #186354), and a re-entrant call falls through to normal
eager dispatch below. Deliberately narrow -- the trace-time behavior the
flag exists for is unchanged, since under tracing the overload call does
not come back here.

COW state is guarded by Dynamo's _is_cow_tensor handler but is not
modeled in the compiled graph. If a COW input reaches this router, keep
the existing eager path so COW-preserving fallback semantics are
maintained instead of compiling through the original op and
materializing it.
ÚonFT©rL  rM  )r   ÚcompilerÚis_dynamo_compilingrË   Ú_router_activer�   r[  Ú
call_boxed)ÚkeysetrY  rÞ   r�   rŽ   ÚresultrT  rW  s   &$$*, €€r   Úeager_routerÚ4_register_overrides_from_graph.<locals>.eager_routerE  s¬   ø€ ôD �N‰N×.Ñ.×0Ò0ØÒ*ÜœN¨D°%×8Ò8Ü# TÐ4¨V×4Ð4à $ŒNÔð*Ù% tÐ6¨vÑ6à$)”Õ!áØØØ$)Ø#ô	
ˆð �YÓØ×'Ò'¨Ð@°Ò@¸Ñ@Ð@Øˆøð %*”Õ!ús   ÁB ÂB(c                  ó8   <€ S! V VR RR7      pVSJ d   \         # V# )TFr\  )ÚNotImplemented)r�   rŽ   rb  rT  rW  s   *, €€r   Úcompile_routerÚ6_register_overrides_from_graph.<locals>.compile_router|  s.   ø€ ÙØØØ$(Ø$ô	
ˆð �YÓÜ!Ð!Øˆr   )r¸   rO   rì   r  r/   r1   r4   r3   rÒ   rÅ   rE  r¾   r   r­   Ú
get_kernelr  rd   rJ  Úget_coveragerÂ   )r&   r'   r(   r)   r   r§   rH   ÚenablerÙ   Úfallback_kernelrJ  rc  rg  rT  rW  rU  rV  s   &&&&$        @@@@r   rø   rø   Î  s>  û€ ô$ ! Ó
.€CàFH€Ió
 ˆØˆßØ!×/Ñ/°Ó5ˆFçÜ ¨<Ô8Ø×Ñ˜dŸl™l¨D¯L©L¸$×:UÑ:UÐVÔWØˆDŽKàˆDŽKñ ô ! Ó7€Hô �j¨\Ô:÷ ØÒÜ$×(Ñ(¨°4Ô8Ùô —m‘m×.Ñ.Øˆ,�b˜˜Ð$ ló€Oô& “€Iõ à×(Ñ(¨ÓA€H÷ò ð85Ø!0ð5ØAI÷5ð 5ön	ô �j¨\ÔHð ÒØ-;Ô  Ó*ñ r   c                ó   € V ^8„  d   QhRR/# )r   r   Nr   )r   s   "r   r   r   ’  s   € ÷ 
ñ 
 ñ 
r   c                 óf   € \         P                  4        F  w  rV w  r#p\        VVVV4       K  	  R# )zG
Perform all registration calls from previously-built override graphs.
N)r!   r"   rø   )rl   r)   r&   r'   r(   s        r   Ú_register_all_overridesro  ’  s4   € ô —m‘m–o‰
ˆØ.1Ñ+ˆ
˜|ä&ØØØØö		
ó &r   c                ó4   € V ^8„  d   QhR\         R\        RR/# )r   Úfnr.  r   N)r1  r   )r   s   "r   r   r   ¡  s(   € ÷ ñ Üðô ðð 
ñ	r   c               ó    € \        V VR7       R# )a’  
Reorder override graphs using a user-provided ordering function.

Args:
    fn: User-provided function that takes (op_symbol, dispatch_key, graph)
        and returns a reordered graph
    reregister_overrides: Whether to reregister graphs that have changed

Note:
    This function uses the common graph transformation pattern and can serve
    as an example for other graph manipulation operations.
©r0  r.  N©r?  )rq  r.  s   &$r   Ú!reorder_graphs_from_user_functionru  ¡  s   € ô"  ØØ1÷r   c                ól   € V ^8„  d   QhR\         \        \        \        .\        3,          R\        RR/# )r   Ú	filter_fnr.  r   N)r   r5   r,   r   )r   s   "r   r   r   ¸  s9   € ÷ 5ñ 5Üœœc¤=Ð1´4Ð7Õ8ð5ô ð5ð 
ñ	5r   c               ó4   a € R V 3R llp\        VVR7       R# )a´  
Apply a filter function to remove nodes from graphs.

This is a convenience function that uses the graph transformation pattern
to filter out unwanted nodes.

Args:
    filter_fn: Function that takes (op_symbol, dispatch_key, node) and
        returns True to keep the node, False to remove it
    reregister_overrides: Whether to reregister modified graphs

Example:
    # Remove all nodes with "deprecated" in the DSL name
    _apply_graph_filter(
        lambda op, dk, node: "deprecated" not in node.dsl_name,
        reregister_overrides=True
    )

Note:
    If filter_fn raises an exception for a specific graph, the original
    graph will be preserved and processing will continue.
c          	      ót   € V ^8„  d   QhR\         R\         R\        \        ,          R\        \        ,          /# ©r   r'   r(   r)   r   ©r5   rƒ   r,   )r   s   "r   r   Ú)_apply_graph_filter.<locals>.__annotate__Ô  s6   € ÷ ñ ÜðÜ&)ðÜ26´}Õ2Eðä	ŒmÕ	ñr   c                ó  <€  V Uu. uF  pS! WV4      '       g   K  VNK  	  up# u upi   \         \        \        \        3 d    \        P                  RT TRR7       Tu # \         d    \        P                  RT T4       Tu # i ; i)z-Apply filter_fn to graph with error handling.r3  Tr4  r6  ©r8  rë   rÍ   r9  rö   r:  r;  r<  )r'   r(   r)   rH   rw  s   &&& €r   Úfiltering_transformationÚ5_apply_graph_filter.<locals>.filtering_transformationÔ  sŒ   ø€ ð	Ù%*ÓW¡U˜T©i¸	ÐQU×.V—D�D¡UÑWÐWùÒWøÜœ:¤~´|ÐDô 	Ü�K‰KØSØØØð	 ô ð ŠLÜô 	Ü�M‰MØ`ØØôð
 ŠLð	ús+   ƒ+ ‡&�&£+ ¦+ «6B	Á#B	Á,B	ÂB	rs  Nrt  )rw  r.  r  s   f$ r   Ú_apply_graph_filterr�  ¸  s   ø€ ÷8ð ô,  Ø2Ø1÷r   c                ón   € V ^8„  d   QhR\         \        \        .\        3,          R\        R\        RR/# )r   Úcondition_fnÚordering_fnr.  r   N)r   r5   r   r1  )r   s   "r   r   r   ð  sD   € ÷ Lñ LÜœC¤˜:¤tÐ+Õ,ðLäðLô ð	Lð
 
ñLr   c               ó8   a a€ R V V3R llp\        VVR7       R# )aý  
Apply reordering only to graphs that match a condition.

This allows for more targeted reordering operations.

Args:
    condition_fn: Function that takes (op_symbol, dispatch_key) and
        returns True if the graph should be reordered
    ordering_fn: Ordering function to apply to matching graphs
    reregister_overrides: Whether to reregister modified graphs

Example:
    # Only reorder CUDA operations
    _apply_selective_reordering(
        condition_fn=lambda op, dk: dk == "CUDA",
        ordering_fn=lambda op, dk, g: sorted(g, key=lambda n: n.dsl_name),
        reregister_overrides=True
    )

Note:
    If condition_fn or ordering_fn raises an exception for a specific graph,
    the original graph will be preserved and processing will continue.
c          	      ót   € V ^8„  d   QhR\         R\         R\        \        ,          R\        \        ,          /# rz  r{  )r   s   "r   r   Ú1_apply_selective_reordering.<locals>.__annotate__  s6   € ÷ )ñ )Üð)Ü&)ð)Ü26´}Õ2Eð)ä	ŒmÕ	ñ)r   c                óÂ  <€  S! W4      pT'       d    S! YT4      # T#   \         \        \        \        3 d    \        P                  RT TRR7       Tu # \         d    \        P                  RT T4       Tu # i ; i  \         \        \        \        3 d    \        P                  RT TRR7       Tu # \         d    \        P                  RT T4       Tu # i ; i)z=Apply ordering_fn conditionally based on condition_fn result.r3  Tr4  r6  r~  )r'   r(   r)   Úshould_reorderrƒ  r„  s   &&& €€r   Úconditional_transformationÚ?_apply_selective_reordering.<locals>.conditional_transformation  sô   ø€ ð	Ù)¨)ÓBˆN÷" ðÙ" 9¸EÓBÐBð" ˆøôG œ:¤~´|ÐDô 	Ü�K‰KØSØØØð	 ô ð ŠLÜô 	Ü�M‰MØ`ØØôð
 ŠLð	ûô œz¬>¼<ÐHô Ü—‘ØWØØ Ø!ð	 ô ð ’Üô Ü—‘ØdØØ ôð
 ’ðús8   ƒ ”B  Ÿ6A=ÁA=Á A=Á<A=Â 6CÂ8CÃCÃCrs  Nrt  )rƒ  r„  r.  rŠ  s   ff$ r   Ú_apply_selective_reorderingrŒ  ð  s   ù€ ÷<)ñ )ôV  Ø4Ø1÷r   c                ó°  € V ^8„  d   Qh/ ^ \         9   d
   \        ;R&   ^\         9   d@   \        \        \        \        3,          \
        P                  P                  3,          ;R&   ^\         9   d   \        \        \        3,          ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R&   ^\         9   d
   \        ;R&   ^\         9   d   \        \        ,          ;R	&   ^	\         9   d   \        \        ,          ;R
&   ^
\         9   d/   \        \        \
        P                  P                  3,          ;R&   ^\         9   d   \        \        ,          ;R&   ^\         9   dE   \        \        \        \        \        3,          \
        P                  P                  3,          ;R&   # )r   r$   r·   rE  r!   r    r¢   r¡   r  r  r  r±   râ   r½   )Ú__conditional_annotations__rE   r…   r\   r5   r   r­   r®   r  r   Ú_GraphsTyper—   ÚintÚ	frozensetrW   )r   s   "r   r   r      su  € ‡�÷j -Ò ,Œ|Ñ ,ñk ÷p 9Ò 8„tŒE”#”s�(�OœUŸ]™]×2Ñ2Ð2Õ3Ñ 8ñq ÷^ 6Ò 5œ$œv¤xÐ/Õ0Ñ 5ñ_ ÷V Ò ŒÑ ñW ÷` *Ò )œÑ )ña ÷b .Ò -œLÑ -ñc ÷d +Ò *œÑ *ñe ÷n Ò ”#Ñ ño ÷~ò œ9¤S�>ñ ñ ÷Z GÒ F”i¤•nÑ Fñ[ ÷P
 1Ò 0Œ4””U—]‘]×*Ñ*Ð*Õ+Ñ 0ñQ
 ÷T
 &Ò %”Sœ•XÑ %ñU
 ÷b
 GÒ F””Uœ3¤¤S˜=Õ)¬5¯=©=×+@Ñ+@Ð@ÕAÑ Fòc
 r   )r1  r"  ru  rù   rÿ   r  rG  >   ÚMetaÚCompositeExplicitAutogradÚCompositeImplicitAutograd)r�   rp   )PrŽ  ÚloggingÚ	threadingÚcollections.abcr   r   Údataclassesr   r   Útypingr   r   Útorch.libraryr   Ú__all__Ú	getLoggerr;   rö   r	   r
   r   r6   r7   r8   r   r*   r,   r5   rƒ   r1  rE   r$   r·   rE  Úlocalr_  r�   r…   r\   r�  r!   r—   r    r¢   r¡   r  r‘  r  r  r^   r©   r±   rW   râ   r½   r²   r¸   rÂ   rÅ   rÒ   rÛ   ræ   rì   rX   rù   rÿ   r  r  r  r"  r(  r#   r?  rG  rø   ro  ru  r�  rŒ  r   )rŽ  s   @r   Ú<module>rž     s  øðß €Û ß .ß (ß %ã ò€ð ×Ò˜Ó!€áˆcƒN€ÙˆCƒL€à�Q˜�WÕ€	Ø�Q˜�T�N€	Ø˜B ˜HÕ%Ð õ	;õð ÷;ð ;ó ð;ð, ˜3  T¨-Õ%8Ð9¸4ÀÕ;NÐNÕO€ð ÷^ð ^ó ð^ñD +›n€Ó ,ð 79€Ó 8ð. 46Ð Ó 5ð —’Ó"€õð$ �5˜˜c 3˜Õ'¨¨mÕ)<Ð<Õ=€Ø€Ó à�C˜˜e C¨¨c MÕ2Õ3Ð3Õ4€ð (*Ð Ó )Ø+-Ð Ó -Ø(*Ð Ó *ð
 Ð Ó ñ -6ÚFó-Ð ó ñ (1°&¸*Ð1EÓ'FÐ Ó Fõ!ðH°U÷ ð( /1€	Ó 0á #£Ð Ó %ð EG€Ó Fõ õõõ.õõ(õ("õ8õ4ð&9à/3ð9ð 15ð9ð 48÷	9ðx-à04ð-ð 26ð-ð 59÷	-÷`õ0#LõLðfIð 7;ðfIð %*ðfIð $)÷fIðR'ð #÷	'ð0ð )-÷ð<Oð 9=ðOð "'ð	Oð
 )-÷O÷d3ðlA<ð )-÷A<õH
ðð "'÷ð.5ð "'÷5ðpLð "'÷	Lñ Lr   