a
    h                     @  s   d Z ddlmZ g dZddlZddlmZ er<ddlm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.    )annotations)OnnxExporterWarningSymbolicValueErrorUnsupportedOperatorErrorN)TYPE_CHECKING)_Cc                   @  s   e Zd ZdZdS )r   zWarnings in the ONNX exporter.N__name__
__module____qualname____doc__ r   r   ?/var/www/auris/lib/python3.9/site-packages/torch/onnx/errors.pyr      s   r   c                   @  s   e Zd ZdZdS )OnnxExporterErrorzSErrors raised by the ONNX exporter. This is the base class for all exporter errors.Nr   r   r   r   r   r      s   r   c                      s*   e Zd ZdZdddd fddZ  ZS )r   z7Raised when an operator is unsupported by the exporter.strintz
int | None)nameversionsupported_versionc                   sT   |d ur"d| d| d| d}n"| dr@d| d| d}nd}t | d S )NzExporting the operator 'z' to ONNX opset version zB is not supported. Support for this operator was added in version z!, try exporting with this version)zaten::zprim::zquantized::z is not supportedzONNX export failed on an operator with unrecognized namespace {op_name}. If you are trying to export a custom operator, make sure you registered it with the right domain and version.)
startswithsuper__init__)selfr   r   r   msg	__class__r   r   r   !   s    
z!UnsupportedOperatorError.__init__r	   r
   r   r   r   __classcell__r   r   r   r   r      s   r   c                      s(   e Zd ZdZddd fddZ  ZS )r   z+Errors around TorchScript values and nodes.r   z_C.Value)r   valuec              
     s   | d| d|   d|   d}|  }|rH|d| d7 }zl|d7 }|tdd	d
d t|  D p|d d	 d d	dd t| 	 D pd d7 }W n t
y   |d7 }Y n0 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  s.   | ]&\}}d | d| d|   dV  qdS z    #z: z	  (type 'z')Ntype).0iZinput_r   r   r   	<genexpr>M   s   z.SymbolicValueError.__init__.<locals>.<genexpr>z	    Emptyz	Outputs:
c                 s  s.   | ]&\}}d | d| d|   dV  qdS r!   r"   )r$   r%   outputr   r   r   r&   V   s   z    zv Failed to obtain its input and output for debugging. Please refer to the TorchScript graph for debugging information.)r#   nodekindZsourceRangetextwrapindentjoin	enumerateinputsoutputsAttributeErrorr   r   )r   r   r   messageZcode_locationr   r   r   r   <   s@    

	


zSymbolicValueError.__init__r   r   r   r   r   r   7   s   r   )r   
__future__r   __all__r*   typingr   Ztorchr   UserWarningr   RuntimeErrorr   r   r   r   r   r   r   <module>   s   