U
    <c                      @   sr   d dl mZmZmZmZ ddddZdd 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 )    )BinaryUfuncInfoOpInfoReductionOpInfoUnaryUfuncInfoNop_dbc                C   s>   |dkrddl m} |D ] }|j| kr|j|kr|  S qdS )zH
    Finds the OpInfo with the given name that has no variant name.
    Nr   r   )Z2torch.testing._internal.common_methods_invocationsr   nameZvariant_test_name)Zreferenced_nameZvariant_namer   Zopinfo r	   G/tmp/pip-unpacked-wheel-gikjz4vx/torch/testing/_internal/opinfo/refs.py_find_referenced_opinfo   s
    r   c                 C   s   | |d d d dd}|  }d|kr6||d  |d= d|krD|d= d|krR|d= d|kr`|d= d|krn|d= || || d|d< d|d	< d|d
< d|d< d|d< |S )NF)r   opaliasesZmethod_variantZinplace_variantZsupports_scriptingkwargsself	__class__skipsZ
decoratorsZsupports_autogradZsupports_gradgradZsupports_fwgrad_bwgradZsupports_inplace_autogradZsupports_forward_ad)copyupdate)r   r   	inheritedZ	overridesZcommon_kwargsr   r	   r	   r
   _inherit_constructor_args.   s6    


r   c                       s.   e Zd ZdZdddddd fdd
Z  ZS )PythonRefInfozM
    An OpInfo for a Python reference of an OpInfo base class operation.
    N T)r   r   torch_opinfo_variant_namevalidate_view_consistencysupports_nvfuserc                   sd   || _ || _t|||d| _|| _|| _t| jts8t| jj	}	t
|||	|}
tt| jf |
 d S Nr   )torch_opinfo_namer   r   torch_opinfor   r   
isinstancer   AssertionErrorZ_original_opinfo_argsr   superr   __init__)r   r   r   r   r   r   r   r   r   r   ukwargsr   r	   r
   r!   ^   s      zPythonRefInfo.__init____name__
__module____qualname____doc__r!   __classcell__r	   r	   r#   r
   r   Y   s   r   c                       s,   e Zd ZdZddddd fdd
Z  ZS )ReductionPythonRefInfoM
    An OpInfo for a Python reference of an elementwise unary operation.
    Nr   Tr   r   r   r   c          
         s`   || _ || _t|||d| _|| _t| jts2t| jj}t	||||}	d| _
t jf |	 d S )Nr   F)r   r   r   r   r   r   r   r   Z_original_reduction_argsr   r   r    r!   
r   r   r   r   r   r   r   r   r   r"   r#   r	   r
   r!   ~   s      zReductionPythonRefInfo.__init__r$   r	   r	   r#   r
   r*   y   s   r*   c                       s,   e Zd ZdZddddd fdd
Z  ZS )ElementwiseUnaryPythonRefInfor+   Nr   Tr,   c          
         s^   || _ || _t|||d| _|| _t| jts2t| jj}t	||||}	t
t| jf |	 d S r   )r   r   r   r   r   r   r   r   Z_original_unary_ufunc_argsr   r    r.   r!   r-   r#   r	   r
   r!      s      z&ElementwiseUnaryPythonRefInfo.__init__r$   r	   r	   r#   r
   r.      s   r.   c                       s,   e Zd ZdZddddd fdd
Z  ZS )ElementwiseBinaryPythonRefInfozN
    An OpInfo for a Python reference of an elementwise binary operation.
    Nr   Tr,   c          
         s^   || _ || _t|||d| _|| _t| jts2t| jj}t	||||}	t
t| jf |	 d S r   )r   r   r   r   r   r   r   r   Z_original_binary_ufunc_argsr   r    r/   r!   r-   r#   r	   r
   r!      s      z'ElementwiseBinaryPythonRefInfo.__init__r$   r	   r	   r#   r
   r/      s   r/   )Z#torch.testing._internal.opinfo.corer   r   r   r   r   r   r   r*   r.   r/   r	   r	   r	   r
   <module>   s   + "