
    קg                         d dl Z d dlmZ d dlmZ d dlZg dZ G d dej        j        j	                  Z	 ede
          d	             Z ed
e
          dddd            Z ede
          d             ZdS )    N)Any)
deprecated)autocast
custom_fwd
custom_bwdc                        e Zd ZdZ ede          dej        dfdedej	        def fd            Z
 fd	Zd
ededef fdZ fdZ x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                     t           j                                        r|| _        d| _        || _        d S t                                          d|||           d S )Ncuda)r   r   r   )torch_jit_internalis_scripting_enableddevice
fast_dtypesuper__init__)selfr   r   r   	__class__s       X/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/cuda/amp/autocast_mode.pyr   zautocast.__init__   sj     ++-- 	#DM DK#DOFG5 	 	
 	
 	
 	
 	
    c                     t           j                                        r| S t                                                      S N)r   r   r   r   	__enter__)r   r   s    r   r   zautocast.__enter__&   s5    ++-- 	Kww  """r   exc_typeexc_valexc_tbc                     t           j                                        rd S t                                          |||          S r   )r   r   r   r   __exit__)r   r   r    r!   r   s       r   r#   zautocast.__exit__,   s;    ++-- 	Fww'6:::r   c                     t           j                                        r|S t                                          |          S r   )r   r   r   r   __call__)r   funcr   s     r   r%   zautocast.__call__1   s7    ++-- 	Kww%%%r   )__name__
__module____qualname____doc__r   FutureWarningr   float16boolr   r   r   r   r#   r%   __classcell__)r   s   @r   r   r      s        
 Z	D   "]"	
 

 {
 	
 
 
 
 
 

# # # # #; ;s ;C ; ; ; ; ; ;
& & & & & & & & &r   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                 N    t           j        j                            | d|          S )Nr   )r   ampautocast_mode_cast)valuer   s     r   r2   r2   8   s!     9"((>>>r   z{`torch.cuda.amp.custom_fwd(args...)` is deprecated. Please use `torch.amp.custom_fwd(args..., device_type='cuda')` instead.)cast_inputsc                b     t          j        t          j        j        d          | |          S )z
    ``torch.cuda.amp.custom_fwd(args...)`` is deprecated. Please use
    ``torch.amp.custom_fwd(args..., device_type='cuda')`` instead.
    r   device_typefwdr4   )	functoolspartialr   r0   r   r8   s     r   r   r   A   s8     G9UY1vFFF[   r   z{`torch.cuda.amp.custom_bwd(args...)` is deprecated. Please use `torch.amp.custom_bwd(args..., device_type='cuda')` instead.c                 ^     t          j        t          j        j        d          |           S )z
    ``torch.cuda.amp.custom_bwd(args...)`` is deprecated. Please use
    ``torch.amp.custom_bwd(args..., device_type='cuda')`` instead.
    r   r6   )r:   r;   r   r0   r   )bwds    r   r   r   P   s*     G9UY1vFFFsKKKr   r   )r:   typingr   typing_extensionsr   r   __all__r0   r1   r   r+   r2   r   r    r   r   <module>rB      sF             ( ( ( ( ( (  3
2
2(& (& (& (& (&uy&/ (& (& (&X P  
? ? 
? N  
     
 N  
L L 
L L Lr   