[docs]classEvent:r"""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``) """def__init__(self,enable_timing=False):self.__eventId=torch._C._mps_acquireEvent(enable_timing)def__del__(self):# checks if torch._C is already destroyedifhasattr(torch._C,"_mps_releaseEvent")andself.__eventId>0:torch._C._mps_releaseEvent(self.__eventId)
[docs]defrecord(self):r"""Records the event in the default stream."""torch._C._mps_recordEvent(self.__eventId)
[docs]defwait(self):r"""Makes all future work submitted to the default stream wait for this event."""torch._C._mps_waitForEvent(self.__eventId)
[docs]defquery(self):r"""Returns True if all work currently captured by event has completed."""returntorch._C._mps_queryEvent(self.__eventId)
[docs]defsynchronize(self):r"""Waits until the completion of all work currently captured in this event. This prevents the CPU thread from proceeding until the event completes. """torch._C._mps_synchronizeEvent(self.__eventId)
[docs]defelapsed_time(self,end_event):r"""Returns the time elapsed in milliseconds after the event was recorded and before the end_event was recorded. """returntorch._C._mps_elapsedTimeOfEvents(self.__eventId,end_event.__eventId)
Docs
Access comprehensive developer documentation for PyTorch
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.