
    Χg                        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dS )zONNX exporter exceptions.    )annotations)OnnxExporterWarningSymbolicValueErrorUnsupportedOperatorErrorN)TYPE_CHECKING)_Cc                      e Zd ZdZdS )r   zWarnings in the ONNX exporter.N__name__
__module____qualname____doc__     M/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/onnx/errors.pyr   r      s        ((((r   r   c                      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   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.namestrversionintsupported_version
int | Nonec                2   ddl m} ddlm} |E|j        j        }|                    |||          }|                    ||j        j	        |           n|
                    d          rJ|j        j        }|                    |||j                  }|                    ||j        j	        |           nB|j        j        }|                    |          }|                    ||j        j	        |           t                                          |           d S )Nr   )
_constants)diagnostics)zaten::zprim::zquantized::)
torch.onnxr   torch.onnx._internalr   rules)operator_supported_in_newer_opset_versionformat_messagediagnoselevelsERROR
startswith"missing_standard_symbolic_functionPYTORCH_GITHUB_ISSUES_URL missing_custom_symbolic_functionsuper__init__)	selfr   r   r   r   r   diagnostic_rulemsg	__class__s	           r   r+   z!UnsupportedOperatorError.__init__!   s5   ))))))444444(!K  "00w@QRRC  +2D2JCPPPPBCC 	U"-"3"V%44':#G  $$_k6H6NPSTTTT"-"3"T%44T::$$_k6H6NPSTTTr   )r   r   r   r   r   r   r   r   r   r   r+   __classcell__r/   s   @r   r   r      sC        A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.r.   r   value_C.Valuec                   | d| d|                                  d|                                                                 d}|                                                                }|r	|d| dz  }	 |dz  }|t	          j        dd	                    d
 t          |                                                                          D                       pdz   d	z   dz   d	                    d t          |                                	                                          D                       pdz   d          z  }n# t          $ r |dz  }Y nw xY 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              3  X   K   | ]%\  }}d | d| d|                                  dV  &dS z    #z: z	  (type 'z')Ntype).0iinput_s      r   	<genexpr>z.SymbolicValueError.__init__.<locals>.<genexpr>O   ^       " " )6 LAKKKK&++--KKK" " " " " "r   z	    Emptyz	Outputs:
c              3  X   K   | ]%\  }}d | d| d|                                  dV  &dS r:   r;   )r=   r>   outputs      r   r@   z.SymbolicValueError.__init__.<locals>.<genexpr>X   rA   r   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.   r4   messagecode_locationr/   s        r   r+   zSymbolicValueError.__init__>   s    Z ZE Z ZEJJLL Z Z@E

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

0022 	BAAAAAG	vGx		 " "-6uzz||7J7J7L7L-M-M" " "   ' '  #	# 		 " "-6uzz||7K7K7M7M-N-N" " "   ' '$ )  GG,  	 	 	SGGG	 	!!!!!s   8C	E EE)r.   r   r4   r5   r0   r2   s   @r   r   r   9   sC        55)" )" )" )" )" )" )" )" )" )"r   r   )r   
__future__r   __all__rG   typingr   torchr   UserWarningr   RuntimeErrorr   r   r   r   r   r   <module>rV      s#     " " " " " "                 ) ) ) ) )+ ) ) )^ ^ ^ ^ ^ ^ ^ ^    0   :." ." ." ." ."* ." ." ." ." ."r   