o
    ¡…›iœ  ã                   @   s†   U d dl 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jdB ed< e  d¡dd„ ƒZG d	d
„ d
eƒZdd„ Zdd„ ZdS )é    N)Ú_len_torch_function_stack)Ú	_pop_modeÚ
_push_modeÚTorchFunctionMode©Úcontext_decoratorÚCURRENT_DEVICEé   c                   C   sâ   h 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&’S ©N)'ÚtorchÚemptyÚempty_permutedÚempty_stridedÚempty_quantizedÚonesÚarangeÚbartlett_windowÚblackman_windowÚeyeÚfftÚfftfreqÚrfftfreqÚfullÚhamming_windowÚhann_windowÚkaiser_windowÚlinspaceÚlogspaceÚnestedÚnested_tensorÚrandÚrandnÚrandintÚrandpermÚrangeÚsparse_coo_tensorÚsparse_compressed_tensorÚsparse_csr_tensorÚsparse_csc_tensorÚsparse_bsr_tensorÚsparse_bsc_tensorÚtril_indicesÚtriu_indicesÚzerosÚasarrayÚtensorÚ	as_tensorÚscalar_tensor© r2   r2   úU/sda-disk/www/egybert/egybert_env/lib/python3.10/site-packages/torch/utils/_device.pyÚ_device_constructors   s’   þýüûúùø	÷
öõôóòñðïîíêéèçæåäãâá à!ß"Þ#Ý$Ü&Ú'Ù(Ør4   c                   @   s0   e Zd Zddd„Zdd„ Zdd„ Zdd
d„ZdS )ÚDeviceContextÚreturnNc                 C   s   t  |¡| _d S r
   )r   Údevice)Úselfr7   r2   r2   r3   Ú__init__=   s   zDeviceContext.__init__c                 C   sB   t | _| ja dd„ ttƒ ƒD ƒ}t| ƒ t|ƒD ]}t|ƒ qd S )Nc                 S   s   g | ]}t ƒ ‘qS r2   )r   )Ú.0Ú_r2   r2   r3   Ú
<listcomp>I   s    z+DeviceContext.__enter__.<locals>.<listcomp>)r   Ú
old_devicer7   r$   r   r   Úreversed)r8   Ú	cur_stackÚmoder2   r2   r3   Ú	__enter__A   s   
ÿzDeviceContext.__enter__c                 C   s|   | j ag }ttƒ d ƒD ]}tƒ }t|tƒrtdƒ‚| |¡ qtƒ dkr1tƒ }t|tƒs1tdƒ‚t	|ƒD ]}t
|ƒ q5d S )Nr	   z@Found nested DeviceContext on the mode stack where none expectedr   z8Expected a DeviceContext at the bottom of the mode stack)r=   r   r$   r   r   Ú
isinstancer5   ÚAssertionErrorÚappendr>   r   )r8   Úexc_typeÚexc_valÚexc_tbr?   r;   r@   r2   r2   r3   Ú__exit__P   s$   
ÿ

ÿ
ÿzDeviceContext.__exit__r2   c                 C   s8   |pi }|t ƒ v r| d¡d u r| j|d< ||i |¤ŽS )Nr7   )r4   Úgetr7   )r8   ÚfuncÚtypesÚargsÚkwargsr2   r2   r3   Ú__torch_function__i   s   
z DeviceContext.__torch_function__)r6   N)r2   N)Ú__name__Ú
__module__Ú__qualname__r9   rA   rH   rN   r2   r2   r2   r3   r5   <   s
    
r5   c                    s   t ‡ fdd„|ƒS )Nc                      s   ˆ S r
   r2   r2   ©r7   r2   r3   Ú<lambda>r   s    z"device_decorator.<locals>.<lambda>r   )r7   rJ   r2   rR   r3   Údevice_decoratorq   s   rT   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
   )rT   r   r7   )rJ   rR   r2   r3   rS   |   s    zset_device.<locals>.<lambda>r2   rR   r2   rR   r3   Ú
set_deviceu   s   rU   )Ú	functoolsr   Útorch._Cr   Útorch.overridesr   r   r   Útorch.utils._contextlibr   r   r7   Ú__annotations__Ú	lru_cacher4   r5   rT   rU   r2   r2   r2   r3   Ú<module>   s   

.5