§
    ž²Åj™  ã                   óH  — d dl Z d dlZd dlmZ d dlmZ d dlZd dlZd dl	Zd dl
Zd dlmc mZ g d¢Zej        j        Zej        j        Zej        j        ZdZdeej        j                 fd„Zed„ ¦   «         Zd	„ Zd
„ Z G d„ d¦  «        Zdedefd„Z d„ Z!ed„ ¦   «         Z"dS )é    N)Úcontextmanager)ÚIterator)Úenable_python_dispatcherÚno_python_dispatcherÚenable_pre_dispatchFÚreturnc               #   ó´   K  — t           j        D ]H} t          t           j        | ¦  «        }|D ])}t          ||¦  «        }|D ]}t          ||¦  «        V — ŒŒ*ŒIdS )aÄ  
    Warning: the set of overloads this will report is very subtle.  It is precisely
    the set of torch.ops functions that have actually been accessed from Python
    (e.g., we actually called torch.ops.aten.blah at some point.  This is DIFFERENT
    from the set of registered operators, which will in general be a larger set,
    as this would include all operators which we ran C++ static initializers or
    Python operator registration on.  This does not eagerly populate the list on
    torch.ops.aten; this list is lazy!

    In other words, this is good for traversing over everything that has an
    OpOverload object allocated in Python.  We use it for cache invalidation, but
    don't rely on this list being complete.

    Note that even if we did report all C++ registered overloads, this isn't guaranteed
    to be complete either, as a subsequent lazy load of a library which triggers more
    registrations could add more things to the set.
    N)ÚtorchÚopsÚgetattr)ÚnsÚpacketsÚop_nameÚpacketÚoverloads        úGC:\Projects\Historical\venv\Lib\site-packages\torch/_dispatch/python.pyÚall_py_loaded_overloadsr      s„   è è € õ$ Œið 0ð 0ˆÝ�%œ) RÑ(Ô(ˆØð 	0ð 	0ˆGÝ˜W gÑ.Ô.ˆFØ"ð 0ð 0�Ý˜f hÑ/Ô/Ð/Ð/Ð/Ð/ð0ð	0ð0ð 0ó    c               #   óL  K  — t           j                             t           j        j        j        ¦  «        } t           j                             ¦   «         }| rt          j        ¦   «          	 d V — | rt          j        |¬¦  «         d S d S # | rt          j        |¬¦  «         w w xY w)N)Úreapply_views)r
   Ú_CÚ&_dispatch_tls_is_dispatch_key_includedÚDispatchKeyÚFunctionalizeÚ$_functionalization_reapply_views_tlsÚ_disable_functionalizationÚ_enable_functionalization)Úf_tlsÚf_rvs     r   Úsuspend_functionalizationr    1   s»   è è € åŒH×;Ò;ÝŒÔÔ*ñô €Eõ Œ8×8Ò8Ñ:Ô:€DØð +ÝÔ(Ñ*Ô*Ð*ð@Øˆˆˆàð 	@ÝÔ+¸$Ð?Ñ?Ô?Ð?Ð?Ð?ð	@ð 	@øˆ5ð 	@ÝÔ+¸$Ð?Ñ?Ô?Ð?Ð?ð	@øøøs   Á*B	 Â	B#c           	      ó2  — t          |¦  «        sJ ‚|                      ¦   «         |                     ¦   «         k    s>J  |¦   «         › d|                      ¦   «         › d|                     ¦   «         › �¦   «         ‚| j        |j        k    s$J  |¦   «         › d| j        › d|j        › �¦   «         ‚t          j                             | |d¬¦  «        \  }}|sBJ  |¦   «         › d|                      ¦   «         › d|                     ¦   «         › d|› d�¦   «         ‚d S )	Nz: sizes ú != z: dtype F)Ú	only_cudaz
: strides z (mismatch at index ú))ÚcallableÚsizeÚdtyper
   Ú_prims_commonÚcheck_significant_stridesÚstride)ÚnvÚrvÚdescÚsame_stridesÚidxs        r   Úcheck_tensor_metadata_matchesr0   @   s5  € Ý�D‰>Œ>ÐÐˆ>Ø�7Š7‰9Œ9˜Ÿš™	œ	Ò!Ð!Ð! d d¡f¤fÐ#PÐ#P°b·g²g±i´iÐ#PÐ#PÀRÇWÂWÁYÄYÐ#PÐ#PÑ!Ô!Ð!ØŒ8�r”xÒÐÐ D D¡F¤FÐ!LÐ!L°B´HÐ!LÐ!LÀ"Ä(Ð!LÐ!LÑÔÐÝÔ+×EÒEØ
ˆB˜%ð Fñ ô Ñ€L�#ð 	ðUð Uà
ˆ$‰&Œ&ÐTÐT˜BŸIšI™KœKÐTÐT¨R¯YªY©[¬[ÐTÐTÈcÐTÐTÐTñUô UØðUð Ur   c                 óÞ  ‡‡	— t          ‰¦  «        sJ ‚t          j        | ¦  «        \  }}t          j        |¦  «        \  }}t          |¦  «        t          |¦  «        k    s)J t          |¦  «        › dt          |¦  «        › �¦   «         ‚t	          t          t          |¦  «        ¦  «        ||¦  «        D ]6\  Š	}}t          |t          j        ¦  «        sŒ!t          ||ˆˆ	fd„¦  «         Œ7d S )Nr"   c                  ó"   •—  ‰ ¦   «         › d‰› �S )Nz output © )r-   Úis   €€r   ú<lambda>z(check_metadata_matches.<locals>.<lambda>V   s   ø€ ¸¸¹¼Ð6LÐ6LÈÐ6LÐ6L€ r   )
r%   ÚpytreeÚtree_flattenÚlenÚzipÚrangeÚ
isinstancer
   ÚTensorr0   )
ÚnÚrr-   Ún_valsÚn_specÚr_valsÚr_specr+   r,   r4   s
     `      @r   Úcheck_metadata_matchesrC   L   sô   øø€ Ý�D‰>Œ>ÐÐˆ>ÝÔ(¨Ñ+Ô+�N€FˆFÝÔ(¨Ñ+Ô+�N€FˆFõ ˆv‰;Œ;�#˜f™+œ+Ò%Ð%Ð%­#¨f©+¬+Ð'HÐ'H½3¸v¹;¼;Ð'HÐ'HÑ%Ô%Ð%Ý��s 6™{œ{Ñ+Ô+¨V°VÑ<Ô<ð Nð N‰	ˆˆ2ˆrÝ˜"�eœlÑ+Ô+ð 	ØÝ% b¨"Ð.LÐ.LÐ.LÐ.LÐ.LÑMÔMÐMÐMðNð Nr   c                   ó   — e Zd Zd„ Zd„ ZdS )ÚLitc                 ó   — || _         d S ©N©Ús)ÚselfrI   s     r   Ú__init__zLit.__init__Z   s   € ØˆŒˆˆr   c                 ó   — | j         S rG   rH   )rJ   s    r   Ú__repr__zLit.__repr__]   s	   € ØŒvˆr   N)Ú__name__Ú
__module__Ú__qualname__rK   rM   r3   r   r   rE   rE   Y   s2   € € € € € ðð ð ðð ð ð ð r   rE   Úac           	      óØ   — t          | t          j        ¦  «        rOt          dt	          |                      ¦   «         ¦  «        › d|                      ¦   «         › d| j        › d�¦  «        S | S )Nztorch.empty_strided(ú, z, dtype=r$   )r;   r
   r<   rE   Útupler&   r*   r'   )rQ   s    r   Ú_fmtrU   a   se   € Ý�!•U”\Ñ"Ô"ð ÝØT¥5¨¯ª©¬¡?¤?ÐTÐT°a·h²h±j´jÐTÐTÈ!Ì'ÐTÐTÐTñ
ô 
ð 	
ð ˆr   c                 óh   ‡ ‡‡— ddl mŠ ‰ t          j        j        j        j        k    r‰S ˆˆˆ fd„}|S )Nr   )ÚFakeTensorModec                  óò  •‡	‡
‡—  ‰¦   «         Š	ˆ	fd„}d„ }t           j        j                             ¦   «         5  t	          ¦   «         5  t          j        || |f¦  «        \  }}t          j        |||f¦  «        \  Š
Š‰	5   ‰|i |¤Ž}d d d ¦  «         n# 1 swxY w Y   d d d ¦  «         n# 1 swxY w Y   d d d ¦  «         n# 1 swxY w Y    ‰j        ‰g| ¢R i |¤Ž}ˆˆ
ˆfd„}t          |||¦  «         |S )Nc                 ól  •— t          | t          j        ¦  «        r˜t          j        | ¦  «        rmt          j        | ¦  «        }|                      ¦   «         |                     ¦   «         k    sJ ‚|                      ¦   «         |                     ¦   «         k    sJ ‚n| }‰                     |¦  «        S | S rG   )r;   r
   r<   Ú_is_functional_tensorÚ_from_functional_tensorr&   r*   Úfrom_tensor)Útr>   Ú	fake_modes     €r   Úfakeify_defunzCmake_crossref_functionalize.<locals>.handler.<locals>.fakeify_defunt   sŸ   ø€ Ý˜!�Uœ\Ñ*Ô*ð 0ÝÔ.¨qÑ1Ô1ð 	ÝÔ5°aÑ8Ô8�Að
 Ÿ6š6™8œ8 q§v¢v¡x¤xÒ/Ð/Ð/Ð/ØŸ8š8™:œ:¨¯ª©¬Ò3Ð3Ð3Ð3Ð3à�Aà ×,Ò,¨QÑ/Ô/Ð/ØˆHr   c                 ób   — t          | t          j        ¦  «        r|                      ¦   «         S | S rG   )r;   r
   r<   Údetach)r]   s    r   Úmaybe_detachzBmake_crossref_functionalize.<locals>.handler.<locals>.maybe_detach„   s)   € Ý˜!�Uœ\Ñ*Ô*ð Ø—x’x‘z”zÐ!à�r   c                  ó°   •— d                      t          j        d„ ‰D ¦   «         d„ ‰                     ¦   «         D ¦   «         ¦  «        ¦  «        } ‰› d| › d�S )NrS   c              3   ód   K  — | ]+}t          t          j        t          |¦  «        ¦  «        V — Œ,d S rG   )Úreprr6   Útree_maprU   )Ú.0rQ   s     r   ú	<genexpr>zMmake_crossref_functionalize.<locals>.handler.<locals>.desc.<locals>.<genexpr>˜   s6   è è € ÐIÐI¸•T�&œ/­$°Ñ2Ô2Ñ3Ô3ÐIÐIÐIÐIÐIÐIr   c              3   óZ   K  — | ]&\  }}|› d t          j        t          |¦  «        › �V — Œ'dS )ú=N)r6   rf   rU   )rg   ÚkÚvs      r   rh   zMmake_crossref_functionalize.<locals>.handler.<locals>.desc.<locals>.<genexpr>™   sT   è è € ð ð á ˜A˜qð Ð9Ð9�vœ­t°QÑ7Ô7Ð9Ð9ðð ð ð ð ð r   ú(r$   )ÚjoinÚ	itertoolsÚchainÚitems)Úfmt_argsÚopÚorig_f_argsÚorig_f_kwargss    €€€r   r-   z:make_crossref_functionalize.<locals>.handler.<locals>.desc•   sw   ø€ Ø—y’yÝ”ØIÐI¸[ÐIÑIÔIðð à$1×$7Ò$7Ñ$9Ô$9ðñ ô ñô ñô ˆHð Ð&Ð&˜8Ð&Ð&Ð&Ð&r   )	r
   ÚutilsÚ_python_dispatchÚ_disable_current_modesr    r6   rf   Ú_op_dkrC   )ÚargsÚkwargsr_   rb   Úf_argsÚf_kwargsÚf_rr>   r-   r^   rt   ru   rW   Ú	final_keyrs   s            @@@€€€r   Úhandlerz,make_crossref_functionalize.<locals>.handlerq   s  øøøø€ Ø"�NÑ$Ô$ˆ	ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	õ Œ[Ô)×@Ò@ÑBÔBð 	.ð 	.ÕD]ÑD_ÔD_ð 	.ð 	.Ý%œ¨}¸tÀV¸nÑMÔMÑˆF�HÝ)/¬Ø˜v xÐ0ñ*ô *Ñ&ˆK˜ð ð .ð .Ø�b˜&Ð- HÐ-Ð-�ð.ð .ð .ñ .ô .ð .ð .ð .ð .ð .ð .øøøð .ð .ð .ð .ð	.ð 	.ð 	.ñ 	.ô 	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.øøøð 	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.ñ 	.ô 	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.øøøð 	.ð 	.ð 	.ð 	.ð ˆBŒI�iÐ1 $Ð1Ð1Ð1¨&Ð1Ð1ˆð
	'ð 
	'ð 
	'ð 
	'ð 
	'ð 
	'ð 
	'õ 	˜s A tÑ,Ô,Ð,ØˆsY   ºCÁ	7B,Â 	BÂ	B,ÂBÂB,ÂBÂB,Â CÂ,B0	Â0CÂ3B0	Â4CÃCÃ
C)Útorch._subclasses.fake_tensorrW   r
   r   ÚatenÚ
lift_freshÚdefault)rs   r   r€   rW   s   `` @r   Úmake_crossref_functionalizer…   j   s_   øøø€ Ø<Ð<Ð<Ð<Ð<Ð<ð 
�UŒYŒ^Ô&Ô.Ò.Ð.ØÐð1ð 1ð 1ð 1ð 1ð 1ð 1ðf €Nr   c               #   ó6  K  — t          ¦   «         D ]+} |                      t          j        j        j        ¦  «         Œ,	 t          ¦   «         5  t          j         	                    dd¦  «        5  d V — d d d ¦  «         n# 1 swxY w Y   d d d ¦  «         n# 1 swxY w Y   t          ¦   «         D ]+} |                      t          j        j        j        ¦  «         Œ,d S # t          ¦   «         D ]+} |                      t          j        j        j        ¦  «         Œ,w xY w)Nz-torch._dispatch.python.CROSSREF_FUNCTIONALIZET)
r   Ú_uncache_dispatchr
   r   r   r   r   ÚunittestÚmockÚpatch)rs   s    r   Úenable_crossref_functionalizer‹   ©   s£  è è € å%Ñ'Ô'ð Að AˆØ
×Ò�UœXÔ1Ô?Ñ@Ô@Ð@Ð@ðEÝ%Ñ'Ô'ð 	ð 	­¬×)<Ò)<Ø;¸Tñ*
ô *
ð 	ð 	ð ˆEˆEˆEð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð 	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ
 *Ñ+Ô+ð 	Eð 	EˆBØ× Ò ¥¤Ô!5Ô!CÑDÔDÐDÐDð	Eð 	EøÕ)Ñ+Ô+ð 	Eð 	EˆBØ× Ò ¥¤Ô!5Ô!CÑDÔDÐDÐDð	EøøøsS   ¾C Á!BÁ-A>Á2BÁ>B	ÂBÂB	ÂBÂ	C ÂBÂC ÂBÂC Ã<D)#ro   Úunittest.mockrˆ   Ú
contextlibr   Útypingr   r
   Útorch._CÚ
torch._opsÚtorch.utils._python_dispatchÚtorch.utils._pytreerv   Ú_pytreer6   Ú__all__r   Ú_DisablePythonDispatcherr   Ú_EnablePythonDispatcherr   Ú_EnablePreDispatchr   ÚCROSSREF_FUNCTIONALIZEÚ_opsÚ
OpOverloadr   r    r0   rC   rE   ÚobjectrU   r…   r‹   r3   r   r   ú<module>rœ      s¦  ðà Ð Ð Ð Ø Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð à €€€Ø €€€Ø Ð Ð Ð Ø #Ð #Ð #Ð #Ø $Ð $Ð $Ð $Ð $Ð $Ð $Ð $Ð $ð VÐ
UÐ
U€à”xÔ8Ð Ø œ8Ô;Ð Ø”hÔ1Ð àÐ ð0 ¨%¬*Ô*?Ô!@ð 0ð 0ð 0ð 0ð4 ð@ð @ñ „ð@ð	Uð 	Uð 	Uð
Nð 
Nð 
Nðð ð ð ð ñ ô ð ðˆFð �vð ð ð ð ð:ð :ð :ð~ ð
Eð 
Eñ „ð
Eð 
Eð 
Er   