o
    ðÇhÂ  ã                   @   s   d dl Z G dd„ dƒZdS )é    Nc                   @   sl   e Zd ZdZddeddfdd„Zddd	„Zdd
d„Zddd„Zdefdd„Z	ddd„Z
dd def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``)
    FÚenable_timingÚreturnNc                 C   s   t j |¡| _d S )N)ÚtorchÚ_CÚ_mps_acquireEventÚ_Event__eventId)Úselfr   © r
   úc/var/www/html/construction_image-detection-poc/venv/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   Ú_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   Ú_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   Ú_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   Ú_mps_synchronizeEventr   r   r
   r
   r   Úsynchronize#   ó   zEvent.synchronizeÚ	end_eventc                 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   Ú_mps_elapsedTimeOfEventsr   )r	   r   r
   r
   r   Úelapsed_time)   r   zEvent.elapsed_time)F)r   N)Ú__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    