
    sg                         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y)    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                  j                         r|| _        d| _        || _        y t        |   d|||       y )Ncuda)r   r   r   )torch_jit_internalis_scripting_enableddevice
fast_dtypesuper__init__)selfr   r   r   	__class__s       O/var/www/html/venv/lib/python3.12/site-packages/torch/cuda/amp/autocast_mode.pyr   zautocast.__init__   sJ     ++-#DM DK#DOG5 	 	
    c                 `    t         j                  j                         r| S t        |          S N)r   r   r   r   	__enter__)r   r   s    r   r   zautocast.__enter__&   s(    ++-Kw ""r   exc_typeexc_valexc_tbc                 d    t         j                  j                         ry t        |   |||      S r   )r   r   r   r   __exit__)r   r   r    r!   r   s       r   r#   zautocast.__exit__,   s,    ++-w'6::r   c                 b    t         j                  j                         r|S t        |   |      S r   )r   r   r   r   __call__)r   funcr   s     r   r%   zautocast.__call__1   s*    ++-Kw%%r   )__name__
__module____qualname____doc__r   FutureWarningr   float16boolr   r   r   r   r#   r%   __classcell__)r   s   @r   r   r      s    
 	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                 X    t         j                  j                  j                  | d|      S )Nr   )r   ampautocast_mode_cast)valuer   s     r   r2   r2   8   s#     99""((>>r   z{`torch.cuda.amp.custom_fwd(args...)` is deprecated. Please use `torch.amp.custom_fwd(args..., device_type='cuda')` instead.)cast_inputsc                p     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   s0     G9UYY11vF[ r   z{`torch.cuda.amp.custom_bwd(args...)` is deprecated. Please use `torch.amp.custom_bwd(args..., device_type='cuda')` instead.c                 l     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UYY11vFsKKr   r   )r:   typingr   typing_extensionsr   r   __all__r0   r1   r   r+   r2   r   r    r   r   <module>rB      s      (  3(&uyy&&// (&X P
?
? N
 
 N
L
Lr   