
    קg                       d dl mZ d dlZd dlZd dlZd dlmZ e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dS )    )annotationsN)	lru_cacheTORCHINDUCTOR_WRITE_MISSING_OPS1c                    t          t          j                     dd          5 }|                    t	          |           dz              d d d            d S # 1 swxY w Y   d S )Nz/missing_ops.txta
)opentempfile
gettempdirwritestr)targetfds     O/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/_inductor/exc.py_record_missing_opr      s    X(**<<<cBB 	)bHHS[[4'(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   &AAAc                    d S )N )r   s    r   r   r      s        c                  $    e Zd Zed             ZdS )OperatorIssuec                    d|  gd t          |          D             z   }|r|                    d|            t          j        d                    |          d          S )Nztarget: c                $    g | ]\  }}d | d| S )zargs[z]: r   ).0iargs      r   
<listcomp>z.OperatorIssue.operator_str.<locals>.<listcomp>   s:     )
 )
 )
$*AsA#)
 )
 )
r   zkwargs: r	   z  )	enumerateappendtextwrapindentjoin)r   argskwargsliness       r   operator_strzOperatorIssue.operator_str   s|    $F$$% )
 )
.7oo)
 )
 )
 
  	.LL,F,,---tyy//666r   N)__name__
__module____qualname__staticmethodr&   r   r   r   r   r      s-        7 7 \7 7 7r   r   c                        e Zd Zd fdZ xZS )MissingOperatorWithoutDecompreturnNonec                    t          |           t                                          d|                     |||                      d S )Nzmissing lowering
)r   super__init__r&   selfr   r#   r$   	__class__s       r   r1   z%MissingOperatorWithoutDecomp.__init__#   sJ    6"""Wd.?.?f.U.UWWXXXXXr   r-   r.   r'   r(   r)   r1   __classcell__r4   s   @r   r,   r,   "   sG        Y Y Y Y Y Y Y Y Y Yr   r,   c                        e Zd Zd fdZ xZS )MissingOperatorWithDecompr-   r.   c                    t          |           t                                          d|                     |||           t	          j        d| d          z              d S )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   r0   r1   r&   r    dedentr2   s       r   r1   z"MissingOperatorWithDecomp.__init__)   s    6"""Od&7&7f&M&MOOo8>   
	
 
	
 
	
 
	
 
	
r   r5   r6   r8   s   @r   r:   r:   (   s=        
 
 
 
 
 
 
 
 
 
r   r:   c                        e Zd Zd fdZ xZS )LoweringExceptionexc	Exceptionr-   r.   c                    t                                          t          |          j         d| d|                     |||                      d S )Nz: r	   )r0   r1   typer'   r&   )r3   r?   r   r#   r$   r4   s        r   r1   zLoweringException.__init__9   s]    Cyy!UUSUUD,=,=fdF,S,SUU	
 	
 	
 	
 	
r   )r?   r@   r-   r.   r6   r8   s   @r   r>   r>   8   s=        
 
 
 
 
 
 
 
 
 
r   r>   c                      e Zd ZdS )SubgraphLoweringExceptionNr'   r(   r)   r   r   r   rD   rD   ?           Dr   rD   c                        e Zd Zd fdZ xZS )InvalidCxxCompilerr-   r.   c                    ddl m} t                                          d|j         d|j        j                    d S )N   )configz!No working C++ compiler found in z
.cpp.cxx: ) rK   r0   r1   r'   cppcxx)r3   rK   r4   s     r   r1   zInvalidCxxCompiler.__init__D   sT    [[[6:>[[	
 	
 	
 	
 	
r   r5   r6   r8   s   @r   rH   rH   C   s=        
 
 
 
 
 
 
 
 
 
r   rH   c                        e Zd Zd fdZ xZS )CppWrapperCodeGenErrormsgr   r-   r.   c                P    t                                          d|            d S )NzC++ wrapper codegen error: )r0   r1   )r3   rQ   r4   s     r   r1   zCppWrapperCodeGenError.__init__M   s*    <s<<=====r   )rQ   r   r-   r.   r6   r8   s   @r   rP   rP   L   s=        > > > > > > > > > >r   rP   c                        e Zd Zd fdZ xZS )	CppCompileErrorcmd	list[str]outputr   r-   r.   c                6   t          |t                    r|                    d          }t                                          t          j        d                                                              d	                    |          |                     d S )Nzutf-8z
                    C++ compile error

                    Command:
                    {cmd}

                    Output:
                    {output}
                 )rU   rW   )

isinstancebytesdecoder0   r1   r    r<   stripformatr"   )r3   rU   rW   r4   s      r   r1   zCppCompileError.__init__R   s    fe$$ 	,]]7++FO
 
 UWWVfV55	
 	
 	
 	
 	
r   )rU   rV   rW   r   r-   r.   r6   r8   s   @r   rT   rT   Q   s=        
 
 
 
 
 
 
 
 
 
r   rT   c                      e Zd ZdS )CUDACompileErrorNrE   r   r   r   r`   r`   g   rF   r   r`   )
__future__r   osr   r    	functoolsr   environgetr   RuntimeErrorr   r,   r:   r>   rD   rH   rP   rT   r`   r   r   r   <module>rg      s!   " " " " " " 				         :>>344;;Yt__) ) _) )  7 7 7 7 7L 7 7 7Y Y Y Y Y= Y Y Y
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
	 	 	 	 	 	 	 	
 
 
 
 
 
 
 
> > > > >\ > > >

 
 
 
 
l 
 
 
,	 	 	 	 	 	 	 	 	 	r   