
    '}h                        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
e      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.    )annotationsN)Optional)_C)
_constants)diagnostics)OnnxExporterErrorOnnxExporterWarningCheckerErrorSymbolicValueErrorUnsupportedOperatorErrorc                      e Zd ZdZy)r	   z1Base class for all warnings in the ONNX exporter.N__name__
__module____qualname____doc__     P/var/www/html/test/engine/venv/lib/python3.12/site-packages/torch/onnx/errors.pyr	   r	      s    ;r   r	   c                      e Zd ZdZy)r   z#Errors raised by the ONNX exporter.Nr   r   r   r   r   r      s    -r   r   c                      e Zd ZdZy)r
   z2Raised when ONNX checker detects an invalid model.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                   |]t         j                  j                  }|j                  |||      }t        j                  |t         j
                  j                  |       n|j                  d      rkt         j                  j                  }|j                  ||t        j                        }t        j                  |t         j
                  j                  |       nZt         j                  j                  }|j                  |      }t        j                  |t         j
                  j                  |       t        | 5  |       y )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__)selfnameversionsupported_versiondiagnostic_rulemsg	__class__s         r   r%   z!UnsupportedOperatorError.__init__)   s    (!!KK  "00w@QRC  +2D2D2J2JCPBC"-"3"3"V"V%44':#G#G $$_k6H6H6N6NPST"-"3"3"T"T%44T:$$_k6H6H6N6NPSTr   )r'   strr(   intr)   zOptional[int]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>R   7      " )6 $A3b	&++-K"   ')z	    Emptyz	Outputs:
c              3  V   K   | ]!  \  }}d | d| d|j                          d # ywr7   r8   )r:   r;   outputs      r   r=   z.SymbolicValueError.__init__.<locals>.<genexpr>[   r>   r?   z    zv Failed to obtain its input and output for debugging. Please refer to the TorchScript graph for debugging information.)r9   nodekindsourceRangetextwrapindentjoin	enumerateinputsoutputsAttributeErrorr$   r%   )r&   r+   valuemessagecode_locationr,   s        r   r%   zSymbolicValueError.__init__A   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-   rL   z_C.Valuer/   r1   s   @r   r   r   >   s    5)" )"r   r   )r   
__future__r   rE   typingr   torchr   
torch.onnxr   torch.onnx._internalr   __all__UserWarningr	   RuntimeErrorr   r
   r   r   r   r   r   <module>rW      s`     "    ! ,	+ 		 		$ 	0 0,"* ,"r   