a
    ¢º”h}  ã                   @   s’   U d dl Z d dlmZ d dlZd dlmZ d dlmZmZm	Z	 d dl
mZ daeej ed< e  d¡dd	„ ƒZG d
d„ de	ƒZdd„ Zdd„ ZdS )é    N)ÚOptional)Ú_len_torch_function_stack)Ú	_pop_modeÚ
_push_modeÚTorchFunctionMode©Úcontext_decoratorÚCURRENT_DEVICEé   c                $   C   sš   t jt jt jt jt jt jt jt jt j	t j
jt j
jt jt jt jt jt jt jt jjt jt jt jt jt jt jt jt jt jt jt jt j t j!t j"t j#t j$t j%t j&h$S ©N)'ÚtorchÚemptyZempty_permutedZempty_stridedZempty_quantizedZonesZarangeZbartlett_windowZblackman_windowZeyeZfftZfftfreqZrfftfreqÚfullZhamming_windowZhann_windowZkaiser_windowZlinspaceZlogspaceÚnestedZnested_tensorZrandZrandnÚrandintZrandpermÚrangeZsparse_coo_tensorZsparse_compressed_tensorZsparse_csr_tensorZsparse_csc_tensorZsparse_bsr_tensorZsparse_bsc_tensorZtril_indicesZtriu_indicesÚzerosZasarrayZtensorZ	as_tensorZscalar_tensor© r   r   úA/var/www/auris/lib/python3.9/site-packages/torch/utils/_device.pyÚ_device_constructors   sJ    Ør   c                   @   s.   e Zd Zdd„ Zdd„ Zdd„ Zdd	d
„ZdS )ÚDeviceContextc                 C   s   t  |¡| _d S r   )r   Údevice)Úselfr   r   r   r   Ú__init__>   s    zDeviceContext.__init__c                 C   sB   t | _| ja dd„ ttƒ ƒD ƒ}t| ƒ t|ƒD ]}t|ƒ q0d S )Nc                 S   s   g | ]
}t ƒ ‘qS r   )r   )Ú.0Ú_r   r   r   Ú
<listcomp>I   ó    z+DeviceContext.__enter__.<locals>.<listcomp>)r	   Ú
old_devicer   r   r   r   Úreversed)r   Ú	cur_stackÚmoder   r   r   Ú	__enter__A   s    zDeviceContext.__enter__c                 C   st   | j ag }ttƒ d ƒD ]"}tƒ }t|tƒr0J ‚| |¡ qtƒ dkrZtƒ }t|tƒsZJ ‚t|ƒD ]}t	|ƒ qbd S )Nr
   r   )
r   r	   r   r   r   Ú
isinstancer   Úappendr   r   )r   Úexc_typeÚexc_valÚexc_tbr    r   r!   r   r   r   Ú__exit__P   s    
zDeviceContext.__exit__r   Nc                 C   s8   |pi }|t ƒ v r*| d¡d u r*| j|d< ||i |¤ŽS )Nr   )r   Úgetr   )r   ÚfuncÚtypesÚargsÚkwargsr   r   r   Ú__torch_function__c   s    
z DeviceContext.__torch_function__)r   N)Ú__name__Ú
__module__Ú__qualname__r   r"   r(   r.   r   r   r   r   r   =   s   r   c                    s   t ‡ fdd„|ƒS )Nc                      s   ˆ S r   r   r   ©r   r   r   Ú<lambda>l   r   z"device_decorator.<locals>.<lambda>r   )r   r*   r   r2   r   Údevice_decoratork   s    r4   c                    s   ‡ fdd„S )zð
    Set the default device inside of the wrapped function by decorating it with this function.

    If you would like to use this as a context manager, use device as a
    context manager directly, e.g., ``with torch.device(device)``.
    c                    s   t t ˆ ¡| ƒS r   )r4   r   r   )r*   r2   r   r   r3   v   r   zset_device.<locals>.<lambda>r   r2   r   r2   r   Ú
set_deviceo   s    r5   )Ú	functoolsÚtypingr   r   Ztorch._Cr   Ztorch.overridesr   r   r   Ztorch.utils._contextlibr   r	   r   Ú__annotations__Ú	lru_cacher   r   r4   r5   r   r   r   r   Ú<module>   s   

..