
    ¯wg                        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__     V/home/mcse/projects/flask/flask-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                V   ddl m} ddlm} |Q|j                  j
                  }|j                  |||      }|j                  ||j                  j                  |       n|j                  d      r[|j                  j                  }|j                  |||j                        }|j                  ||j                  j                  |       nN|j                  j                  }|j                  |      }|j                  ||j                  j                  |       t        | =  |       y )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__)	selfnameversionsupported_versionr   r   diagnostic_rulemsg	__class__s	           r   r%   z!UnsupportedOperatorError.__init__!   s   )4(!!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
int | 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>O   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>X   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__>   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   9   s    5)" )"r   r   )r   
__future__r   __all__rE   typingr   torchr   UserWarningr   RuntimeErrorr   r   r   r   r   r   <module>rU      sV     "    )+ )^ ^0 :."* ."r   