U
    d                     @   s  d Z ddlmZ ddlZdddddd	d
dddddddddddddddgZed:Zdd ZG dd deZedZ	dd Z
eejejfZdd Zeejf Zd d Zd!d Zeejejf Zd"d Zd#d ZeejejfZd$d ZeejejejejejfZ d%d Z!d&d Z"ee  Z#d'd Z$d(d Z%eejejfZ&d)d Z'd*d+ Z(e#e& Z)d,d Z*d-d	 Z+e#ejf Z,d.d
 Z-d;eej. d1d2dZ/eej. d1d3dZ0d<eej. d1d4dZ1eej. d1d5dZ2d=eej. d1d6dZ3eej. d1d7d8Z4ee5 d1d9dZ6dS )>a  This module exist to be able to deprecate functions publicly without doing so internally. The deprecated
public versions are defined in torch.testing._deprecated and exposed from torch.testing. The non-deprecated internal
versions should be imported from torch.testing._internal
    )ListN_validate_dtypes_dispatch_dtypes	all_typesall_types_andall_types_and_complexall_types_and_complex_andall_types_and_halfcomplex_typesempty_typesfloating_and_complex_typesfloating_and_complex_types_andfloating_typesfloating_types_anddouble_typesfloating_types_and_halfget_all_complex_dtypesget_all_dtypesget_all_fp_dtypesget_all_int_dtypesget_all_math_dtypesintegral_typesintegral_types_andget_all_device_typesc                  G   s   | D ]}t |tjstq| S N)
isinstancetorchdtypeAssertionError)dtypesr    r    9/tmp/pip-unpacked-wheel-ua33x9lu/torch/testing/_legacy.pyr   ,   s    c                   @   s   e Zd Zdd ZdS )r   c                 C   s   t |tsttt| |S r   )r   tupler   r   __add__)selfotherr    r    r!   r#   3   s    z_dispatch_dtypes.__add__N)__name__
__module____qualname__r#   r    r    r    r!   r   2   s   r    c                   C   s   t S r   )_empty_typesr    r    r    r!   r   8   s    c                   C   s   t S r   )_floating_typesr    r    r    r!   r   <   s    c                   C   s   t S r   )_floating_types_and_halfr    r    r    r!   r   @   s    c                  G   s   t t|   S r   )r*   r   r   r    r    r!   r   C   s    c                   C   s   t S r   )_floating_and_complex_typesr    r    r    r!   r   G   s    c                  G   s   t t|   S r   )r-   r   r,   r    r    r!   r   J   s    c                   C   s   t S r   )_double_typesr    r    r    r!   r   N   s    c                   C   s   t S r   )_integral_typesr    r    r    r!   r   R   s    c                  G   s   t t|   S r   )r/   r   r,   r    r    r!   r   U   s    c                   C   s   t S r   )
_all_typesr    r    r    r!   r   Y   s    c                  G   s   t t|   S r   )r0   r   r,   r    r    r!   r   \   s    c                   C   s   t S r   )_complex_typesr    r    r    r!   r
   `   s    c                  G   s   t t|   S r   )r1   r   r,   r    r    r!   complex_types_andc   s    r2   c                   C   s   t S r   )_all_types_and_complexr    r    r    r!   r   g   s    c                  G   s   t t|   S r   )r3   r   r,   r    r    r!   r   j   s    c                   C   s   t S r   )_all_types_and_halfr    r    r    r!   r	   n   s    TF)returnc                 C   sD   t  t| |d }|r"|tj |r2|t|7 }|r@|t 7 }|S )Ninclude_halfinclude_bfloat16)r   r   appendr   boolr   get_all_qint_dtypes)r7   r8   Zinclude_boolZinclude_complexinclude_complex32Zinclude_qintr   r    r    r!   r   t   s    
c                 C   s   t  t| ddd t  S )NcudaFr6   )r   r   
startswithr   )Zdevicer    r    r!   r      s
    c                 C   s    | rt jt jt jgS t jt jgS r   )r   Z	complex32Z	complex64
complex128)r<   r    r    r!   r      s    c                   C   s   t jt jt jt jt jgS r   )r   uint8int8int16int32int64r    r    r    r!   r      s    c                 C   s0   t jt jg}| r|t j |r,|t j |S r   )r   float32float64r9   Zfloat16Zbfloat16)r7   r8   r   r    r    r!   r      s    c                   C   s   t jt jt jt jt jgS r   )r   Zqint8Zquint8Zqint32Zquint4x2Zquint2x4r    r    r    r!   r;      s    r;   c                   C   s   t j sdgS ddgS )Ncpur=   )r   r=   Zis_availabler    r    r    r!   r      s    )r   )TTTTFF)F)TT)7__doc__typingr   r   Z__all_dtype_getters____all__r   r"   r   r)   r   rE   rF   r*   r   Zhalfr+   r   r   ZcfloatZcdoubler-   r   r   r?   r.   r   r@   rA   rB   rC   rD   r/   r   r   r0   r   r   r1   r
   r2   r3   r   r   r4   r	   r   r   r   r   r   r   r;   strr   r    r    r    r!   <module>   s    	      	