o
    h                     @   s4   d dl mZ d dlZdgZG dd dejjjZdS )    )AnyNautocastc                       sl   e Zd ZdZ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   z
    See :class:`torch.autocast`.
    ``torch.cpu.amp.autocast(args...)`` is equivalent to ``torch.autocast("cpu", args...)``
    Tenableddtypecache_enabledc                    s8   t j r|| _d| _|| _d S t jd|||d d S )Ncpu)r   r   r   )torch_jit_internalis_scripting_enableddevice
fast_dtypesuper__init__)selfr   r   r   	__class__ Q/var/www/html/ai/venv/lib/python3.10/site-packages/torch/cpu/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   (   s   
zautocast.__call__)__name__
__module____qualname____doc__r   bfloat16boolr   r   r   r   r   r   __classcell__r   r   r   r   r      s    )typingr   r   __all__ampautocast_moder   r   r   r   r   <module>   s    