o
    i                     @   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
   L/home/ubuntu/veenaModal/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   )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   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    