o
    h                     @  s   d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ g 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dS )zONNX exporter exceptions.    )annotationsN)Optional)_C)
_constants)diagnostics)OnnxExporterErrorOnnxExporterWarningCheckerErrorUnsupportedOperatorErrorSymbolicValueErrorc                   @     e Zd ZdZdS )r   z1Base class for all warnings in the ONNX exporter.N__name__
__module____qualname____doc__ r   r   G/var/www/html/ai/venv/lib/python3.10/site-packages/torch/onnx/errors.pyr          r   c                   @  r   )r   z#Errors raised by the ONNX exporter.Nr   r   r   r   r   r      r   r   c                   @  r   )r	   z2Raised when ONNX checker detects an invalid model.Nr   r   r   r   r   r	       r   r	   c                      s"   e Zd ZdZd
 fdd	Z  ZS )r
   z7Raised when an operator is unsupported by the exporter.namestrversionintsupported_versionOptional[int]c                   s   |d urt jj}||||}t |t jj| n-|dr4t jj}|||t	j
}t |t jj| nt jj}||}t |t jj| t | d S )N)zaten::zprim::zquantized::)r   rules)operator_supported_in_newer_opset_versionformat_messagediagnoselevelsERROR
startswith"missing_standard_symbolic_functionr   PYTORCH_GITHUB_ISSUES_URL missing_custom_symbolic_functionsuper__init__)selfr   r   r   diagnostic_rulemsg	__class__r   r   r&   )   s   

z!UnsupportedOperatorError.__init__)r   r   r   r   r   r   r   r   r   r   r&   __classcell__r   r   r*   r   r
   &       r
   c                      s"   e Zd ZdZd fddZ  ZS )	r   z+Errors around TorchScript values and nodes.r)   r   value_C.Valuec              
     s   | d| d|   d|   d}|  }|r$|d| d7 }z6|d7 }|tdd	d
d t|  D p>d d	 d d	dd t| 	 D pTd d7 }W n t
yg   |d7 }Y nw t | d S )Nz  [Caused by the value 'z	' (type 'z;') in the TorchScript graph. The containing node has kind 'z'.] z
    (node defined in )z

zInputs:

c                 s  0    | ]\}}d | d| d|   dV  qdS z    #z: z	  (type 'z')Ntype).0iinput_r   r   r   	<genexpr>R   
    
z.SymbolicValueError.__init__.<locals>.<genexpr>z	    Emptyz	Outputs:
c                 s  r3   r4   r5   )r7   r8   outputr   r   r   r:   [   r;   z    zv Failed to obtain its input and output for debugging. Please refer to the TorchScript graph for debugging information.)r6   nodekindsourceRangetextwrapindentjoin	enumerateinputsoutputsAttributeErrorr%   r&   )r'   r)   r/   messagecode_locationr*   r   r   r&   A   sB   

	

zSymbolicValueError.__init__)r)   r   r/   r0   r,   r   r   r*   r   r   >   r.   r   )r   
__future__r   r@   typingr   torchr   
torch.onnxr   torch.onnx._internalr   __all__UserWarningr   RuntimeErrorr   r	   r
   r   r   r   r   r   <module>   s    	