
    Yh                     (    d dl Z  G d d          ZdS )    Nc                   `    e Zd ZdZddeddfdZddZddZdd	Zdefd
Z	ddZ
dd def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                 N    t           j                            |          | _        d S )N)torch_C_mps_acquireEvent_Event__eventId)selfr   s     a/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/torch/mps/event.py__init__zEvent.__init__   s    33MBB    c                     t          t          j        d          r1| j        dk    r(t          j                            | j                   d S d S d S )N_mps_releaseEventr   )hasattrr   r	   r   r   r   s    r   __del__zEvent.__del__   sQ    58011 	7dnq6H6HH&&t~66666	7 	76H6Hr   c                 N    t           j                            | j                   dS )z(Records the event in the default stream.N)r   r	   _mps_recordEventr   r   s    r   recordzEvent.record   s     !!$.11111r   c                 N    t           j                            | j                   dS )zJMakes all future work submitted to the default stream wait for this event.N)r   r	   _mps_waitForEventr   r   s    r   waitz
Event.wait   s     ""4>22222r   c                 J    t           j                            | j                  S )zCReturns True if all work currently captured by event has completed.)r   r	   _mps_queryEventr   r   s    r   queryzEvent.query   s    x''777r   c                 N    t           j                            | j                   dS )zWaits 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   s    r   synchronizezEvent.synchronize#   s"     	&&t~66666r   	end_eventc                 V    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!   s     r   elapsed_timezEvent.elapsed_time)   s!     x00ATUUUr   )F)r   N)__name__
__module____qualname____doc__boolr   r   r   r   r   r    floatr$    r   r   r   r      s         C Cd Ct C C C C7 7 7 7
2 2 2 23 3 3 38t 8 8 8 87 7 7 7Vg V% V V V V V Vr   r   )r   r   r+   r   r   <module>r,      sJ    )V )V )V )V )V )V )V )V )V )Vr   