latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
Event
- class tensorplay.cuda.streams.Event(device=None, *, enable_timing=False, blocking=False, interprocess=False)[source]
Query and record Stream status to identify or control dependencies across Stream and measure timing.
- Parameters:
device (
tensorplay.device, optional) – the desired device for the Event. If not given, the current the relevant documentation type will be used.enable_timing (bool, optional) – indicates if the event should measure time (default:
False)blocking (bool, optional) – if
True,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:
An tensorplay.Event object.
- Return type:
Example:
>>> event = tensorplay.Event() >>> e_cuda = tensorplay.Event(device='cuda')- elapsed_time(end_event) float[source]
Returns the elapsed time in milliseconds between when this event and the
end_eventare each recorded viatensorplay.Stream.record_event().- Parameters:
end_event (
tensorplay.Event) – The ending event has been recorded.- Returns:
Time between starting and ending event in milliseconds.
- Return type:
Example:
>>> s_cuda = tensorplay.Stream(device='cuda') >>> e1_cuda = s_cuda.record_event() >>> e2_cuda = s_cuda.record_event() >>> ms = e1_cuda.elapsed_time(e2_cuda)
- classmethod from_ipc_handle(device, handle)[source]
Reconstruct an event from an IPC handle on the given device.
- ipc_handle()[source]
Return an IPC handle of this event.
- query() bool[source]
Check if the stream where this event was recorded already moved past the point where the event was recorded. Always returns
Trueif the Event was not recorded.- Returns:
A boolean indicating if all work currently captured by event has completed.
- Return type:
Example:
>>> s_cuda = tensorplay.Stream(device='cuda') >>> e_cuda = s_cuda.record_event() >>> e_cuda.query() True
- record(stream=None) None[source]
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).- Parameters:
stream (
tensorplay.Stream, optional) – A stream to be recorded. If not given, the current stream will be used.
Example:
>>> e_cuda = tensorplay.Event(device='cuda') >>> e_cuda.record()
- synchronize() None[source]
Wait for the event to complete. This prevents the CPU thread from proceeding until the event completes.
Example:
>>> s_cuda = tensorplay.Stream(device='cuda') >>> e_cuda = s_cuda.record_event() >>> e_cuda.synchronize()
- wait(stream=None) None[source]
Make all future work submitted to the given stream wait for this event.
- Parameters:
stream (
tensorplay.Stream, optional) – A stream to synchronize. If not given, the current stream will be used.
Example:
>>> s1_cuda = tensorplay.Stream(device='cuda') >>> s2_cuda = tensorplay.Stream(device='cuda') >>> e_cuda = s1_cuda.record() >>> e_cuda.wait(s2)
Help improve this page
Found an error, an unclear step, or a missing example?

