o
    wZh                     @  s|   d Z ddlmZ ddlZddlmZ er ddlZddlZddlZ	ej
dddG dd dZej
dddG d	d
 d
ZdS )z8Module for handling ATen to ONNX functions registration.    )annotationsN)TYPE_CHECKINGT)frozeneqc                   @  s:   e Zd ZU dZded< ded< dZded< dZded	< d
S )ONNXFunctiona_  A wrapper of onnx-script function.

    op_full_name: The qualified name of the function. In the form of '<namespace>::<op_name>.<overload>'.
    onnx_function: The onnx-script function from torchlib.
    is_custom: Whether the function is a custom function.
    is_complex: Whether the function is a function that handles complex valued inputs.

    z7onnxscript.OnnxFunction | onnxscript.TracedOnnxFunctionZonnx_functionstrZop_full_nameFbool	is_custom
is_complexN)__name__
__module____qualname____doc____annotations__r	   r
    r   r   S/var/www/auris/lib/python3.10/site-packages/torch/onnx/_internal/fx/registration.pyr      s   
 	r   c                   @  sp   e Zd ZU dZded< ded< ded< e	ddd	d
ZedddZedddZedddZ	dddZ
dS )OpNamezAA class representing an operator name in internal ONNX converter.r   	namespaceop_nameoverloadN
str | Nonereturnc                 C  s    |d u s|dkr
d}| |||S )N defaultr   )clsr   r   r   r   r   r   from_name_parts-   s   zOpName.from_name_partsqualified_namec                 C  s:   | d\}}| dd^}}|r|d nd}| |||S )z4When the name is <namespace>::<op_name>[.<overload>]::.   r   r   )split)r   r   r   Zopname_overloadr   r   r   r   r   from_qualified_name7   s   zOpName.from_qualified_nameop_overloadtorch._ops.OpOverloadc                 C  s   |  | S N)r!   name)r   r"   r   r   r   from_op_overload?   s   zOpName.from_op_overloadbuiltin_functiontypes.BuiltinFunctionTypec                 C  s   |j }|j}| |d | S )a  From a builtin function, e.g. operator.add, math.ceil, etc, get the OpName.

        FX graph uses built-in functions to caculate sympy expression. This function
        is used to get the OpName from a builtin function.

        Args:
            builtin_function (types.BuiltinFunctionType): operator.add, math.ceil, etc.

        Returns:
            OpName: _description_
        r   )r   r   r!   )r   r'   opmoduler   r   r   from_builtin_functionC   s   zOpName.from_builtin_functionc                 C  s   | j  d| j d| j S )Nr   r   )r   r   r   )selfr   r   r   r   V   s   zOpName.qualified_namer$   )r   r   r   r   r   r   r   r   )r   r   r   r   )r"   r#   r   r   )r'   r(   r   r   )r   r   )r   r   r   r   r   classmethodr   r!   r&   r+   r   r   r   r   r   r   %   s   
 	r   )r   
__future__r   dataclassestypingr   typesZ
onnxscriptZ
torch._opsZtorch	dataclassr   r   r   r   r   r   <module>   s    