
    i                        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e	      Z
 G d	 d
e      Z G d de      Z G d de      Zy)zONNX exporter exceptions.    )annotations)OnnxExporterWarningSymbolicValueErrorUnsupportedOperatorErrorN)TYPE_CHECKING)_Cc                      e Zd ZdZy)r   zWarnings in the ONNX exporter.N__name__
__module____qualname____doc__     K/var/www/html/engine/venv/lib/python3.12/site-packages/torch/onnx/errors.pyr   r      s    (r   r   c                      e Zd ZdZy)OnnxExporterErrorzSErrors raised by the ONNX exporter. This is the base class for all exporter errors.Nr
   r   r   r   r   r      s    ]r   r   c                  $     e Zd ZdZd fdZ xZS )r   z7Raised when an operator is unsupported by the exporter.c                    |d| d| d| d}n!|j                  d      r
d| d| d}nd| d}t        | 	  |       y )	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 supportedz>ONNX export failed on an operator with unrecognized namespace zo. If you are trying to export a custom operator, make sure you registered it with the right domain and version.)
startswithsuper__init__)selfnameversionsupported_versionmsg	__class__s        r   r   z!UnsupportedOperatorError.__init__!   s    (*4&0H	 RT$%%FH 
 __@A*4&0H	 R# #  QQUPV W0 0  	r   )r   strr   intr   z
int | NonereturnNoner   r   r   r   r   __classcell__r   s   @r   r   r      s    A r   r   c                  $     e Zd ZdZd fdZ xZS )r   z+Errors around TorchScript values and nodes.c                `   | d| d|j                          d|j                         j                          d}|j                         j                         }|r	|d| dz  }	 |dz  }|t	        j
                  dd	j                  d
 t        |j                         j                               D              xs dz   d	z   dz   d	j                  d t        |j                         j                               D              xs dz   d      z  }t        | 1  |       y # t        $ r |dz  }Y  w xY w)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              3  V   K   | ]!  \  }}d | d| d|j                          d # ywz    #z: z	  (type 'z')Ntype).0iinput_s      r   	<genexpr>z.SymbolicValueError.__init__.<locals>.<genexpr>M   7      " )6 $A3b	&++-K"   ')z	    Emptyz	Outputs:
c              3  V   K   | ]!  \  }}d | d| d|j                          d # ywr+   r,   )r.   r/   outputs      r   r1   z.SymbolicValueError.__init__.<locals>.<genexpr>V   r2   r3   z    zv Failed to obtain its input and output for debugging. Please refer to the TorchScript graph for debugging information.)r-   nodekindsourceRangetextwrapindentjoin	enumerateinputsoutputsAttributeErrorr   r   )r   r   valuemessagecode_locationr   s        r   r   zSymbolicValueError.__init__<   s\   e+E7)EJJL> J@@E

@Q@Q@S?TTXZ 	
 

0020qAAG	vGx		 "-6uzz|7J7J7L-M"  ' '  #	# 		 "-6uzz|7K7K7M-N"  ' '$ ) G8 	!  	SG	s   $B(D D-,D-)r   r   r@   z_C.Valuer!   r"   r#   r%   s   @r   r   r   7   s    5)" )"r   r   )r   
__future__r   __all__r9   typingr   torchr   UserWarningr   RuntimeErrorr   r   r   r   r   r   <module>rI      sV     "    )+ )^ ^0 6."* ."r   