U
    d                     @   s.   d dl Z d dlmZ G dd de jjjZdS )    N)Anyc                       sd   e Zd ZdZdejdfeejed fddZ fddZ	e
e
e
d fd	d
Z fddZ  ZS )autocastz
    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cpur   )torch_jit_internalis_scriptingZ_enabledZdeviceZ
fast_dtypesuper__init__)selfr   r   r   	__class__ ?/tmp/pip-unpacked-wheel-ua33x9lu/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	   Zbfloat16boolr   r   r   r   r   r   __classcell__r   r   r   r   r      s
   "r   )r	   typingr   ampZautocast_moder   r   r   r   r   <module>   s   