
    3j                       S SK Jr  S SKrS SKrS SKrS SKJr  S SKJrJ	r	  S SK
JrJr  \	(       a
  S SKrS SKJr  \R                   R#                  S5      S:X  a  \" S5      S#S	 j5       rOS#S
 jr " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S \5      r " S! S"\5      rg)$    )annotationsN)	lru_cache)AnyTYPE_CHECKING)BackendCompilerFailedShortenTraceback)_CudaDevicePropertiesTORCHINDUCTOR_WRITE_MISSING_OPS1c                    [        [        R                  " 5        S3S5       nUR                  [	        U 5      S-   5        S S S 5        g ! , (       d  f       g = f)Nz/missing_ops.txta
)opentempfile
gettempdirwritestr)targetfds     M/home/wildlama/miniconda3/lib/python3.13/site-packages/torch/_inductor/exc.py_record_missing_opr      sB    X((*++;<cBbHHS[4'( CBBs   A


Ac                    g N )r   s    r   r   r      s        c                  (    \ rS rSr\SS j5       rSrg)OperatorIssue   c           	         SU  3/[        U5       VVs/ s H  u  p4SU SU 3PM     snn-   nU(       a  UR                  SU 35        [        R                  " SR	                  U5      S5      $ s  snnf )Nztarget: zargs[z]: zkwargs: r   z  )	enumerateappendtextwrapindentjoin)r   argskwargsiargliness         r   operator_strOperatorIssue.operator_str   sw    F8$%.7o)
.=FAeA3c#o)
 
 LL8F8,-tyy/66)
s   A/r   N)r   r   r%   	list[Any]r&   dict[str, Any]returnr   )__name__
__module____qualname____firstlineno__staticmethodr*   __static_attributes__r   r   r   r   r      s    7 7r   r   c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )MissingOperatorWithoutDecomp)   c                `   > [        U5        [        TU ]	  SU R                  XU5       35        g )Nzmissing lowering
)r   super__init__r*   selfr   r%   r&   	__class__s       r   r:   %MissingOperatorWithoutDecomp.__init__*   s.    6"-d.?.?f.U-VWXr   r   r   r   r%   r,   r&   r-   r.   Noner/   r0   r1   r2   r:   r4   __classcell__r=   s   @r   r6   r6   )   s    Y Yr   r6   c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )MissingOperatorWithDecomp/   c                   > [        U5        [        TU ]	  SU R                  XU5       3[        R
                  " SU S35      -   5        g )Nzmissing decomposition
z9

                There is a decomposition available for z in
                torch._decomp.get_decompositions().  Please add this operator to the
                `decompositions` list in torch._inductor.decomposition
                )r   r9   r:   r*   r"   dedentr;   s       r   r:   "MissingOperatorWithDecomp.__init__0   sV    6"%d&7&7f&M%NOoo88>x @
	
r   r   r?   rA   rC   s   @r   rE   rE   /   s    
 
r   rE   c                  H   ^  \ rS rSr S           SU 4S jjjrSrU =r$ )LoweringException?   c           	        > [        U5      R                   SU SU R                  X#U5       3nU(       a	  Xf SU 3-  n[        TU ]  U5        g )N: r   z
Found from : 
 )typer/   r*   r9   r:   )r<   excr   r%   r&   stack_tracemsgr=   s          r   r:   LoweringException.__init__@   sX     c##$Bse2d.?.?f.U-VWU,[M::Cr   r   r   )rP   	Exceptionr   r   r%   r,   r&   r-   rQ   z
str | Noner.   r@   rA   rC   s   @r   rK   rK   ?   sL     #'  	
    
 r   rK   c                      \ rS rSrSrg)SubgraphLoweringExceptionN   r   Nr/   r0   r1   r2   r4   r   r   r   rV   rV   N       r   rV   c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )InvalidCxxCompilerR   c                x   > SSK Jn  [        TU ]  SUR                   SUR
                  R                   35        g )N   )configz!No working C++ compiler found in z
.cpp.cxx: ) r_   r9   r:   r/   cppcxx)r<   r_   r=   s     r   r:   InvalidCxxCompiler.__init__S   s1    //@
6::>>JZ[	
r   r   )r.   r@   rA   rC   s   @r   r[   r[   R   s    
 
r   r[   c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )CppWrapperCodegenError[   c                *   > [         TU ]  SU 35        g )NzC++ wrapper codegen error: r9   r:   )r<   rR   r=   s     r   r:   CppWrapperCodegenError.__init__\   s    6se<=r   r   )rR   r   r.   r@   rA   rC   s   @r   re   re   [   s    > >r   re   c                  6   ^  \ rS rSrSU 4S jjrSS jrSrU =r$ )CppCompileError`   c                  > [        U[        5      (       a  UR                  S5      nXl        X l        [
        TU ]  [        R                  " S5      R                  5       R                  SR                  U5      US95        g )Nzutf-8z
                    C++ compile error

                    Command:
                    {cmd}

                    Output:
                    {output}
                 cmdoutput)
isinstancebytesdecoderp   rq   r9   r:   r"   rH   stripformatr$   )r<   rp   rq   r=   s      r   r:   CppCompileError.__init__a   se    fe$$]]7+FOO
 UWVfV5	
r   c                J    U R                   U R                  U R                  44$ r   )r=   rp   rq   )r<   s    r   
__reduce__CppCompileError.__reduce__x   s    4;; 788r   ro   )rp   z	list[str]rq   r   r.   r@   )r.   z"tuple[type, tuple[list[str], str]])r/   r0   r1   r2   r:   ry   r4   rB   rC   s   @r   rk   rk   `   s    
.9 9r   rk   c                      \ rS rSrSrg)CUDACompileError|   r   NrX   r   r   r   r|   r|   |   rY   r   r|   c                  ,   ^  \ rS rSrSU 4S jjrSrU =r$ )TritonMissing   c                "   > [         TU ]  SUS9  g )NzCannot find a working triton installation. Either the package is not installed or it is too old. More information on installing Triton can be found at: https://github.com/triton-lang/tritonfirst_useful_framerh   )r<   r   r=   s     r   r:   TritonMissing.__init__   s     k  2	 	 	
r   r   )r   types.FrameType | Noner.   r@   rA   rC   s   @r   r   r      s    
 
r   r   c                  8   ^  \ rS rSr      SU 4S jjrSrU =r$ )GPUTooOldForTriton   c                p   > [         TU ]  SUR                   SUR                   SUR                   3US9  g )NzFound z which is too old to be supported by the triton GPU compiler, which is used as the backend. Triton only supports devices of CUDA Capability >= 7.0, but your device is of CUDA capability .r   )r9   r:   namemajorminor)r<   device_propsr   r=   s      r   r:   GPUTooOldForTriton.__init__   sN     	\&&' (55A5G5G4H,J\J\I]_  2	 	 	
r   r   )r   r	   r   r   r.   r@   rA   rC   s   @r   r   r      s+    
 ,
 3	

 

 
r   r   c                  .    \ rS rSrSr      SS jrSrg)InductorError   inductorc                l    Xl         [        R                  " U [        U5      R                   SU 3US9  g )NrN   r   )inner_exceptionr   r:   rO   r/   )r<   r   r   s      r   r:   InductorError.__init__   s9    
  /!!O$--.b0AB1	
r   )r   N)r   rT   r   r   r.   r@   )r/   r0   r1   r2   backend_namer:   r4   r   r   r   r   r      s(    L

"

 3

 
	

r   r   )r   r   r.   r@   ) 
__future__r   osr   r"   	functoolsr   typingr   r   torch._dynamo.excr   r   types
torch.cudar	   environgetr   RuntimeErrorr   r6   rE   rK   rV   r[   re   rk   r|   r   r   r   r   r   r   <module>r      s    " 	    % E 0::>>34;t_) )7L 7Y= Y
 
  	 	
 
>\ >
9l 98	 	
$ 

) 

) 
r   