U
    •Ê¹jþ  ã                   @  sª   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 dd	d
ddg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G dd„ deƒZdS )zONNX exporter exceptions.é    )ÚannotationsN)ÚOptional)Ú_C)Ú
_constants)ÚdiagnosticsÚOnnxExporterErrorÚOnnxExporterWarningÚCheckerErrorÚUnsupportedOperatorErrorÚSymbolicValueErrorc                   @  s   e Zd ZdZdS )r   z1Base class for all warnings in the ONNX exporter.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   úP/var/www/html/bwave/python/venv/lib/python3.8/site-packages/torch/onnx/errors.pyr      s   c                   @  s   e Zd ZdZdS )r   z#Errors raised by the ONNX exporter.Nr   r   r   r   r   r      s   c                   @  s   e Zd ZdZdS )r	   z2Raised when ONNX checker detects an invalid model.Nr   r   r   r   r   r	       s   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Optional[int])ÚnameÚversionÚsupported_versionc                   sœ   |d k	r2t jj}| |||¡}t  |t jj|¡ nZ| d¡rht jj}| ||t	j
¡}t  |t jj|¡ n$t jj}| |¡}t  |t jj|¡ tƒ  |¡ d S )N)zaten::zprim::zquantized::)r   ÚrulesZ)operator_supported_in_newer_opset_versionZformat_messageZdiagnoseZlevelsÚERRORÚ
startswithZ"missing_standard_symbolic_functionr   ZPYTORCH_GITHUB_ISSUES_URLZ missing_custom_symbolic_functionÚsuperÚ__init__)Úselfr   r   r   Zdiagnostic_ruleÚmsg©Ú	__class__r   r   r   )   s"    ÿ
  ÿ
z!UnsupportedOperatorError.__init__©r   r   r   r   r   Ú__classcell__r   r   r   r   r
   &   s   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 ƒ¡p¨d d¡7 }W n t
k
rÐ   |d7 }Y nX 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>R   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+   [   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   A   s<    &ÿ
þúø	÷
þñì
ÿ
zSymbolicValueError.__init__r!   r   r   r   r   r   >   s   )r   Ú
__future__r   r/   Útypingr   Ztorchr   Z
torch.onnxr   Ztorch.onnx._internalr   Ú__all__ÚUserWarningr   ÚRuntimeErrorr   r	   r
   r   r   r   r   r   Ú<module>   s"   û	