mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
[Easy][torch.Event] Fix and improve the docs of torch.Event (#151411)
**Changes:** - add detailed function or class signature - fix the wrong display of torch.Event.wait and torch.Event.record Pull Request resolved: https://github.com/pytorch/pytorch/pull/151411 Approved by: https://github.com/albanD ghstack dependencies: #151404, #151221
This commit is contained in:
@ -13394,14 +13394,20 @@ Example::
|
||||
add_docstr(
|
||||
torch.Event,
|
||||
r"""
|
||||
Event(device, *, enable_timing) -> Event
|
||||
Event(device=None, *, enable_timing=False, blocking=False, interprocess=False)
|
||||
|
||||
Query and record Stream status to identify or control dependencies across Stream and measure timing.
|
||||
|
||||
Arguments:
|
||||
device (:class:`torch.device`, optional): the desired device for the Event.
|
||||
If not given, the current :ref:`accelerator<accelerators>` type will be used.
|
||||
enable_timing (bool, optional): indicates if the event should measure time (default: ``False``).
|
||||
enable_timing (bool, optional): indicates if the event should measure time (default: ``False``)
|
||||
blocking (bool, optional): if ``True``, :meth:`wait` will be blocking (default: ``False``)
|
||||
interprocess (bool): if ``True``, the event can be shared between processes (default: ``False``)
|
||||
|
||||
.. warning::
|
||||
|
||||
Both blocking and interprocess are not supported right now and are noops.
|
||||
|
||||
Returns:
|
||||
Event: An torch.Event object.
|
||||
@ -13409,6 +13415,7 @@ Returns:
|
||||
Example::
|
||||
|
||||
>>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_CUDA)
|
||||
>>> event = torch.Event()
|
||||
>>> e_cuda = torch.Event(device='cuda')
|
||||
""",
|
||||
)
|
||||
@ -13464,14 +13471,14 @@ Example::
|
||||
add_docstr(
|
||||
torch.Event.record,
|
||||
r"""
|
||||
Event.record(stream) -> None
|
||||
Event.record(stream=None) -> None
|
||||
|
||||
Record the event in a given stream. The stream's device must match the event's device.
|
||||
This function is equivalent to ``stream.record_event(self)``.
|
||||
|
||||
Arguments:
|
||||
stream (:class:`torch.Stream`, optional): A stream to be recorded.
|
||||
If not given, the current stream will be used.
|
||||
If not given, the current stream will be used.
|
||||
|
||||
Example::
|
||||
|
||||
@ -13502,13 +13509,13 @@ Example::
|
||||
add_docstr(
|
||||
torch.Event.wait,
|
||||
r"""
|
||||
Event.wait(stream) -> None
|
||||
Event.wait(stream=None) -> None
|
||||
|
||||
Make all future work submitted to the given stream wait for this event.
|
||||
|
||||
Arguments:
|
||||
stream (:class:`torch.Stream`, optional): A stream to synchronize.
|
||||
If not given, the current stream will be used.
|
||||
If not given, the current stream will be used.
|
||||
|
||||
Example::
|
||||
|
||||
|
Reference in New Issue
Block a user