Shortcuts

Source code for torch.mps.event

import torch


[docs]class Event: 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: bool = False) -> None: self.__eventId = torch._C._mps_acquireEvent(enable_timing) def __del__(self) -> None: # checks if torch._C is already destroyed if hasattr(torch._C, "_mps_releaseEvent") and self.__eventId > 0: torch._C._mps_releaseEvent(self.__eventId)
[docs] def record(self) -> None: r"""Records the event in the default stream.""" torch._C._mps_recordEvent(self.__eventId)
[docs] def wait(self) -> None: r"""Makes all future work submitted to the default stream wait for this event.""" torch._C._mps_waitForEvent(self.__eventId)
[docs] def query(self) -> bool: r"""Returns True if all work currently captured by event has completed.""" return torch._C._mps_queryEvent(self.__eventId)
[docs] def synchronize(self) -> None: 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] def elapsed_time(self, end_event: "Event") -> float: r"""Returns the time elapsed in milliseconds after the event was recorded and before the end_event was recorded. """ return torch._C._mps_elapsedTimeOfEvents(self.__eventId, end_event.__eventId)

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy