
    j*                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Zd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZmZ d dlmZ d dlZd d	lmZ  d d
l!m"Z" d dl#m$Z$ d dl%m&Z&m'Z' d dl(m)Z)  ej*        e+          Z,er,d dl-m.Z.m/Z/m0Z0 d dl1m2Z2 d dl3Z3d dl4m5Z5 d dl6m7Z7 d dl8m9Z9 d dl:m;Z; 	  ej<        d          Z= ej<        d          Z> eddd           G d d                      Z? G d de          Z@ G d dejA                  ZB	  G d d          ZC ej        d            G d! d"                      ZD G d# d$e          ZE ej        d%           G d& d'                      ZF ed(          ZG	  ej        d            G d) d*                      ZH	  ej        d            G d+ d,eH                      ZI	  ej        d            G d- d.eH                      ZJ	  G d/ d0eeG                   ZK G d1 d2          ZL G d3 d4          ZM G d5 d6eKeM                   ZN G d7 d8          ZO G d9 d:eKeO                   ZP G d; d<          ZQ	  G d= d>eKeL                   ZR G d? d@          ZS G dA dBeS          ZT G dC dD          ZU ejV                    ZW	  G dE dF          ZXe G dG dH                      ZY G dI dJ          ZZedfdO            Z[edgdR            Z\edhdW            Z]e	 didjdZ            Z] e            	 didkd]            Z] e]d            G d^ d_                      Z^ e]d            G d` dae^                      Z_didlddZ`dmdeZadS )n    )annotationsN)abstractmethod)defaultdict)contextmanager)	dataclass)AnyGeneric
NamedTupleOptionaloverloadTYPE_CHECKINGTypeVar)dataclass_transform)_pytree)
OrderedSet)is_traceable_wrapper_subclass)CapturedTracebackformat_frame)WeakTensorKeyDictionary)Callable	GeneratorIterator)CodeType)DDPOptimizerContext)	PyCodegen)ViewAndMutationMetaFakeTensorModez-^(?P<frame_id>\d+)/(?P<frame_compile_id>\d+)$zQ^!(?P<compiled_autograd_id>\d+)(?:/(?P<frame_id>\d+)/(?P<frame_compile_id>\d+))?$T)frozenkw_onlyslotsc                  R    e Zd ZU ded<   ded<   dZded<   ddZedd            ZdS )	CompileId
int | Noneframe_idframe_compile_idNcompiled_autograd_idreturnstrc                @   | j         Z| j        d u | j        d u k    rt          d| j         d| j                   d}| j        d| j         d| j         }d| j          | S | j        | j        t          d| j         d| j                   | j         d| j         S )NzMframe_id and frame_compile_id must both be None or both be set, got frame_id=z, frame_compile_id= /!z=frame_id and frame_compile_id must not be None, got frame_id=)r'   r%   r&   AssertionError)self	frame_strs     W/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/torch/_guards.py__str__zCompileId.__str__S   s   $0%4+@D+HII$^$(M^ ^FJF[^ ^   I}(GGG0EGG	=t0=)===}$(=(E$^$(M^ ^FJF[^ ^   m==d&;===    
compile_id
str | NoneCompileId | Nonec                N   |dS 	 t           t          fD ]e}|                    |          x}rL|                                }|                                D ]\  }}|t          |          ||<    | di |c S ft          # t          $ r}t          d| d          |d}~ww xY w)z
        Factory method that creates a CompileId from its string representation.
        Keep this in sync with the __str__ method.
        NzInvalid compile_id '' )COMPILE_ID_PATTERNCA_COMPILE_ID_PATTERNmatch	groupdictitemsint
ValueError	Exception)clsr4   patternr<   groupskves           r1   from_stringzCompileId.from_stringh   s     4	J.0EF ! !#MM*5555 )"__..F & / /1=(+AF1I3====((() !  	J 	J 	JAJAAABBI	Js   A2B 9B 
B$BB$r(   r)   )r4   r5   r(   r6   )__name__
__module____qualname____annotations__r'   r2   classmethodrH   r9   r3   r1   r#   r#   D   s~         
 !    (,++++
> > > >* J J J [J J Jr3   r#   c                  ,    e Zd ZU ded<   ded<   d	dZdS )
TraceIdr#   r4   r?   attemptr(   r)   c                b    | j         dk    rt          | j                  S | j         d| j          S )Nr   _)rQ   r)   r4   r/   s    r1   r2   zTraceId.__str__   s7    <1t'''o66666r3   NrI   rJ   rK   rL   rM   r2   r9   r3   r1   rP   rP      sA          LLL7 7 7 7 7 7r3   rP   c                  z    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZddZddZddZddZddZdS )GuardSourcer                           	   
                     r(   boolc                6    | t           j        t           j        fv S N)rW   GLOBAL_FSDP_MODULELOCAL_FSDP_MODULErT   s    r1   is_fsdp_modulezGuardSource.is_fsdp_module   s    68UVVVr3   c                    dd l mc m} |j        r.| t          j        t          j        fv p|                                 S | t          j        t          j        fv S )Nr   )torch._dynamo.config_dynamoconfig_unsafe_skip_fsdp_module_guardsrW   GLOBAL_SPECIALIZED_NN_MODULELOCAL_SPECIALIZED_NN_MODULErm   )r/   rq   s     r1   is_specialized_nn_modulez$GuardSource.is_specialized_nn_module   s|    ---------1 	<; )
 &&(( 43
 
 	
r3   c                b    | t           j        t           j        t           j        t           j        fv S rj   )rW   GLOBAL_UNSPECIALIZED_NN_MODULELOCAL_UNSPECIALIZED_NN_MODULE&GLOBAL_UNSPECIALIZED_BUILTIN_NN_MODULE%LOCAL_UNSPECIALIZED_BUILTIN_NN_MODULErT   s    r1   is_unspecialized_nn_modulez&GuardSource.is_unspecialized_nn_module   s,    65>=	
 
 	
r3   c                6    | t           j        t           j        fv S rj   )rW   ry   rz   rT   s    r1   "is_unspecialized_builtin_nn_modulez.GuardSource.is_unspecialized_builtin_nn_module   s     >=
 
 	
r3   c                x    | t           j        t           j        t           j        t           j        t           j        fv S rj   )rW   LOCALrt   rl   rx   rz   rT   s    r1   is_localzGuardSource.is_local   s2    3)5=
 
 	
r3   Nr(   rh   )rJ   rK   rL   r   GLOBALrt   rs   CONSTANTRANDOM_VALUE	SHAPE_ENVrl   rk   BACKWARD_STATE	EPHEMERALSYNTHETIC_LOCALrx   rw   rz   ry   
TEMP_LOCALrm   ru   r{   r}   r   r9   r3   r1   rW   rW      s        EF"##$ HLINIO$&!%'",.)-/*JW W W W
 
 
 
"
 
 
 

 
 
 

 
 
 
 
 
r3   rW   c                      e Zd ZdS )GuardBuilderBaseNrJ   rK   rL   r9   r3   r1   r   r      s        Dr3   r   )r   c                  ,    e Zd ZU ded<   ded<   d	dZdS )
SLocz#traceback.FrameSummary | str | Noneframework_locr5   maybe_user_locr(   r)   c                    t          | j        t                    r| j        nt          | j                  }| j        | j         d| dS d| dS )Nz ()()
isinstancer   r)   r   r   )r/   flocs     r1   r2   zSLoc.__str__   sg     $,c222Dd011 	
 *)44T4444t;;;r3   NrI   rU   r9   r3   r1   r   r      sB         6666	 	 	 	 	 	r3   r   c                  .    e Zd ZU ded<   ded<   ded<   dS )
ShapeGuardzsympy.logic.boolalg.Booleanexprr   slocrh   size_obliviousNrJ   rK   rL   rM   r9   r3   r1   r   r      s3         %%%%JJJr3   r   )r!   c                  <   e Zd ZU ded<   ded<   dZded<   dZded<   dZd	ed
<   dZded<   dZded<   dZ	ded<   dZ
ded<   dZded<   d4dZd5dZd6dZd7dZed8d             Zed9d"            Zed:d$            Zd8d%Zd8d&Zd;d*Zd<d+Zd<d,Zd<d-Zd8d.Zd=d3ZdS )>GuardSourceoriginating_sourcez)Callable[[GuardBuilderBase, Guard], None]	create_fnNzlist[str] | Noneguard_types	code_listzobject | Noneobj_weakref!weakref.ReferenceType[Any] | Noneguarded_class_weakrefzCapturedTraceback | Nonestackztraceback.StackSummary | None
user_stackr$   _hashFrh   _unserializabler(   r?   c                    | j         3t          | j        | j        t	          | j                  f          | _         | j         S rj   )r   hashnamesourceidr   rT   s    r1   __hash__zGuard.__hash__  s6    :ty$+r$.7I7IJKKDJzr3   tuple[bool, int, int, str, int]c                (   t          | j        t          j                  o&| j        j        t
          j        j        j        j	        u }|| j
        r| j
        j        ndt          | j                  | j        |                                 j        j        fS )N)r   r   	functoolspartialfunctorchrp   guardsGuardBuilderDUPLICATE_INPUTr   valuelenr   inner_create_fn__code__co_firstlineno)r/   is_duplicate_inputs     r1   sort_keyzGuard.sort_key  s    
 t~y'899 Y#u}';'H'XX 	
 !%4DK"	NNI  ""+:
 	
r3   otherc                V    |                                  |                                 k     S rj   )r   r/   r   s     r1   __lt__zGuard.__lt__+  s    }}!1!111r3   (Callable[[GuardBuilderBase, Guard], Any]c                f    t          | j        t          j                  r| j        j        S | j        S rj   )r   r   r   r   r   rT   s    r1   r   zGuard.inner_create_fn.  s,    dni&788 	">&&>!r3   r)   c                    | j         j        S rj   )r   r   rT   s    r1   r   z
Guard.name4  s    &++r3   rW   c                    | j         j        S rj   )r   guard_sourcerT   s    r1   r   zGuard.source8  s    &33r3   objectc           
     @   t          | t          j                  rv |             }|Jdt          t	          |                      d|j        j         dt          t	          |                     dS dt          t	          |                      dS t          |           S )a  
        This is a workaround of a Python weakref bug.

        `obj_weakref` is instance returned by `weakref.ref`,
        `str(obj_weakref)` is buggy if the original obj overrides __getattr__, e.g:

            class MyConfig(dict):
                def __getattr__(self, x):
                    return self[x]

            obj = MyConfig(offset=5)
            obj_weakref = weakref.ref(obj)
            str(obj_weakref)  # raise error: KeyError: '__name__'
        Nz<weakref at z; to 'z' at >z; dead>)r   weakrefReferenceTypehexr   	__class__rJ   r)   )r   objs     r1   weakref_to_strzGuard.weakref_to_str<  s      k7#899 	$+--Cnc"[//&:&:nn#-BXnn_bceficjcj_k_knnnnCc"[//&:&:CCCC{###r3   c                    d| j         r| j         j                                        nd dt          | j                   d|                                 j         d| j         d| j         d|                     | j	                   d| j
         d}|S )	Nz	
        r+    z&
        {
            'guard_types': z,
            'code': z,
            'obj_weakref': z
            'guarded_class': z
        }
        )r   r   lowerreprr   rJ   r   r   r   r   r   )r/   ss     r1   __repr__zGuard.__repr__U  s    %)[	8				!	!	!b ;?	?? MQMaMaMcMcMl  !,  ^	 
 !//0@AA  #8   r3   c                l   dt          | j                   d}| j        r| j        j                                        nd}|d| dz  }|d|                                 j         dz  }|d| j         dz  }|d| j         dz  }|d|                     | j	                   dz  }|d	| j
         dz  }|S )
NzName: 
r+   z    Source: z    Create Function: z    Guard Types: z    Code List: z    Object Weakref: z    Guarded Class Weakref: )r   r   r   r   r   rJ   r   r   r   r   r   )r/   outputr   s      r1   r2   zGuard.__str__a  s    -$ty//----1[@!'')))b+++++M$*>*>*@*@*IMMMM:d&6::::6DN6666R)<)<T=M)N)NRRRRN0JNNNNr3   builderr   r   c           	        	 |                      ||           S # t          $ r t                              dt	          |                                                      | j        r_t                              dd                    | j        	                                dd                                                                w xY w)NzError while creating guard:
%szCreated at:
%sr+   )
r   rA   log	exceptionr)   rstripr   errorjoinformat)r/   r   s     r1   createzGuard.createl  s    	>>'4000 	 	 	MM;SYY=M=M=O=OPPPz Y		+RWWTZ5F5F5H5H5M-N-N-U-U-W-WXXX		s
    B,Cc                4    | j                                         S rj   )r   ru   rT   s    r1   ru   zGuard.is_specialized_nn_moduleu  s    {33555r3   c                4    | j                                         S rj   )r   rm   rT   s    r1   rm   zGuard.is_fsdp_modulex  s    {))+++r3   c                4    | j                                         S rj   )r   r   rT   s    r1   r   zGuard.is_local{  s    {##%%%r3   c                v    t          | j        t          j                  r| j        j        }n| j        }|j        S rj   )r   r   r   r   r   rJ   )r/   r   s     r1   create_fn_namezGuard.create_fn_name~  s5    dni&788 	'+III!!r3   
guard_typeguarded_class	list[str]Nonec                   | j         sg | _         | j                             |           | j        |d fvrt          d| j         d|           || _        | j        s|| _        n| j                            |           | j        |d fv p)t          | j                  o|                                 d u }|st          d| j         d|           || _        d S )Nz1Guarded class id must be identical, or None, got z vs zHGuarded object must be identical, None or ephemeral (dead weakref), got )r   appendr   r.   r   extendr   callable)r/   r   r   r   r   is_valids         r1   set_export_infozGuard.set_export_info  s>     	"!D
+++%mT-BBB G1G G7DG G   &3"~ 	-&DNNN!!),,, d 33 +()) +  ""d* 	
  	 ;'; ;-8; ;   'r3   r(   r?   )r(   r   )r   r   r(   rh   )r(   r   rI   r(   rW   )r   r   r(   r)   )r   r   r(   r   r   )
r   r)   r   r   r   r   r   r   r(   r   )rJ   rK   rL   rM   r   r   r   r   r   r   r   r   r   r   r   r   propertyr   r   staticmethodr   r   r2   r   ru   rm   r   r   r   r9   r3   r1   r   r      s        & 8888 %)K(((("&I&&&&!%K%%%%?CCCCC&*E****04J4444E!O!!!!   

 
 
 
 2 2 2 2" " " " , , , X, 4 4 4 X4 $ $ $ \$0
 
 
 
	 	 	 	   6 6 6 6, , , ,& & & &" " " "&' &' &' &' &' &'r3   r   Tc                      e Zd ZdS )GuardEnvExprNr   r9   r3   r1   r   r     s        Dr3   r   c                  ,    e Zd ZU ded<   ded<   ddZdS )	DuplicateInputsr   input_source_ainput_source_br(   r   c                T    | j         | j        k    rt          d| j                    d S )Nz9input_source_a and input_source_b must be different, got )r   r   r.   rT   s    r1   __post_init__zDuplicateInputs.__post_init__  sB    $"555 -*- -   65r3   Nr(   r   )rJ   rK   rL   rM   r  r9   r3   r1   r   r     sB              r3   r   c                  $    e Zd ZU ded<   ded<   dS )StorageOverlapzlist[Source]overlapping_sourcesnon_overlapping_sourcesNr   r9   r3   r1   r  r    s*         %%%%))))))r3   r  c                  >    e Zd Zedd            Zed	d            ZdS )
Checkpointabler(   r   c                    d S rj   r9   rT   s    r1   copy_graphstatezCheckpointable.copy_graphstate  s    $'Cr3   stater   c                    d S rj   r9   r/   r  s     r1   restore_graphstatez!Checkpointable.restore_graphstate  s    47Cr3   N)r(   r   )r  r   r(   r   )rJ   rK   rL   r   r
  r  r9   r3   r1   r  r    s<        ''' ^'777 ^777r3   r  c                  6    e Zd ZU dZded<   ddZdd	ZddZdS )GuardsCheckpointStatezW
    The GuardCheckpointState - it is the T of Checkpointable[T] for GuardsContext
    OrderedSet[Guard]dynamo_guardsr(   r   c                    || _         d S rj   )r  )r/   r  s     r1   __init__zGuardsCheckpointState.__init__   s    *r3   r   Optional[OrderedSet[Guard]]c                n    | j                             |j                   }t          |          dk    rdS |S )z
        Produces a delta against another GuardsCheckpointState.

        Returns None if no delta is found, otherwise, return an OrderedSet() of mismatched
        Guard type objects.
        r   N)r  
differencer   r/   r   rs      r1   diffzGuardsCheckpointState.diff  s6     ))%*=>>q66Q;;4r3   r   rh   c                ^    t          |t                    sdS |                     |          d u S NF)r   r  r  r   s     r1   __eq__zGuardsCheckpointState.__eq__  s1    %!677 	5yy4''r3   N)r  r  r(   r   )r   r  r(   r  r   r   r(   rh   )rJ   rK   rL   __doc__rM   r  r  r  r9   r3   r1   r  r    sj           %$$$+ + + +
 
 
 
( ( ( ( ( (r3   r  c                  6    e Zd ZU i Zded<   ddZddZddZdS )ModuleContextCheckpointStatedict[str, torch.nn.Module]
nn_modulesr(   r   c                    || _         d S rj   r#  )r/   r#  s     r1   r  z%ModuleContextCheckpointState.__init__  s    $r3   r   set[str] | Nonec                    t          | j                                                                      t          |j                                                            }t	          |          dk    rdS |S )z
        Produces a delta against another ModuleContextCheckpointState.

        Returns None if no delta is found, otherwise, return a set() of mismatched
        module key names.
        r   N)setr#  keysr  r   r  s      r1   r  z!ModuleContextCheckpointState.diff  s]     $$&&''223u7G7L7L7N7N3O3OPPq66Q;;4r3   r   rh   c                ^    t          |t                    sdS |                     |          d u S r  )r   r!  r  r   s     r1   r  z#ModuleContextCheckpointState.__eq__'  1    %!=>> 	5yy4''r3   N)r#  r"  r(   r   )r   r!  r(   r&  r  )rJ   rK   rL   r#  rM   r  r  r  r9   r3   r1   r!  r!    sc         -/J////% % % %
 
 
 
( ( ( ( ( (r3   r!  c                  &    e Zd Zd	dZd
dZddZdS )ModuleContextr(   r   c                    i | _         d S rj   r%  rT   s    r1   r  zModuleContext.__init__.  s    *,r3   r!  c                D    t          t          | j                            S rj   )r!  dictr#  rT   s    r1   r
  zModuleContext.copy_graphstate1  s    +D,A,ABBBr3   r  c                    t          |t                    st          dt          |                     |j        | _        d S )Nz+expected ModuleContextCheckpointState, got )r   r!  r.   typer#  r  s     r1   r  z ModuleContext.restore_graphstate4  sH    %!=>> 	 Kd5kkKK    *r3   Nr  )r(   r!  )r  r!  r(   r   rJ   rK   rL   r  r
  r  r9   r3   r1   r-  r-  -  sT        - - - -C C C C+ + + + + +r3   r-  c                  6    e Zd ZU i Zded<   ddZdd	ZddZdS )GlobalContextCheckpointStatedict[str, tuple[Callable, Any]]global_stateglobal_statesr(   r   c                    || _         d S rj   r7  )r/   r8  s     r1   r  z%GlobalContextCheckpointState.__init__?  s    )r3   r   r&  c                    t          | j                                                                      t          |j                                                            }t	          |          dk    rdS |S )z
        Produces a delta against another GlobalContextCheckpointState.

        Returns None if no delta is found, otherwise, return a set() of mismatched
        global key names.
        r   N)r(  r7  r)  r  r   r  s      r1   r  z!GlobalContextCheckpointState.diffB  s^     !&&(())44S9K9P9P9R9R5S5STTq66Q;;4r3   r   rh   c                ^    t          |t                    sdS |                     |          d u S r  )r   r5  r  r   s     r1   r  z#GlobalContextCheckpointState.__eq__N  r+  r3   N)r8  r6  r(   r   )r   r5  r(   r&  r  )rJ   rK   rL   r7  rM   r  r  r  r9   r3   r1   r5  r5  <  sc         46L6666* * * *
 
 
 
( ( ( ( ( (r3   r5  c                  2    e Zd ZdZh dZddZddZdd	Zd
S )GlobalContextzz
    This keeps track of the global torch state during tracing of a function.
    For example, torch.is_grad_enabled.
    >   grad_enabledautocast_enabledautocast_cpu_dtypeautocast_gpu_dtypeautocast_cpu_enabledautocast_cache_enabledr(   r   c                    i | _         d S rj   r:  rT   s    r1   r  zGlobalContext.__init__c  s    =?r3   r5  c                *    t          | j                  S rj   )r5  r7  rT   s    r1   r
  zGlobalContext.copy_graphstatef  s    +D,=>>>r3   r  c                   t          |t                    st          dt          |                     |j        | _        t          | j                  t          | j                  k    r/t          | j                                                  | j        k    s>t          dt          | j                                                   d| j                   | j        	                                D ]\  }} ||           d S )Nz+expected GlobalContextCheckpointState, got z Global state mismatch: got keys z, expected )
r   r5  r.   r2  r7  r   _supported_global_statesr(  r)  values)r/   r  r   argss       r1   r  z GlobalContext.restore_graphstatei  s   %!=>> 	 Kd5kkKK   ".!""c$*G&H&HHHD%**,,--1NNN <3t7H7M7M7O7O3P3P < < 9< <   +2244 	 	JD$DJJJJ	 	r3   Nr  )r(   r5  )r  r5  r(   r   )rJ   rK   rL   r  rH  r  r
  r  r9   r3   r1   r>  r>  T  sp         
     @ @ @ @? ? ? ?     r3   r>  c                  X    e Zd ZdddZddZd d
Zd!dZd"dZdddd#dZd$dZ	d%dZ
dS )&	GuardsSetNinnerr  r(   r   c                B    |t                      | _        d S || _        d S rj   )r   rM  )r/   rM  s     r1   r  zGuardsSet.__init__~  s!    =,6LLDJJJDJJJr3   Iterator[Guard]c                *    t          | j                  S rj   )iterrM  rT   s    r1   __iter__zGuardsSet.__iter__      DJr3   r?   c                *    t          | j                  S rj   )r   rM  rT   s    r1   __len__zGuardsSet.__len__  s    4:r3   r   c                :    t          | j        |j        z
            S rj   )rL  rM  r   s     r1   __sub__zGuardsSet.__sub__  s    ek1222r3   rh   c                *    t          | j                  S rj   )rh   rM  rT   s    r1   __bool__zGuardsSet.__bool__  rS  r3   Tr   )collect_debug_stackskipguardr   rZ  r[  c                   || j         v rd S |r$|j        t          j        d|z             |_        |j        t
                                          |_        | j                             |           d S NrX   )r[  )rM  r   r   extractr   TracingContextextract_stackadd)r/   r\  rZ  r[  s       r1   rb  zGuardsSet.add  sw     DJF 	G{"/7QXFFF#-;;==E
ur3   others
set[Guard]c                H    |D ]}|D ]}|                      |d           d S r^  )rb  )r/   rc  ogs       r1   updatezGuardsSet.update  sH     	$ 	$A $ $####$	$ 	$r3   r   r   c                b    ddl m t          fd| j        D                       | _        dS )z.Delete all guards that contains a given sourcerX   )is_from_sourcec              3  >   K   | ]} |j                   |V  d S rj   )r   ).0rg  rj  r   s     r1   	<genexpr>z6GuardsSet.remove_guards_with_source.<locals>.<genexpr>  sK        
  
8Lf)U)U 
 
  
  
  
  
  
r3   N)_dynamo.sourcerj  r   rM  )r/   r   rj  s    `@r1   remove_guards_with_sourcez#GuardsSet.remove_guards_with_source  sX    222222  
  
  
  
  
z 
  
  
 
 



r3   rj   )rM  r  r(   r   )r(   rO  r   )r   rL  r(   rL  r   )r\  r   rZ  rh   r[  r?   r(   r   )rc  rd  r(   r   )r   r   r(   r   )rJ   rK   rL   r  rR  rU  rW  rY  rb  rh  ro  r9   r3   r1   rL  rL  }  s                      
3 3 3 3        <@Q
 
 
 
 
 
$ $ $ $

 
 
 
 
 
r3   rL  c                  &    e Zd Zd	dZd
dZddZdS )GuardsContextr(   r   c                :    t                      | _        g | _        d S rj   )rL  r  aotautograd_guardsrT   s    r1   r  zGuardsContext.__init__  s    (168r3   r  c                N    t          t          | j        j                            S rj   )r  r   r  rM  rT   s    r1   r
  zGuardsContext.copy_graphstate  s    $Z0B0H%I%IJJJr3   r  c                    t          |t                    st          dt          |                     t	          |j                  | _        d S )Nz$expected GuardsCheckpointState, got )r   r  r.   r2  rL  r  r  s     r1   r  z GuardsContext.restore_graphstate  sL    %!677 	W !UU!U!UVVV&u':;;r3   Nr  )r(   r  )r  r  r(   r   r3  r9   r3   r1   rq  rq    sT        9 9 9 9K K K K< < < < < <r3   rq  c                      e Zd Zedd            Zedd	            Zedd            Zedd            Zedd            Zedd            Z	edd            Z
edd            ZdS )HopSubgraphCachefn_idr?   
identifierr)   r(   r   c                    d S rj   r9   r/   rx  ry  s      r1   add_dynamo_installed_submodulez/HopSubgraphCache.add_dynamo_installed_submodule  s    SVSVr3   r   c                    d S rj   r9   r/   rx  s     r1   get_dynamo_installed_submodulesz0HopSubgraphCache.get_dynamo_installed_submodules      HKr3   keyr   c                    d S rj   r9   r/   ry  r  s      r1   add_autograd_key_entryz'HopSubgraphCache.add_autograd_key_entry  s    NQcr3   Callable | Nonec                    d S rj   r9   r/   ry  s     r1   get_autograd_key_entryz'HopSubgraphCache.get_autograd_key_entry  s    JM#r3   c                    d S rj   r9   r  s      r1   add_proxy_dispatch_entryz)HopSubgraphCache.add_proxy_dispatch_entry  s    PSPSr3   c                    d S rj   r9   r  s     r1   get_proxy_dispatch_entryz)HopSubgraphCache.get_proxy_dispatch_entry  s    LOCr3   tangent_metadatatuple[object]gmodtorch.fx.GraphModulec                    d S rj   r9   )r/   ry  r  r  s       r1   add_lazy_bwd_entryz#HopSubgraphCache.add_lazy_bwd_entry  s	     cr3   .tuple[torch.fx.GraphModule | None, int | None]c                    d S rj   r9   r/   ry  r  s      r1   get_lazy_bwd_entryz#HopSubgraphCache.get_lazy_bwd_entry  s	     :=r3   Nrx  r?   ry  r)   r(   r   rx  r?   r(   r   ry  r)   r  r   r(   r   ry  r)   r(   r  ry  r)   r  r  r  r  r(   r?   ry  r)   r  r  r(   r  )rJ   rK   rL   r   r|  r  r  r  r  r  r  r  r9   r3   r1   rw  rw    s        VVV ^VKKK ^KQQQ ^QMMM ^MSSS ^SOOO ^O   ^ = = = ^= = =r3   rw  c                  f    e Zd ZddZd dZd!d
Zd"dZd#dZd"dZd#dZ	d$dZ
d%dZd&dZd'dZdS )(InvokeSubgraphCacher(   r   c                    i | _         i | _        t          t                    | _        t          t
                    | _        i | _        d S rj   )autograd_cacheproxy_dispatch_cacher   listdynamo_installed_submodulesr0  lazy_bwd_cacheeffects_cacherT   s    r1   r  zInvokeSubgraphCache.__init__  sJ    359;!ALTARAR(  	
  	r3   rx  r?   ry  r)   c                F    | j         |                             |           d S rj   )r  r   r{  s      r1   r|  z2InvokeSubgraphCache.add_dynamo_installed_submodule  s$    (/66zBBBBBr3   r   c                8    | j                             |g           S rj   )r  getr~  s     r1   r  z3InvokeSubgraphCache.get_dynamo_installed_submodules  s    /33E2>>>r3   r  r   c                    || j         |<   d S rj   )r  r  s      r1   r  z*InvokeSubgraphCache.add_autograd_key_entry  s    *-J'''r3   r  c                8    | j                             |d           S rj   )r  r  r  s     r1   r  z*InvokeSubgraphCache.get_autograd_key_entry  s    "&&z4888r3   c                    || j         |<   d S rj   )r  r  s      r1   r  z,InvokeSubgraphCache.add_proxy_dispatch_entry  s    03!*---r3   c                8    | j                             |d           S rj   )r  r  r  s     r1   r  z,InvokeSubgraphCache.get_proxy_dispatch_entry  s    (,,Z>>>r3   r  r  r  r  c                ^    t          | j        |                   }||f| j        |         |<   |S rj   )r   r  )r/   ry  r  r  	num_gmodss        r1   r  z&InvokeSubgraphCache.add_lazy_bwd_entry  s7     +J788	=A9<MJ'(89r3   r  c                Z    || j         vrdS | j         |                             |d          S )N)NN)r  r  r  s      r1   r  z&InvokeSubgraphCache.get_lazy_bwd_entry  s6     T000<":.223C\RRRr3   effectsr(  c           	         | j                             |d          x}r||k    rt          d| d| d| d          || j         |<   dS )z>Store the effect types for a given invoke_subgraph identifier.NzPDifferent number of effects were found for invoke_subgraph call with identifier z,. 
Previously we had the following effects: z.
But now we have: .)r  r  r.   )r/   ry  r  prev_effectss       r1   add_effectszInvokeSubgraphCache.add_effects  s    -11*dCCC< 	,&&$3,63 3@L3 3 )03 3 3   *1:&&&r3   
set | Nonec                8    | j                             |d          S )zARetrieve the effect types for a given invoke_subgraph identifier.N)r  r  r  s     r1   get_effectszInvokeSubgraphCache.get_effects!  s    !%%j$777r3   Nr  r  r  r  r  r  r  )ry  r)   r  r(  r(   r   )ry  r)   r(   r  )rJ   rK   rL   r  r|  r  r  r  r  r  r  r  r  r  r9   r3   r1   r  r    s        	 	 	 	C C C C? ? ? ?. . . .9 9 9 94 4 4 4? ? ? ?	 	 	 	S S S S
1 
1 
1 
18 8 8 8 8 8r3   r  c                      e Zd Zd	dZd
dZdS )HopDispatchSetCacher(   r   c                <    ddl m} |t                      i| _        d S )Nr   )invoke_subgraph)'torch._higher_order_ops.invoke_subgraphr  r  hop_cache_map)r/   r  s     r1   r  zHopDispatchSetCache.__init__'  s.    KKKKKK-/B/D/DEr3   optorch._ops.HigherOrderOperatorHopSubgraphCache | Nonec                2    || j         vrd S | j         |         S rj   )r  )r/   r  s     r1   	get_cachezHopDispatchSetCache.get_cache-  s#    T'''4!"%%r3   Nr  )r  r  r(   r  )rJ   rK   rL   r  r  r9   r3   r1   r  r  &  s@        F F F F& & & & & &r3   r  c                  v    e Zd Zedd            Zedd            ZddZedd	            Zedd            ZdS )CompileContextr(   c                 P    t           j        t          d          t           j        S )Nzcompile_context is not set)_TLScompile_contextr.   r9   r3   r1   r  zCompileContext.getI  s#    ' !=>>>##r3   CompileContext | Nonec                 .    t          t          dd           S Nr  getattrr  r9   r3   r1   try_getzCompileContext.try_getO      t.555r3   r4   r6   r   c                    |4t          |t                    st          dt          |                     || _        d| _        g | _        d S )Nz*compile_id must be None or CompileId, got r   )r   r#   r.   r2  r4   rQ   shape_env_guards)r/   r4   s     r1   r  zCompileContext.__init__S  sZ    !*Z*K*K! OT*=M=MOO   -7+-r3   c                 J    t                                           } | d S | j        S rj   )r  r  r4   rT   s    r1   current_compile_idz!CompileContext.current_compile_id]  s%    %%''<4r3   TraceId | Nonec                     t                                           } | d S | j        d S t          | j        | j                  S rj   )r  r  r4   rP   rQ   rT   s    r1   current_trace_idzCompileContext.current_trace_idd  s>    %%''<4?"4t555r3   N)r(   r  )r(   r  )r4   r6   r(   r   )r(   r6   )r(   r  )	rJ   rK   rL   r   r  r  r  r  r  r9   r3   r1   r  r  H  s        $ $ $ \$
 6 6 6 \6. . . .    \ 6 6 6 \6 6 6r3   r  c                  2    e Zd ZU dZded<   ded<   ded<   dS )	InlinedCodeCachez8Cache for code-object-derived data used during inlining.z	list[Any]instructionszdict[Any, int]indexofdict[str, Any]code_optionsN)rJ   rK   rL   r  rM   r9   r3   r1   r  r  n  s<         BB      r3   r  c                  `   e Zd ZdZed"d            Zed#d            Zd$d	Zd%d
Zee	d&d                        Z
ed'd            Zd(dZeej	        d)d                        Zeej	        d*d                        Zeej	        d+d                        Zed,d            Zed-d             Zd!S ).r`  z
    Provides the currently installed TracingContext, or None.

    Note that it is a staticmethod, and invocations outside of `with tracing()` (see below), are valid but
    will return None.
    r(   TracingContext | Nonec                 .    t          t          dd           S )Ntracing_contextr  r9   r3   r1   r  zTracingContext.try_get  r  r3   c                 Z    t                                           x} r| S t          d          )Nz<TracingContext.get() must be called within an ongoing trace.)r`  r  RuntimeError)ctxs    r1   r  zTracingContext.get  s5     ((***3 	JJ
 
 	
r3   	fake_modeFakeTensorMode | Noner   c                   t                      | _        t                      | _        t	                      | _        t                      | _        t                      | _        t                      | _	        || _
        g | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d| _        t+                      | _        d| _        t1                      | _        g | _        d S r  )rq  guards_contextr-  module_contextr>  global_contextr0  previously_inlined_functionspreviously_cleaned_instructionsinlined_code_cacher  frame_summary_stackloc_in_framefw_metadataddp_optimizer_ctxaot_graph_nameparams_flatparams_flat_unwrap_subclassesparams_unwrapped_to_flat_indexoutput_strides#force_unspec_int_unbacked_size_liker   tensor_to_contextfakify_first_callr  hop_dispatch_set_cachetraced_code)r/   r  s     r1   r  zTracingContext.__init__  s    +oo+oo+oo<@FF)?Cvv,?Cvv09AC  :>7;=A04-1?C*@D+ DH 490!8!:!:
 "'&9&;&;#+-r3   c                    i | j         _        | j                                         | j                                         | j                                         d S rj   )r  r7  r  clearr  r  rT   s    r1   r  zTracingContext.clear  sT     ,.()//111,22444%%'''''r3   kwargsr   Generator[None, None, None]c               +    K   i }t                                           }| D ]}t          ||          ||<   |                                 D ]\  }}t	          |||           	 d V  |                                D ]\  }}t	          |||           d S # |                                D ]\  }}t	          |||           w xY wrj   )r`  r  r  r>   setattr)r  priorr  r  vals        r1   patchzTracingContext.patch  s         "" 	+ 	+C c**E#JJ 	# 	#HCCc""""	'EEE!KKMM ' 'SS#&&&&' 'EKKMM ' 'SS#&&&&'s   "B -C traceback.StackSummaryc                     t                                           } | t          j                    S | j        }| j        ||                                 gz   }t          j                            |          S rj   )r`  r  	tracebackStackSummaryr  r  _populate_loc_in_frame_summary	from_list)r/   r   s     r1   ra  zTracingContext.extract_stack  sh    %%''<)+++((T@@BBCCE%//666r3   traceback.FrameSummaryc                t    | j         t          d          | j         \  }}}t          j        |||d          S )Nzloc_in_frame must not be NoneF)lookup_line)r  r.   r  FrameSummary)r/   filenamelineno
frame_names       r1   r  z-TracingContext._populate_loc_in_frame_summary  sD    $ !@AAA'+'8$&*%h
PUVVVVr3   c               #    K   t                                           } t          j        j                            | dg           5  t          j        j                            | dd           5  	 d V  n*# t          $ r}t          |d          sd |_         d }~ww xY w	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr  r  
real_stack)	r`  r  unittestmockr  r   rA   hasattrr  )tcrG   s     r1   clear_framezTracingContext.clear_frame  s_      !!M&&r+@"EE	 	M&&r>4@@	 	   $ q,// (#'AL) 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sZ   'B?)B'+A0/B'0
B:BBB'B?'B+	+B?.B+	/B??CCframe_summarytraceback.FrameSummary | Nonec              #    K   t                                           }| |j                            |            |j        }d |_        	 d V  n<# t
          $ r/}t          |d          s|                                |_         d }~ww xY w	 | |j        	                                 ||_        d S # | |j        	                                 ||_        w xY w)Nr  )
r`  r  r  r   r  rA   r  ra  r  pop)r  r  oldrG   s       r1   current_framezTracingContext.current_frame  s       !!$"))-888o		"EEEE 	 	 	1l++ 2!//11	  (&**,,,!BOOO (&**,,,!BO!!!!s*   A B- 
B*B  BB- -$C:Generator[list[tuple[int, ...] | None] | None, None, None]c               #     K   t                                           } | d V  d S | j        }g | _        	 | j        V  || _        d S # || _        w xY wrj   )r`  r  r  )r  old_output_stridess     r1   report_output_stridesz$TracingContext.report_output_strides"  st      
 ##%%:JJJF.	3#### 2B 2B2222s   	A 	Ar  r)   r  r?   r  c                H    | ||ft                                           _        d S rj   )r`  r  r  )r  r  r  s      r1   set_current_loczTracingContext.set_current_loc2  s%     .6vz,J)))r3   list[CodeType] | Nonec                 J    t                                           } | d S | j        S rj   )r`  r  r  )r  s    r1   get_traced_codezTracingContext.get_traced_code8  s%    ##%%:4~r3   N)r(   r  )r(   r`  )r  r  r(   r   r  )r  r   r(   r  )r(   r  )r(   r	  )r(   r  )r  r  r(   r  )r(   r  )r  r)   r  r?   r  r)   r(   r   )r(   r#  )rJ   rK   rL   r  r   r  r  r  r  r   r  ra  r  
contextlibr  r  r   r"  r%  r9   r3   r1   r`  r`  w  s         6 6 6 \6 
 
 
 \
3. 3. 3. 3.j( ( ( ( ' ' ' ^ \' 7 7 7 \7W W W W     \< " " "  \"* 3 3 3  \3 K K K \K
    \  r3   r`  contextr  r(   ,Generator[CompileContext | None, None, None]c              #     K   t          t          dd           }| t          _        	 | V  |t          _        d S # |t          _        w xY wr  )r  r  r  )r'  old_contexts     r1   r  r  @  sR       $ 1488K"D+*{****s	   8 Ar  ,Generator[TracingContext | None, None, None]c              #    K   t          t          dd          }| t          _        	 | V  n># t          $ r1}t	          |d          s| |                                 |_         d}~ww xY w	 | 1| j        *| j        j        | j        j        	                                 |t          _        dS # | 1| j        *| j        j        | j        j        	                                 |t          _        w xY w)z
    This function installs the passed in tracing context as a dynamic scoped
    global variable.

    Calls to TracingContext.get() while not under a `with tracing()` context
    will return None.
    r  Nr  )
r  r  r  rA   r  ra  r  r  	shape_envcleanup)r'  r*  rG   s      r1   tracingr/  L  s      $ 1488K"D+   q,'' 	3G,?"0022AL 	 !-!+7'//111* !-!+7'//111*****s&   + B+ 
A&,A!!A&&B+ +AC,rB   type[T]r  r   c                    d S rj   r9   rB   r  s     r1   dataclass_with_cached_hashr3  i  r  r3   r   Callable[[type[T]], type[T]]c                    d S rj   r9   r2  s     r1   r3  r3  m  s	     $'3r3   type[T] | None&type[T] | Callable[[type[T]], type[T]]c                .    dfd}| |S  ||           S )N	cls_innerr0  r(   c                j    t          j        | fi }| j        dfd}d }||_        ||_        |S )Nr(   r?   c                |    t          | d          s%t                              | d |                      | j        S )Nr   )r  r   __setattr__r   )r/   old_hashs    r1   r   z:dataclass_with_cached_hash.<locals>.wrap.<locals>.__hash__{  s>    4)) B""4((4..AAA:r3   c                t     t          j                   }t           fd|D                       } j        |fS )Nc              3  B   K   | ]}t          |j                  V  d S rj   )r  r   )rl  fr/   s     r1   rm  zOdataclass_with_cached_hash.<locals>.wrap.<locals>.__reduce__.<locals>.<genexpr>  s/       G G1qv!6!6 G G G G G Gr3   )dataclassesfieldstupler   )r/   rB  field_valuess   `  r1   
__reduce__z<dataclass_with_cached_hash.<locals>.wrap.<locals>.__reduce__  sD     !'--F  G G G G G G GGGLNL11r3   r   )rA  r   r   rE  )r9  new_clsr   rE  r=  r  s       @r1   wrapz(dataclass_with_cached_hash.<locals>.wrapw  sh    '	<<V<<%	 	 	 	 	 	
	2 	2 	2 $'r3   )r9  r0  r(   r0  r9   )rB   r  rG  s    ` r1   r3  r3  s  s;         * {499r3   c                      e Zd ZddZddZddZej        dd
            Ze	dd            Z
ej        dd            Zd dZd!dZddZddZdS )"r   r(   rh   c                    dS r  r9   rT   s    r1   is_dict_keyzSource.is_dict_key      ur3   c                    dS r  r9   rT   s    r1   is_ephemeralzSource.is_ephemeral  rK  r3   codegenr   r   c                    t           rj   NotImplementedError)r/   rN  s     r1   reconstructzSource.reconstruct  s    !!r3   rW   c                    t           rj   rP  rT   s    r1   r   zSource.guard_source  s    !!r3   r)   c                    t           )a  
        A template for the name of the source. Used to prevent code duplication between
        `name` and `get_value`.

        For non-ChainedSources, `name` and `get_value` use the returned string directly.

        For ChainedSources, `name` and `get_value` expect the return to be a format string
        with `{0}` present - `name` and `get_value` will apply different values to this function's
        returned format string.
        rP  rT   s    r1   _name_templatezSource._name_template  s
     "!r3   c                    | j         S rj   )rU  rT   s    r1   r   zSource.name  s    ""r3   globalsr  localscache&weakref.WeakKeyDictionary[Source, Any]r   c                T    | |v r||          S t          | j        ||          }||| <   |S rj   )evalrU  )r/   rW  rX  rY  r   s        r1   	get_valuezSource.get_value  s9     5==;T('6::dr3   fnCallable[..., Any]r   c                V    | j         t          j        u rt          t	          | |          S rj   )r   rW   r   rQ  r   )r/   r^  s     r1   
make_guardzSource.make_guard  s'     444%%T2r3   c                4    | j                                         S rj   )r   ru   rT   s    r1   ru   zSource.is_specialized_nn_module  s     99;;;r3   c                ,    | j         t          j        k    S )z+True if you can guard on attributes of this)r   rW   r   rT   s    r1   subguards_allowedzSource.subguards_allowed  s     K$???r3   Nr   )rN  r   r(   r   r   rI   rW  r  rX  r  rY  rZ  r(   r   )r^  r_  r(   r   )rJ   rK   rL   rJ  rM  rR  r   cached_propertyr   r   rU  r   r]  ra  ru   rd  r9   r3   r1   r   r     s             " " " " " " " " " " " X" # # # #
 
 
 
   
< < < <@ @ @ @ @ @r3   r   c                  ~    e Zd ZU ded<   ddZddZej        dd            Zdd	Z	ej        dd            Z
ddZdS )ChainedSourcer   baser(   rh   c                4    | j                                         S rj   )ri  rJ  rT   s    r1   rJ  zChainedSource.is_dict_key  s    y$$&&&r3   c                4    | j                                         S rj   )ri  rM  rT   s    r1   rM  zChainedSource.is_ephemeral  s    y%%'''r3   rW   c                    | j         j        S rj   )ri  r   rT   s    r1   r   zChainedSource.guard_source  s    y%%r3   c                l    | }t          |t                    r|j        }t          |t                    |S rj   )r   rh  ri  )r/   currents     r1   get_basezChainedSource.get_base  s9    -00 	#lG -00 	#r3   r)   c                J    | j                             | j        j                  S rj   )rU  r   ri  r   rT   s    r1   r   zChainedSource.name  s    "))$).999r3   rW  r  rX  rY  rZ  r   c                    | |v r||          S d}d}||v rd| }|dz  }||v | j                             |||          ||<   t          | j                            |          ||          }||= ||| <   |S )Ntmpr   rX   )ri  r]  r\  rU  r   )r/   rW  rX  rY  tmpvarcounterr   s          r1   r]  zChainedSource.get_value  s     5==;$7__FqLG  ,,WfeDDvT(//77&II6Ndr3   Nr   r   )r(   r   rI   re  )rJ   rK   rL   rM   rJ  rM  r   rf  r   ro  r   r]  r9   r3   r1   rh  rh    s         LLL' ' ' '( ( ( ( & & & &    : : : :     r3   rh  inputsr  c                B   ddl mm}m} t                                          x}r|j        }||S g }ddlm} t          t           |                                D ]-\  }t          ||          r|                    |df           .t          j        |           }t          |          D ]\  }	t          |	          r|                    |	j        df           t          |	          rKg }
 ||	|
           fd|
D             }|                    fd	t          |          D                        |r`|d         \  }}}|d
d         D ]G\  }}}||ur=t#          d| d| d| d| d| d| d| d| d|j         d| d| d|j                   H|S dS )a  
    Attempts to "detect" what the current fake mode is.  If there is one ambiently
    available from TracingContext, we preferentially use that.  Otherwise, we
    heuristically detect the fake mode via the following sources, in order of
    priority:

        - Currently active fake mode on stack
        - Fake mode associated with passed in tensors (inputs does not
          have to be flattened)
    r   )
FakeTensorr   get_plain_tensorsN _get_current_dispatch_mode_stackzactive fake modezfake tensor input)outc                4    g | ]}t          |          |S r9   )r   )rl  xrw  s     r1   
<listcomp>z$detect_fake_mode.<locals>.<listcomp>$  s8     . . .*Q
";";.. . .r3   c                0    g | ]\  }}|j         d  |fS )zsubclass input )r  )rl  ixtensoris      r1   r~  z$detect_fake_mode.<locals>.<listcomp>(  s@       "F %'<'<'<bA  r3   rX   zfake mode (z) from r   z doesn't match mode (z

fake mode from z allocated at:
z
fake mode from )torch._subclasses.fake_tensorrw  r   rx  r`  r  r  torch.utils._python_dispatchrz  	enumeratereversedr   r   pytreetree_leavesr   r   r.   r   )ru  r   rx  r'  r  
fake_modesrz  mflat_inputs
flat_inputr{  fake_tensorsdesc1i1desc2i2rw  r  s                   @@r1   detect_fake_moder    s             !((***w %	 JMMMMMM(#C#C#E#EFFGG : :1a(( 	:q"4a8999$V,,K";//  :j*-- 	Nz35H!LMMM(44 	;=Cjc2222. . . .. . .L    &/&=&=      )!}	5"&qrrN 	 	LAub!!$L) L LE L LB L LUV L L_d L Lgi L L&+L L.0L LBK/L L&+L L.0L LBC'L L   " tr3   c                     ddl m}  ddlm} t	          t           |                                D ]\  }}t          ||           r|c S dS )z~
    Inspects the dispatch mode stack for an active fake mode and returns it.
    Returns None if no fake mode is active.
    r   r   ry  N)r  r   r  rz  r  r  r   )r   rz  rS   r  s       r1   active_fake_moder  =  s|    
 =<<<<<MMMMMM(#C#C#E#EFFGG  1a(( 	HHH	 4r3   )r'  r  r(   r(  )r'  r  r(   r+  )rB   r0  r  r   r(   r0  rj   )rB   r   r  r   r(   r4  )rB   r6  r  r   r(   r7  )ru  r   r(   r  )r(   r  )b
__future__r   r&  rA  enumr   loggingre	threadingr  unittest.mockr  r   abcr   collectionsr   r   r   typingr   r	   r
   r   r   r   r   typing_extensionsr   r   torch.utilsr   r  torch.utils._ordered_setr   r  r   torch.utils._tracebackr   r   torch.utils.weakr   	getLoggerrJ   r   collections.abcr   r   r   typesr   sympy"torch._dynamo.backends.distributedr   torch._dynamo.codegenr   &torch._functorch._aot_autograd.schemasr   r  r   compiler:   r;   r#   rP   EnumrW   r   r   r   r   r   r   r   r  r  r  r!  r-  r5  r>  rL  rq  rw  r  r  localr  r  r  r`  r  r/  r3  r   rh  r  r  r9   r3   r1   <module>r     s   " " " " " "               				                    # # # # # # % % % % % % ! ! ! ! ! ! W W W W W W W W W W W W W W W W W W 1 1 1 1 1 1  ) ) ) ) ) ) / / / / / / F F F F F F B B B B B B B B 4 4 4 4 4 4 g!!  	===========LLLFFFFFF//////JJJJJJ<<<<<<  RZ PQQ "
X  " $D1117J 7J 7J 7J 7J 7J 7J 217Jt7 7 7 7 7j 7 7 7<
 <
 <
 <
 <
$) <
 <
 <
~	 	 	 	 	 	 	 	 d###       $#         T"""u' u' u' u' u' u' u' #"u'p GCLL d###	 	 	 	 	 	 	 $#	 d###	 	 	 	 	l 	 	 $#	 d###* * * * *\ * * $#*

8 8 8 8 8WQZ 8 8 8( ( ( ( ( ( ( (8( ( ( ( ( ( ( (0+ + + + +N#?@ + + +( ( ( ( ( ( ( (0$ $ $ $ $N#?@ $ $ $R,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
^< < < < <N#89 < < <= = = = = = = =B?8 ?8 ?8 ?8 ?8* ?8 ?8 ?8D
& 
& 
& 
& 
& 
& 
& 
& y&#6 #6 #6 #6 #6 #6 #6 #6L ! ! ! ! ! ! ! !F F F F F F F FR + + + + + + + +8 
 K K K 
 K 
' ' ' ' 
'
     @ 4(((6@ 6@ 6@ 6@ 6@ 6@ 6@ )(6@t 4((() ) ) ) )F ) ) )()X> > > > >B     r3   