o
    ‘ix  ã                   @   s   d dl Z G dd„ dƒZdS )é    Nc                   @   sJ   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	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``)
    Fc                 C   s   t j |¡| _d S )N)ÚtorchÚ_CZ_mps_acquireEventÚ_Event__eventId)ÚselfZenable_timing© r   ú^/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/torch/mps/event.pyÚ__init__   s   zEvent.__init__c                 C   s0   t tjdƒr| jdkrtj | j¡ d S d S d S )NÚ_mps_releaseEventr   )Úhasattrr   r   r   r
   ©r   r   r   r   Ú__del__   s   ÿzEvent.__del__c                 C   ó   t j | j¡ dS )z(Records the event in the default stream.N)r   r   Z_mps_recordEventr   r   r   r   r   Úrecord   ó   zEvent.recordc                 C   r   )zJMakes all future work submitted to the default stream wait for this event.N)r   r   Z_mps_waitForEventr   r   r   r   r   Úwait   r   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   r   )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#   ó   zEvent.synchronizec                 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   Z	end_eventr   r   r   Úelapsed_time)   r   zEvent.elapsed_timeN)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   r   r   r   r   r   r      s    

r   )r   r   r   r   r   r   Ú<module>   s    