U
    Mh_                     @  s   d Z ddlmZ ddlZddlZddlmZmZmZ ddl	Z
ddlmZ erTd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)OptionalTYPE_CHECKINGUnion)	_beartypeT)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.

    zCUnion[('onnxscript.OnnxFunction', 'onnxscript.TracedOnnxFunction')]Zonnx_functionstrZop_full_nameFbool	is_custom
is_complexN)__name__
__module____qualname____doc____annotations__r   r    r   r   V/var/www/html/venv/lib/python3.8/site-packages/torch/onnx/_internal/fx/registration.pyr	      s
   
	r	   c                   @  s   e Zd ZU dZded< ded< ded< eejddddd dd	d
Zeejdd dddZ	eejdd dddZ
eejdd dddZejddddZdS )OpNamezAA class representing an operator name in internal ONNX converter.r
   	namespaceop_nameoverloadNzOptional[str])r   r   r   returnc                 C  s    |d ks|dkrd}| |||S )N defaultr   )clsr   r   r   r   r   r   from_name_parts,   s    zOpName.from_name_parts)qualified_namer   c                 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_nameztorch._ops.OpOverload)op_overloadr   c                 C  s   |  | S )N)r#   name)r   r$   r   r   r   from_op_overload@   s    zOpName.from_op_overloadztypes.BuiltinFunctionType)builtin_functionr   c                 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_functionE   s    zOpName.from_builtin_function)r   c                 C  s   | j  d| j d| j S )Nr   r    )r   r   r   )selfr   r   r   r   Y   s    zOpName.qualified_name)N)r   r   r   r   r   classmethodr   Zbeartyper   r#   r&   r*   r   r   r   r   r   r   $   s&   
 	r   )r   
__future__r   dataclassestypestypingr   r   r   Z
torch._opsZtorchZtorch.onnx._internalr   Z
onnxscript	dataclassr	   r   r   r   r   r   <module>   s   