o
    hx	                     @   s   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d Zndd ZG dd	 d	eZ	G d
d de	Z
G dd de	ZG dd de	ZG dd deZG dd deZdS )    N)	lru_cacheTORCHINDUCTOR_WRITE_MISSING_OPS1c                 C   sL   t t  dd}|t| d  W d    d S 1 sw   Y  d S )Nz/missing_ops.txta
)opentempfile
gettempdirwritestr)targetfd r   I/var/www/html/ai/venv/lib/python3.10/site-packages/torch/_inductor/exc.py_record_missing_op   s   "r   c                 C   s   d S )Nr   )r   r   r   r   r      s   c                   @   s   e Zd Zedd ZdS )OperatorIssuec                 C   sD   d|  gdd t |D  }|r|d|  td|dS )Nztarget: c                 S   s    g | ]\}}d | d| qS )zargs[z]: r   ).0iargr   r   r   
<listcomp>   s    z.OperatorIssue.operator_str.<locals>.<listcomp>zkwargs: r   z  )	enumerateappendtextwrapindentjoin)r   argskwargslinesr   r   r   operator_str   s   zOperatorIssue.operator_strN)__name__
__module____qualname__staticmethodr   r   r   r   r   r      s    r   c                          e Zd Z fddZ  ZS )MissingOperatorWithoutDecompc                    s(   t | t d| |||  d S )Nzmissing lowering
)r   super__init__r   selfr   r   r   	__class__r   r   r&      s    z%MissingOperatorWithoutDecomp.__init__r   r    r!   r&   __classcell__r   r   r)   r   r$          r$   c                       r#   )MissingOperatorWithDecompc                    s:   t | t d| ||| td| d  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.decompositions
                )r   r%   r&   r   r   dedentr'   r)   r   r   r&   %   s   z"MissingOperatorWithDecomp.__init__r+   r   r   r)   r   r.   $   r-   r.   c                       r#   )LoweringExceptionc                    s0   t  t|j d| d| |||  d S )Nz: r   )r%   r&   typer   r   )r(   excr   r   r   r)   r   r   r&   5   s   "zLoweringException.__init__r+   r   r   r)   r   r0   4   r-   r0   c                       r#   )InvalidCxxCompilerc                    s.   ddl m} t d|j d|jj  d S )N   )configz!No working C++ compiler found in z
.cpp.cxx: ) r5   r%   r&   r   cppcxx)r(   r5   r)   r   r   r&   <   s   zInvalidCxxCompiler.__init__r+   r   r   r)   r   r3   ;   r-   r3   c                       r#   )CppCompileErrorc                    s>   t |tr
|d}t td jd	||d d S )Nzutf-8z
                    C++ compile error

                    Command:
                    {cmd}

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

isinstancebytesdecoder%   r&   r   r/   stripformatr   )r(   r;   r<   r)   r   r   r&   E   s   

zCppCompileError.__init__r+   r   r   r)   r   r9   D   r-   r9   )osr   r   	functoolsr   environgetr   RuntimeErrorr   r$   r.   r0   r3   r9   r   r   r   r   <module>   s    	