U
    9%ex	                     @   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   s6   t t  dd}|t| d  W 5 Q R X d S )Nz/missing_ops.txta
)opentempfile
gettempdirwritestr)targetfd r   R/var/www/html/Darija-Ai-API/env/lib/python3.8/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                    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&   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   	