o
    I&i
                     @  s   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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G dd de
ZG dd deZdS )    )annotationsN)	lru_cacheZ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   >C:\wamp64\www\opt\env\Lib\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                         e Zd Zd fddZ  ZS )LoweringExceptionexc	Exceptionc                   s0   t  t|j d| d| |||  d S )Nz: r   )r%   r&   typer   r   )r(   r2   r   r   r   r)   r   r   r&   7   s   "zLoweringException.__init__)r2   r3   r+   r   r   r)   r   r1   6       r1   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: ) r8   r%   r&   r   cppZcxx)r(   r8   r)   r   r   r&   >   s   zInvalidCxxCompiler.__init__r+   r   r   r)   r   r6   =   r-   r6   c                      r0   )CppWrapperCodeGenErrormsgr   c                   s   t  d|  d S )NzC++ wrapper codegen error: )r%   r&   )r(   r<   r)   r   r   r&   G   s   zCppWrapperCodeGenError.__init__)r<   r   r+   r   r   r)   r   r;   F   r5   r;   c                      s   e Zd Zd fddZ  ZS )CppCompileErrorcmd	list[str]outputr   c                   s>   t |tr
|d}t td jd	||d d S )Nzutf-8z
                    C++ compile error

                    Command:
                    {cmd}

                    Output:
                    {output}
                 )r>   r@   )

isinstancebytesdecoder%   r&   r   r/   stripformatr   )r(   r>   r@   r)   r   r   r&   L   s   

zCppCompileError.__init__)r>   r?   r@   r   r+   r   r   r)   r   r=   K   r5   r=   c                   @  s   e Zd ZdS )CUDACompileErrorN)r   r    r!   r   r   r   r   rG   a   s    rG   )
__future__r   osr   r   	functoolsr   environgetr   RuntimeErrorr   r$   r.   r1   r6   r;   r=   rG   r   r   r   r   <module>   s"    	