o
    Zh                     @   s   d dl Z d dlmZ d dlmZ d dlZg dZG dd dejjj	Z	ede
dd	d
 Zede
ddddddZede
ddd ZdS )    N)Any)
deprecated)autocast
custom_fwd
custom_bwdc                       sx   e Zd ZdZededdejdfdedej	def fdd	Z
 fd
dZdededef fddZ fddZ  ZS )r   zSee :class:`torch.autocast`.

    ``torch.cuda.amp.autocast(args...)`` is deprecated. Please use ``torch.amp.autocast("cuda", args...)`` instead.
    zk`torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.categoryTenableddtypecache_enabledc                    s8   t j r|| _d| _|| _d S t jd|||d d S )Ncuda)r	   r
   r   )torch_jit_internalis_scriptingZ_enabledZdeviceZ
fast_dtypesuper__init__)selfr	   r
   r   	__class__ K/var/www/auris/lib/python3.10/site-packages/torch/cuda/amp/autocast_mode.pyr      s   

zautocast.__init__c                    s   t j r| S t  S N)r   r   r   r   	__enter__)r   r   r   r   r   &   s   

zautocast.__enter__exc_typeexc_valexc_tbc                    s   t j rd S t |||S r   )r   r   r   r   __exit__)r   r   r   r   r   r   r   r   ,   s   
zautocast.__exit__c                    s   t j r|S t |S r   )r   r   r   r   __call__)r   funcr   r   r   r   1   s   
zautocast.__call__)__name__
__module____qualname____doc__r   FutureWarningr   Zfloat16boolr
   r   r   r   r   r   __classcell__r   r   r   r   r      s&    r   z`torch.cuda.amp.autocast_mode._cast(value, dtype)` is deprecated. Please use `torch.amp.autocast_mode._cast(value, 'cuda', dtype)` instead.r   c                 C   s   t jj| d|S )Nr   )r   ampautocast_mode_cast)valuer
   r   r   r   r(   8   s   r(   z{`torch.cuda.amp.custom_fwd(args...)` is deprecated. Please use `torch.amp.custom_fwd(args..., device_type='cuda')` instead.)cast_inputsc                C   s   t jtjjdd| |dS )z
    ``torch.cuda.amp.custom_fwd(args...)`` is deprecated. Please use
    ``torch.amp.custom_fwd(args..., device_type='cuda')`` instead.
    r   Zdevice_typeZfwdr*   )	functoolspartialr   r&   r   r,   r   r   r   r   A   s   
r   z{`torch.cuda.amp.custom_bwd(args...)` is deprecated. Please use `torch.amp.custom_bwd(args..., device_type='cuda')` instead.c                 C   s   t jtjjdd| S )z
    ``torch.cuda.amp.custom_bwd(args...)`` is deprecated. Please use
    ``torch.amp.custom_bwd(args..., device_type='cuda')`` instead.
    r   r+   )r-   r.   r   r&   r   )Zbwdr   r   r   r   P   s   
r   r   )r-   typingr   Ztyping_extensionsr   r   __all__r&   r'   r   r#   r(   r   r   r   r   r   r   <module>   s*   ,

