a
    d5	                     @   s   d dl Z d dlZd dlZd dlmZ e jddkrFe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_cacheZTORCHINDUCTOR_WRITE_MISSING_OPS1c                 C   sJ   t t  dd"}|t| d  W d    n1 s<0    Y  d S )Nz/missing_ops.txta
)opentempfile
gettempdirwritestr)targetfd r   \/var/www/html/stable-diffusion-webui/venv/lib/python3.9/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  }|r2|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                       s   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"      s   r"   c                       s   e Zd Z fddZ  ZS )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+   $   s   r+   c                       s   e Zd Z fddZ  ZS )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   r-   4   s   r-   c                       s   e Zd Z fddZ  ZS )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: ) r2   r#   r$   r   cppcxx)r&   r2   r'   r   r   r$   <   s    zInvalidCxxCompiler.__init__r)   r   r   r'   r   r0   ;   s   r0   c                       s   e Zd Z fddZ  ZS )CppCompileErrorc                    s0   t  td jd||dd d S )Nz
                    C++ compile error

                    Command:
                    {cmd}

                    Output:
                    {output}
                 zutf-8)cmdoutput)r#   r$   r   r,   stripformatr   decode)r&   r8   r9   r'   r   r   r$   E   s    zCppCompileError.__init__r)   r   r   r'   r   r6   D   s   r6   )osr   r   	functoolsr   environgetr   RuntimeErrorr   r"   r+   r-   r0   r6   r   r   r   r   <module>   s   	