
    9i>f                       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mZm	Z	 d dl
mZ d dlmZ d dlmZmZmZmZ d dlmZmZmZmZ d dlZd dlmZ d	d
lmZ d	dlmZ erd dlZd dlm Z  d	dl!m"Z" d	dl#m$Z$ d	dlm%Z% ddZ& ej'        e(          Z)ej*        +                    e(d          Z, G d de-          Z. G d de.          Z/ G d de.          Z0 G d de.          Z1 G d de1          Z2 G d d e1          Z3 G d! d"e1          Z4 G d# d$e1          Z5 G d% d&e.          Z6 G d' d(e.          Z7 G d) d*e.          Z8 G d+ d,e.          Z9 G d- d.e.          Z: G d/ d0e:          Z; G d1 d2e.          Z< G d3 d4e<          Z= G d5 d6e.          Z> G d7 d8e<          Z? G d9 d:e<          Z@ G d; d<e<          ZA G d= d>e<          ZB G d? d@e?          ZC G dA dBe	          ZD G dC dDe<          ZE G dE dFe.          ZF G dG dHe<          ZG G dI dJe.          ZH G dK dLe.          ZI G dM dNe.          ZJ G dO dPeK          ZL G dQ dReK          ZM G dS dTe.          ZN G dU dVe.          ZO G dW dXeO          ZP G dY dZeO          ZQ G d[ d\eQ          ZR G d] d^eQ          ZS G d_ d`eO          ZT G da dbeO          ZU G dc ddeO          ZV G de dfeO          ZW G dg dheO          ZXeYePeZeQe[eRe\eTe]eSe^eUe-eVe_eWe`eXi	ZaddlZbdddmdduZcddxZdeje        jf        jg        eje        jf        jh        eje        jf        ji        eje        jf        jj        eje        jf        jk        fZlddZmddZn ed	          dd            ZoddZp eq            ZrerddddZs G d d          ZtdddZuddZvddZw	 dddZxddZyddZzddZ{	 	 dddZ|ddZ}ddZ~ddZ	 	 dddZdS )    )annotationsN)autoEnum)	lru_cache)Path)extract_stack
format_excformat_listStackSummary)AnyNoReturnOptionalTYPE_CHECKING)get_file_path_2   )config)counters)	CompileId)DynamoTracerOutput)InstructionTranslatorBase)DynamoFrameType	case_namestrreturnc                4    d|                      dd          z   S )NzhFor more information about this error, see: https://pytorch.org/docs/main/generated/exportdb/index.html#_-)replace)r   s    D/var/www/icac/venv/lib/python3.11/site-packages/torch/_dynamo/exc.pyexportdb_error_messager    9   s%    	I


C
%
%	&    graph_breaksc                        e Zd Zd fdZ xZS )TorchDynamoExceptionargsr   kwargsr   Nonec                H     t                      j        |i | d | _        d S N)super__init___torch_dynamo_tracer_outputselfr%   r&   	__class__s      r   r+   zTorchDynamoException.__init__F   s-    $)&)))IM(((r!   r%   r   r&   r   r   r'   __name__
__module____qualname__r+   __classcell__r/   s   @r   r$   r$   E   sG        N N N N N N N N N Nr!   r$   c                      e Zd ZdS )InternalTorchDynamoErrorNr2   r3   r4    r!   r   r8   r8   K           Dr!   r8   c                      e Zd ZdS )ResumePrologueTracingErrorNr9   r:   r!   r   r=   r=   O   r;   r!   r=   c                  2     e Zd ZU ded<   ddd
 fd	Z xZS )RestartAnalysisOptional[str]restart_reasonN)rA   r%   r   r   r'   c               B    || _          t                      j        |  d S r)   )rA   r*   r+   )r.   rA   r%   r/   s      r   r+   zRestartAnalysis.__init__V   s%    ,$r!   )r%   r   rA   r@   r   r'   r2   r3   r4   __annotations__r+   r5   r6   s   @r   r?   r?   S   sX         !!!!CG                        r!   r?   c                      e Zd ZdS )SpeculationRestartAnalysisNr9   r:   r!   r   rF   rF   [   r;   r!   rF   c                      e Zd ZdS )UnspecializeRestartAnalysisNr9   r:   r!   r   rH   rH   _   r;   r!   rH   c                      e Zd ZdS ) CompileCollectiveRestartAnalysisNr9   r:   r!   r   rJ   rJ   c   r;   r!   rJ   c                      e Zd ZdS )TensorifyScalarRestartAnalysisNr9   r:   r!   r   rL   rL   g   r;   r!   rL   c                      e Zd ZdS )	SkipFrameNr9   r:   r!   r   rN   rN   k   r;   r!   rN   c                      e Zd ZdS )TorchRuntimeErrorNr9   r:   r!   r   rP   rP   o   r;   r!   rP   c                        e Zd Zd fdZ xZS )InvalidBackendnamer   r   r'   c                R    t                                          d|d           d S )NzInvalid backend: z=, see `torch._dynamo.list_backends()` for available backends.)r*   r+   )r.   rS   r/   s     r   r+   zInvalidBackend.__init__t   s7    eeee	
 	
 	
 	
 	
r!   )rS   r   r   r'   r1   r6   s   @r   rR   rR   s   s=        
 
 
 
 
 
 
 
 
 
r!   rR   c                        e Zd Zd fdZ xZS )ResetRequiredr   r'   c                n    t                                          t          j        d                     d S )Nz
                Must call `torch._dynamo.reset()` before changing backends.  Detected two calls to
                `torch.compile()` with a different backend compiler arguments.
                )r*   r+   textwrapdedent)r.   r/   s    r   r+   zResetRequired.__init__{   s=    O 	
 	
 	
 	
 	
r!   r   r'   r1   r6   s   @r   rV   rV   z   s=        
 
 
 
 
 
 
 
 
 
r!   rV   c                  (     e Zd Zd fdZdd
Z xZS )ShortenTracebackr%   r   first_useful_frameOptional[types.FrameType]r&   r   r'   c               H     t                      j        |i | || _        d S r)   )r*   r+   r]   )r.   r]   r%   r&   r/   s       r   r+   zShortenTraceback.__init__   s/     	$)&)))"4r!   typing.Selfc                    | j         }| j        |t          j        r| S |j        | j        ur!|j        }|
J d            |j        | j        u!|                     |          S )Nz#internal error, please report a bug)__traceback__r]   r   verbosetb_frametb_nextwith_traceback)r.   tbs     r   remove_dynamo_framesz%ShortenTraceback.remove_dynamo_frames   sq    "*bjFNjKk!888B>>#H>>> k!888 ""2&&&r!   )r%   r   r]   r^   r&   r   r   r'   )r   r`   )r2   r3   r4   r+   rh   r5   r6   s   @r   r\   r\      sQ        5 5 5 5 5 5' ' ' ' ' ' ' 'r!   r\   c                        e Zd Zd
 fd	Z xZS )BackendCompilerFailed
backend_fnr   inner_exception	Exceptionr]   r^   r   r'   c                    t          |dd          | _        || _        d| j        dt          |          j         d| }t                                          ||           d S )Nr2   ?zbackend=z	 raised:
z: )r]   )getattrbackend_namerl   typer2   r*   r+   )r.   rk   rl   r]   msgr/   s        r   r+   zBackendCompilerFailed.__init__   sq     $J
C@@.k*kk_8M8M8VkkZikk1CDDDDDr!   )rk   r   rl   rm   r]   r^   r   r'   r1   r6   s   @r   rj   rj      sG        	E 	E 	E 	E 	E 	E 	E 	E 	E 	Er!   rj   c                  :     e Zd Zdddd fdZddZdddZ xZS )UnsupportedN)r   
real_stackrs   r   r   r@   rv   None | StackSummaryr   r'   c                   t                                          |           |s#t          j        j                                        }|| _        || _        d | _        | 	                                 || _
        d S r)   )r*   r+   torch_guardsTracingContextr   rv   rs   categoryadd_to_statsr   )r.   rs   r   rv   r/   s       r   r+   zUnsupported.__init__   sn     	 	F5CCEEJ$'+(1r!   c                    | j         J t          | j                  | j        xx         dz  cc<   t          | j                  | j                 dk    rt          | j                  | j        = d S d S )Nr   r   r|   r   rs   r.   s    r   remove_from_statszUnsupported.remove_from_stats   sm    }((()))Q.)))DM"48,11'111 21r!   unimplementedr|   c                T    || _         t          |         | j        xx         dz  cc<   d S )Nr   r   )r.   r|   s     r   r}   zUnsupported.add_to_stats   s2     48$$$)$$$$$r!   )rs   r   r   r@   rv   rw   r   r'   rZ   )r   )r|   r   r   r'   )r2   r3   r4   r+   r   r}   r5   r6   s   @r   ru   ru      s|        
 $(*.2 2 2 2 2 2 2 2 2 2 2 2* * * * * * * * *r!   ru   c                      e Zd ZdS )$UnknownPropertiesDuringBackwardTraceNr9   r:   r!   r   r   r      r;   r!   r   c                      e Zd ZdS )RecompileErrorNr9   r:   r!   r   r   r      r;   r!   r   c                      e Zd ZdS )ArgsMismatchErrorNr9   r:   r!   r   r   r      r;   r!   r   c                      e Zd ZdS )AttributeMutationErrorNr9   r:   r!   r   r   r      r;   r!   r   c                      e Zd ZdS )InfiniteGeneratorErrorNr9   r:   r!   r   r   r              Dr!   r   c                      e Zd ZdS )SideEffectsErrorNr9   r:   r!   r   r   r      r;   r!   r   c                      e Zd ZdZdS )CondOpArgsMismatchErrorz?
    Internal error from cond() due to arguments mismatch.
    N)r2   r3   r4   __doc__r:   r!   r   r   r      s           r!   r   c                      e Zd Z e            Z e            Z e            Z e            Z e            Z e            Z	 e            Z
 e            ZdS )UserErrorTypeN)r2   r3   r4   r   DYNAMIC_CONTROL_FLOWANTI_PATTERNSTANDARD_LIBRARYCONSTRAINT_VIOLATIONDYNAMIC_DIMINVALID_INPUTINVALID_OUTPUT*UNSUPPORTED_ALIASED_MUTATED_DYNAMIC_INPUTSr:   r!   r   r   r      sl        466466Ltvv466$&&KDFFMTVVN15...r!   r   c                  $     e Zd Z	 dd fd
Z xZS )	UserErrorN
error_typer   rs   r   r   r@   r   r'   c                    |It          |t                    sJ |                    d          r|dz  }n|dz  }|t          |          z  }t	                                          |           || _        || _        dS )aG  
        Type of errors that would be valid in Eager, but not supported in TorchDynamo.
        The error message should tell user about next actions.

        error_type: Type of user error
        msg: Actionable error message
        case_name: (Optional) Unique name (snake case) for the usage example in exportdb.
        N. 
)
isinstancer   endswithr    r*   r+   r   message)r.   r   rs   r   r/   s       r   r+   zUserError.__init__   s      i-----||C   s
t))444C$r!   r)   )r   r   rs   r   r   r@   r   r'   r1   r6   s   @r   r   r      sE        NR          r!   r   c                      e Zd ZdS )SkipCodeRecursiveExceptionNr9   r:   r!   r   r   r     r;   r!   r   c                      e Zd ZdS )RecompileLimitExceededNr9   r:   r!   r   r   r     r;   r!   r   c                      e Zd ZddZdS )StepUnsupportedr   r'   c                V    t           j        j                                        | _        d S r)   )ry   rz   r{   r   rv   r   s    r   r+   zStepUnsupported.__init__  s    -6DDFFr!   NrZ   )r2   r3   r4   r+   r:   r!   r   r   r     s.        G G G G G Gr!   r   c                      e Zd ZdS )UnsafeScriptObjectErrorNr9   r:   r!   r   r   r     r;   r!   r   c                  "     e Zd Zd	d
 fdZ xZS )UncapturedHigherOrderOpErrorNrs   r   rv   Optional[StackSummary]r   r'   c                    t                                          |           || _        ||n"t          j        j                                        | _        d S r)   )r*   r+   rs   ry   rz   r{   r   rv   )r.   rs   rv   r/   s      r   r+   z%UncapturedHigherOrderOpError.__init__  sP     % J-;;== 	r!   r)   )rs   r   rv   r   r   r'   r1   r6   s   @r   r   r     sB        
 
 
 
 
 
 
 
 
 
 
r!   r   c                      e Zd ZdS )IncorrectUsageNr9   r:   r!   r   r   r     r;   r!   r   c                      e Zd ZdS )FailOnRecompileLimitHitNr9   r:   r!   r   r   r   &  r;   r!   r   c                      e Zd ZdS )PackageErrorNr9   r:   r!   r   r   r   *  r;   r!   r   c                        e Zd Zd fdZ xZS )ObservedExceptionr%   r   r&   r   r'   c                     t                      j        |i | t          j        j                                        | _        d S r)   )r*   r+   ry   rz   r{   r   rv   r-   s      r   r+   zObservedException.__init__0  s;    $)&)))(-(D(R(R(T(Tr!   r0   r1   r6   s   @r   r   r   .  sG        U U U U U U U U U Ur!   r   c                  ,     e Zd ZU ded<   d	 fdZ xZS )
ObservedUserStopIterationzOptional[Any]valuer%   r   r&   r   r'   c                    t                                          d           t          |          dk    r|d         | _        d S d | _        d S )Nzunhandled `raise StopIteration`r   )r*   r+   lenr   r-   s      r   r+   z"ObservedUserStopIteration.__init__;  sE    :;;;t99q==aDJJJDJJJr!   r0   rC   r6   s   @r   r   r   5  sK                  r!   r   c                      e Zd ZdS )ObservedLookupErrorNr9   r:   r!   r   r   r   C  r   r!   r   c                      e Zd ZdS )ObservedIndexErrorNr9   r:   r!   r   r   r   H  r   r!   r   c                      e Zd ZdS )ObservedKeyErrorNr9   r:   r!   r   r   r   M  r   r!   r   c                      e Zd ZdS )ObservedGeneratorExitNr9   r:   r!   r   r   r   R  r;   r!   r   c                      e Zd ZdS )ObservedAttributeErrorNr9   r:   r!   r   r   r   V  r   r!   r   c                      e Zd ZdS )ObservedRuntimeErrorNr9   r:   r!   r   r   r   [  r   r!   r   c                      e Zd ZdS )ObservedNotImplementedErrorNr9   r:   r!   r   r   r   `  r;   r!   r   c                      e Zd ZdS )ObservedTypeErrorNr9   r:   r!   r   r   r   d  r   r!   r   exc_typetype[Exception]type[ObservedException]c                    | t           vrAt          | dt          |                     }t          d| dt          fi           t           | <   t           |          S )Nr2   ObservedError)observed_exception_maprp   r   rr   r   )r   rS   s     r   get_dynamo_observed_exceptionr   v  s]    ---xS]];;+/"t"""%6$8",
 ,
x( "(++r!   )r%   r&   txr   r%   Optional[list[Any]]r&   Optional[dict[str, Any]]r   c                   ddl m}  ||                               ||pg |pi           }|j                            |           t          |           }|r || |)Nr   )BuiltinVariable)	variablesr   call_functionexn_vt_stackset_current_exceptionr   )r   r   r%   r&   r   exception_vt
raised_excs          r   raise_observed_exceptionr     s     +***** #?8,,::2tzr6<UWXXLO)),777.x88J  j$
r!   r   r'   c                8    | j                                          d S r)   )r   clear_current_exception)r   s    r   handle_observed_exceptionr     s    2 O++-----r!   erm   codetypes.CodeTypegb_typecontextexplanationhints	list[str]c                   t          | |          t          j                            dd fd           t                              d           t          } |||||| d           d S )Nartifactc                     dddS )Ndynamo_graph_break_reasonstring)rS   encodingr:   r:   r!   r   <lambda>z,unimplemented_with_warning.<locals>.<lambda>  s    / 
 
 r!   c                      S r)   r:   )graph_break_msgs   r   r   z,unimplemented_with_warning.<locals>.<lambda>  s    ? r!   )metadata_fn
payload_fnz%sT)r   r   r   r   from_exclog_warning)format_error_msg_verbosery   _loggingtrace_structuredgraph_breaks_logdebugr   )r   r   r   r   r   r   _unimplementedr   s          @r   unimplemented_with_warningr    s      /q$77O	N##
 
 +*** $    4111"NN     r!   c                    t          j        |d                                          }d                    d |D                       }t          j        |d                                          }|  d| d| d| d}|S )N    r   c              3  j   K   | ].}d t          j        |d                                          z   V  /dS )z  Hint: r  N)rX   indentlstrip).0hints     r   	<genexpr>z-format_graph_break_message.<locals>.<genexpr>  sP        @D
X_T62299;;;     r!   z
  Explanation: z

  Developer debug context: )rX   r	  r
  join)r   r   r   r   	hints_strrs   s         r   format_graph_break_messager    s     /+v66==??K		  HM    I ogv..5577G 	    
 $  C Jr!   )maxsizedict[str, Any]c                    	 t          t                                                    j        } t	          dt          |           d          }t          |          5 }t          j        |          }ddd           n# 1 swxY w Y   n,# t          $ r t                              d           i }Y nw xY wi }|                                D ]\  }}|D ]}|||d         <   |S )z
    Loads the gb_type to gb_id map from the graph break registry from JSON file with caching.

    Includes historical gb_type (mapping behavior of duplicate gb_types with different gb_ids is undefined).
     zgraph_break_registry.jsonNz!Error accessing the registry fileGb_type)r   __file__resolveparentr   r   openjsonloadrm   log	exceptionitems)
script_dirregistry_pathfregistrymappingkventrys           r   _load_gb_type_to_gb_id_mapr'    s6   	(^^++--4
'J!<
 
 -   	$Ay||H	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$   9::: G   * *1 	* 	*E()GE)$%%	* Ns6   AB A;/B ;A??B A?B &B0/B0r@   c                p    d}t                      }| |v r!| d||                              d           dS dS )z
    Retrieves the GBID documentation link for a given graph break type.

    Args:
        gb_type: The graph break type to look up.

    Returns:
        A string containing the documentation URL if found, otherwise None.
    z;https://meta-pytorch.github.io/compile-graph-break-site/gb/gbGBz.htmlN)r'  r
  )r   GRAPH_BREAK_SITE_URLgb_type_to_gb_id_maps      r   get_gbid_documentation_linkr-    s[     	F  677&&&#XX';G'D'K'KD'Q'QXXX	
 4r!   F)r   r   r   r   boolc                   t          | |||          }t          |           }|r|d| z  }|rt                              |           |t          ur+d}t          |d          r|j        }t          ||          |t          |          )a  
    Called within dynamo to cause a graph break.
    Args:
        gb_type: Context-free graph break type. It should be a short string without any
                 information specific to the tracing context (i.e. no dynamically-generated strings)
        context: Developer context for the graph break. It can contain tracing context/dynamic strings.
        explanation: User-facing context-dependent explanation for the graph break. Can be dynamic.
        hints: List of user-facing hints for the graph break.
    z9
 For more details about this graph break, please visit: Nrv   )rv   )r  r-  r  warning_NOTHINGhasattrrv   ru   )	r   r   r   r   r   r   rs   documentation_linkpast_real_stacks	            r   r   r   +  s    & %Wg{E
J
JC4W== a`L^``` Cx8\** 	2&1O#/:::H
c

r!   c                  &    e Zd Zd
dZddZddZd	S )KeyErrorMsgr   r   r   r'   c                    || _         d S r)   )r   )r.   r   s     r   r+   zKeyErrorMsg.__init__R  s    


r!   r   c                *    t          | j                  S r)   )r   r   r   s    r   __str__zKeyErrorMsg.__str__U  s    4:r!   c                *    |                                  S r)   )r9  r   s    r   __repr__zKeyErrorMsg.__repr__X  s    ||~~r!   N)r   r   r   r'   )r   r   )r2   r3   r4   r+   r9  r;  r:   r!   r   r6  r6  Q  sP                   r!   r6  r   excrs   exportc                |   dd l }d | _        t          |           }|Nt          |          dk    r;|d         | _        |dd                    |                    |                     z  }t          j        r&t          | d          r|d| j	         d| j	         dz  }t          j
        st          | d	          r|d
z  }t          | d          r^t          | j        d          rIt          | j        d          r!|d| j        j         d| j        j         dz  }n|d| j        j         dz  }t          | j                  dk    rdnt          | j        d                   }t!          | t"                    r*t%          ||z             f| j        dd          z   | _        d S ||z   }|f| j        dd          z   | _        d S )Nr   z
from user code:
 r  record_filenamez!
Last frame execution written to zD. To run only this frame while debugging, run torch._dynamo.replay('z').
rv   z
Set TORCHDYNAMO_VERBOSE=1 for the internal stack trace (please do this especially if you're reporting a bug to PyTorch). For even more developer context, set TORCH_LOGS="+dynamo"
rl   minifier_pathbuck_commandz
Minifier script written to zW. Run this buck command to find the smallest traced graph which reproduces this error: r   zQ. Run this script to find the smallest traced graph which reproduces this error.
r   )	tracebackinnermost_user_frame_summaryget_real_stackr   r  r
   r   replay_record_enabledr2  r@  rc   rl   rA  rB  r%   r   r   KeyErrorr6  )r<  rs   r=  rC  rv   old_msgnew_msgs          r   augment_exc_messagerJ  \  s,   '+C$$$J#j//A"5"5+5b>(Rbggi.C.CJ.O.O&P&PRRR# 
5F(G(G 
31D 3 3+3 3 3	

 > 
gc<88 
J	
 s%&& 7_, ,  3&77 
	U0C0Q U U030C0PU U UCC _0C0Q _ _ _C
 MMQ&&bbC,<,<G#x   -#..038ABB<?C-:,r!   
compile_idr   #tuple[Optional[str], Optional[int]]c                ^    d }d }| j         | j         j        }| j         j        }|| _        ||fS r)   )rD  filenamelinenorK  )r   rK  rN  rO  s       r   get_exc_messagerP    s?     HF%11:/6ALVr!   r   c                 8    t          t                                S r)   )filter_stackr   r:   r!   r   get_stack_above_dynamorS    s    (((r!   frameOptional[DynamoFrameType]r   c                    t          | dd           }|d S |t                      }nt                      }t          j        ||z             S )Nrv   )rp   rS  r   	from_list)r<  rT  rv   stack_above_dynamos       r   rE  rE    sZ     lD11Jt  455)^^!"4z"ABBBr!   stackc                    t                      }| D ]D}|j        
d|j        v r n0d|j        v s|j        r
d|j        v r/|                    |           E|S )Nconvert_frame
eval_frameztorch._dynamo.optimize()r   rN  lineappend)rY  
user_stackrT  s      r   rR  rR    s{    J 	! 	!>!en,,E5>))J *4
BB%    r!   rS   c                p    ddl m} t          j        | d|           }|r|                    d          S d S )Nr   )TORCH_DYNAMO_RESUME_IN_PREFIXz_(\w+)_at_\d+)resume_executionra  rematchgroup)rS   ra  rd  s      r   remove_resume_prefixrf    sL    ??????H5FFFMME {{1~~4r!   c                    t                      }| D ]U}|j        
t          |j                  }|r |r|d         j        |k    r||d<   ||_        @|                    |           V|S )a1  
    When we graph break, we create a resume function and make a regular Python call
    to it, which gets intercepted by Dynamo. This behavior is normally shown in the
    traceback, which can be confusing to a user. So we can filter out resume frames
    for better traceback clarity.

    Example:
    File "..." line 3, in f
        <line 3>
    File "..." line 5, in torch_dynamo_resume_in_f_at_80
        <line 5>
    File "..." line 10, in torch_dynamo_resume_in_f_at_120
        <line 10>

    becomes
    File "..." line 10, in f
        <line 10>
    Nr?  )r   rN  rf  rS   r^  )rY  	new_stackrT  rS   s       r   collapse_resume_framesri    s    ( I $ $>!#EJ// 	$ 	$)B-"4"<"<!IbMEJJU####r!   r@  c                    d|j          d|j         d|j         d}|dz  }|t                      z  }t	          | |          }|4|dz  }|d                    t          |                    z  }|dz  }|dz  }|S )	NWON'T CONVERT r    line r   z.========== TorchDynamo Stack Trace ==========
zY
========== The above exception occurred while processing the following code ==========

r  z
==========)co_nameco_filenameco_firstlinenor	   rE  r  r
   )r<  r   r@  rT  rs   rv   s         r   r   r     s     	XWW(8WW@SWWW  CCC:<<CU++J	
 	rww{:..///txJr!   c           	     r    t          | dd           dt          | dd           dt          | dd           dS )	Nrm  z	<unknown>z (rn  rl  ro  r   ))rp   )r   s    r   format_frame_inforr    sX    4K00 	6 	6D-55	6 	6.22	6 	6 	6r!   Optional[types.CodeType]reasonc                >    | t          |           }d| d| S d| S )Nz6torch.compile intentionally decided to skip the frame z! and fall back to eager.
Reason: zVtorch.compile intentionally decided to skip the frame and fall back to eager.
Reason: rr  )r   rt  
frame_infos      r   format_skip_frame_messagerx    sO    &t,,
 Z       	
    	
r!   frame_summaryc                0    t          |           }d| d| S )NzxSkipping frame because there is a graph break in a for/while loop
torch.compile intentionally decided to skip the frame zd and fall back to eager.
Reason: Skipping frame because there is a graph break in a for/while loop.
rv  )r   ry  rw  s      r   format_loop_skip_frame_messager{  (  s5    "4((J	AK	 	 	 	r!   c           	         t           j        rt          | |||          S d|j         d|j         d|j         dt                       S )Nrk  r   rl  z 
due to: 
)r   rc   r   rm  rn  ro  r	   )r<  r   r@  rT  s       r   format_error_msgr}  2  sk     ~ K'T?EJJJ8DL 8 84+; 8 88 8)38 8 8r!   )r   r   r   r   )r   r   r   r   )
r   r   r   r   r%   r   r&   r   r   r   )r   r   r   r'   )r   rm   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   r   r   r   r   r.  r   r   )r   F)r<  rm   rs   r   r=  r.  r   r'   )r   rm   rK  r   r   rL  )r   r   r)   )r<  rm   rT  rU  r   r   )rY  r   r   r   )rS   r   r   r@   )NN)
r<  rm   r   r   r@  r@   rT  rU  r   r   )r   r   r   r   )r   rs  rt  r   r   r   )r   r   ry  r   r   r   )
__future__r   r  loggingrc  rX   typingenumr   r   	functoolsr   pathlibr   rC  r   r	   r
   r   r   r   r   r   torch._guardsry   torch._utils_internalr   r  r   utilsr   typesr   output_graphr   symbolic_convertr   r   r    	getLoggerr2   r  r   getArtifactLoggerr  RuntimeErrorr$   r8   r=   r?   rF   rH   rJ   rL   rN   rP   rR   rV   r\   rj   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm   r   r   r   r   r   r   r   r   r   r   r   r   r   StopIterationLookupError
IndexErrorGeneratorExitrG  AttributeErrorNotImplementedError	TypeErrorr   r   r   r   _subclassesfake_tensorDataDependentOutputExceptionDynamicOutputShapeExceptionUnsupportedOperatorExceptionUnsupportedFakeTensorException$UnsupportedMutationAliasingException!exceptions_allowed_to_be_fallbackr  r  r'  r-  objectr1  r   r6  rJ  rP  rS  rE  rR  rf  ri  r   rr  rx  r{  r}  r:   r!   r   <module>r     s   " " " " " "2   				                       J J J J J J J J J J J J 9 9 9 9 9 9 9 9 9 9 9 9     1 1 1 1 1 1              'LLL''''''000000;;;;;;&&&&&&    g!!>33HnMM N N N N N< N N N	 	 	 	 	3 	 	 		 	 	 	 	!5 	 	 	         *      	 	 	 	 	 	 	 		 	 	 	 	/ 	 	 		 	 	 	 	 	 	 		 	 	 	 	_ 	 	 		 	 	 	 	$ 	 	 		 	 	 	 	, 	 	 	
 
 
 
 
) 
 
 
	
 	
 	
 	
 	
( 	
 	
 	
' ' ' ' '+ ' ' '"
E 
E 
E 
E 
E, 
E 
E 
E* * * * *& * * *8	 	 	 	 	; 	 	 		 	 	 	 	) 	 	 		 	 	 	 	 	 	 		 	 	 	 	[ 	 	 		 	 	 	 	[ 	 	 	
	 	 	 	 	{ 	 	 	    /   8 8 8 8 8D 8 8 8       0	 	 	 	 	!5 	 	 		 	 	 	 	[ 	 	 	
G G G G G* G G G
	 	 	 	 	2 	 	 	
 
 
 
 
#7 
 
 
	 	 	 	 	Y 	 	 		 	 	 	 	i 	 	 		 	 	 	 	' 	 	 	U U U U U, U U U     1   	 	 	 	 	+ 	 	 	
	 	 	 	 	, 	 	 	
	 	 	 	 	* 	 	 	
	 	 	 	 	- 	 	 		 	 	 	 	. 	 	 	
	 	 	 	 	, 	 	 	
	 	 	 	 	"3 	 	 		 	 	 	 	) 	 	 	 ,$"(*&4 
 , , , , !%'+     (. . . .< 
!>	!=	!>	!@	!F% !# # # #L   , 1   2   0 688 ! ! ! ! ! !L       ,- ,- ,- ,- ,-^	 	 	 	) ) ) )
 8<C C C C CB          J &*'+	    6   
 
 
 
    &*'+		8 	8 	8 	8 	8 	8 	8r!   