
    ɯwg                    Z   d dl mZ d dlZd dlZd dlZd dlmZ ej                  j                  d      dk(  r ed      d        Z	nd Z	 G d d	e
      Z G d
 de      Z G d de      Z G d de      Z G d de
      Z G d de
      Z G d de
      Z G d de
      Z G d de      Zy)    )annotationsN)	lru_cacheTORCHINDUCTOR_WRITE_MISSING_OPS1c                    t        t        j                          dd      5 }|j                  t	        |       dz          d d d        y # 1 sw Y   y xY w)Nz/missing_ops.txta
)opentempfile
gettempdirwritestr)targetfds     X/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/torch/_inductor/exc.py_record_missing_opr      sJ    X((*++;<cB 	)bHHS[4'(	) 	) 	)s   A		Ac                     y )N )r   s    r   r   r      s        c                      e Zd Zed        Zy)OperatorIssuec           	         d|  gt        |      D cg c]  \  }}d| d|  c}}z   }|r|j                  d|        t        j                  dj	                  |      d      S c c}}w )Nztarget: zargs[z]: zkwargs: r	   z  )	enumerateappendtextwrapindentjoin)r   argskwargsiargliness         r   operator_strzOperatorIssue.operator_str   su    F8$%.7o)
$*AseA3c#)
 
 LL8F8,-tyy/66)
s   A'N)__name__
__module____qualname__staticmethodr#   r   r   r   r   r      s    7 7r   r   c                        e Zd Zd fdZ xZS )MissingOperatorWithoutDecompc                b    t        |       t        | 	  d| j                  |||              y )Nzmissing lowering
)r   super__init__r#   selfr   r   r   	__class__s       r   r,   z%MissingOperatorWithoutDecomp.__init__#   s0    6"-d.?.?f.U-VWXr   returnNoner$   r%   r&   r,   __classcell__r/   s   @r   r)   r)   "   s    Y Yr   r)   c                        e Zd Zd fdZ xZS )MissingOperatorWithDecompc                    t        |       t        | 	  d| j                  |||       t	        j
                  d| d      z          y )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   r+   r,   r#   r   dedentr-   s       r   r,   z"MissingOperatorWithDecomp.__init__)   sX    6"%d&7&7f&M%NOoo88>x @
	
r   r0   r3   r5   s   @r   r7   r7   (   s    
 
r   r7   c                        e Zd Zd fdZ xZS )LoweringExceptionc                |    t         |   t        |      j                   d| d| j	                  |||              y )Nz: r	   )r+   r,   typer$   r#   )r.   excr   r   r   r/   s        r   r,   zLoweringException.__init__9   s?    Cy!!""SED,=,=fdF,S+TU	
r   )r>   	Exceptionr1   r2   r3   r5   s   @r   r;   r;   8   s    
 
r   r;   c                      e Zd Zy)SubgraphLoweringExceptionNr$   r%   r&   r   r   r   rA   rA   ?       r   rA   c                        e Zd Zd fdZ xZS )InvalidCxxCompilerc                x    ddl m} t        |   d|j                   d|j
                  j                          y )N   )configz!No working C++ compiler found in z
.cpp.cxx: ) rH   r+   r,   r$   cppcxx)r.   rH   r/   s     r   r,   zInvalidCxxCompiler.__init__D   s1    //@
6::>>JZ[	
r   r0   r3   r5   s   @r   rE   rE   C   s    
 
r   rE   c                        e Zd Zd fdZ xZS )CppWrapperCodeGenErrorc                *    t         |   d|        y )NzC++ wrapper codegen error: )r+   r,   )r.   msgr/   s     r   r,   zCppWrapperCodeGenError.__init__M   s    6se<=r   )rO   r   r1   r2   r3   r5   s   @r   rM   rM   L   s    > >r   rM   c                        e Zd Zd fdZ xZS )CppCompileErrorc                    t        |t              r|j                  d      }t        |   t        j                  d      j                         j                  dj                  |      |             y )Nzutf-8z
                    C++ compile error

                    Command:
                    {cmd}

                    Output:
                    {output}
                 )cmdoutput)

isinstancebytesdecoder+   r,   r   r9   stripformatr   )r.   rT   rU   r/   s      r   r,   zCppCompileError.__init__R   sX    fe$]]7+FOO
 UWVfV5	
r   )rT   z	list[str]rU   r   r1   r2   r3   r5   s   @r   rQ   rQ   Q   s    
 
r   rQ   c                      e Zd Zy)CUDACompileErrorNrB   r   r   r   r\   r\   g   rC   r   r\   )
__future__r   osr   r   	functoolsr   environgetr   RuntimeErrorr   r)   r7   r;   rA   rE   rM   rQ   r\   r   r   r   <module>rc      s    " 	    ::>>34;t_) )7L 7Y= Y
 
 
 
	 	
 
>\ >

l 
,	 	r   