a
    ¡º”hÂ  ã                   @   s   d dl Z G dd„ dƒZdS )é    Nc                   @   sx   e Zd ZdZdeddœdd„Zddœdd	„Zddœd
d„Zddœdd„Zedœdd„Z	ddœdd„Z
d edœdd„ZdS )ÚEventaA  Wrapper around an MPS event.

    MPS events are synchronization markers that can be used to monitor the
    device's progress, to accurately measure timing, and to synchronize MPS streams.

    Args:
        enable_timing (bool, optional): indicates if the event should measure time
            (default: ``False``)
    FN)Úenable_timingÚreturnc                 C   s   t j |¡| _d S )N)ÚtorchÚ_CZ_mps_acquireEventÚ_Event__eventId)Úselfr   © r	   ú=/var/www/auris/lib/python3.9/site-packages/torch/mps/event.pyÚ__init__   s    zEvent.__init__)r   c                 C   s(   t tjdƒr$| jdkr$tj | j¡ d S )NÚ_mps_releaseEventr   )Úhasattrr   r   r   r   ©r   r	   r	   r
   Ú__del__   s    zEvent.__del__c                 C   s   t j | j¡ dS )z(Records the event in the default stream.N)r   r   Z_mps_recordEventr   r   r	   r	   r
   Úrecord   s    zEvent.recordc                 C   s   t j | j¡ dS )zJMakes all future work submitted to the default stream wait for this event.N)r   r   Z_mps_waitForEventr   r   r	   r	   r
   Úwait   s    z
Event.waitc                 C   s   t j | j¡S )zCReturns True if all work currently captured by event has completed.)r   r   Z_mps_queryEventr   r   r	   r	   r
   Úquery   s    zEvent.queryc                 C   s   t j | j¡ dS )z¡Waits until the completion of all work currently captured in this event.
        This prevents the CPU thread from proceeding until the event completes.
        N)r   r   Z_mps_synchronizeEventr   r   r	   r	   r
   Úsynchronize#   s    zEvent.synchronize)Ú	end_eventr   c                 C   s   t j | j|j¡S )z}Returns the time elapsed in milliseconds after the event was
        recorded and before the end_event was recorded.
        )r   r   Z_mps_elapsedTimeOfEventsr   )r   r   r	   r	   r
   Úelapsed_time)   s    zEvent.elapsed_time)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úboolr   r   r   r   r   r   Úfloatr   r	   r	   r	   r
   r      s   
r   )r   r   r	   r	   r	   r
   Ú<module>   s   