U
    Mhf                     @   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	   U/var/www/html/venv/lib/python3.8/site-packages/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_args0   s6    


r   c                       s,   e Zd ZdZ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_consistencyc          
         sZ   || _ || _t|||d| _|| _t| jts2t| jj}t	||||}	t
 jf |	 d S Nr   )torch_opinfo_namer   r   torch_opinfor   
isinstancer   AssertionErrorZ_original_opinfo_argsr   super__init__
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   [   s   r   c                       s*   e Zd ZdZdddd fdd
Z  ZS )ReductionPythonRefInfoM
    An OpInfo for a Python reference of an elementwise unary operation.
    Nr   r   r   r   c          	         sZ   || _ || _t|||d| _t| jts,t| jj}t||||}d| _	t
 jf | d S )Nr   F)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!   }   s    
  zReductionPythonRefInfo.__init__r%   r	   r	   r$   r
   r+   x   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          
         sZ   || _ || _t|||d| _|| _t| jts2t| jj}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!      s      z&ElementwiseUnaryPythonRefInfo.__init__r%   r	   r	   r$   r
   r/      s   r/   c                       s*   e Zd ZdZdddd fdd
Z  ZS )ElementwiseBinaryPythonRefInfozN
    An OpInfo for a Python reference of an elementwise binary operation.
    Nr   r-   c          	         sT   || _ || _t|||d| _t| jts,t| jj}t||||}t	 j
f | d S r   )r   r   r   r   r   r   r   Z_original_binary_ufunc_argsr   r    r!   r.   r$   r	   r
   r!      s    
  z'ElementwiseBinaryPythonRefInfo.__init__r%   r	   r	   r$   r
   r0      s
   r0   )Z#torch.testing._internal.opinfo.corer   r   r   r   r   r   r   r+   r/   r0   r	   r	   r	   r
   <module>   s   +