Classes 3
Event
classFull reference ↗- class tensorplay.cuda.streams.Event(enable_timing=False, blocking=False, interprocess=False, external=False)[source]
Wrapper around a CUDA event.
CUDA events are synchronization markers that can be used to monitor the device’s progress, to accurately measure timing, and to synchronize CUDA streams.
- Parameters:
- elapsed_time(end_event: Event)[source]
Return the time elapsed.
Time reported in milliseconds after the event was recorded and before the end_event was recorded.
- Parameters:
end_event (Event) – the end event.
- 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()[source]
Check if all work currently captured by event has completed.
ExternalStream
classFull reference ↗- class tensorplay.cuda.streams.ExternalStream(stream_ptr, device=None, **kwargs)[source]
Wrapper around an externally allocated CUDA stream.
This class is used to wrap streams allocated in other libraries in order to facilitate data exchange and multi-library interactions.
Note
This class doesn’t manage the stream life-cycle, it is the user responsibility to keep the referenced stream alive while this class is being used.
- Parameters:
stream_ptr (int) – Integer representation of the cudaStream_t value allocated externally.
device (tensorplay.Device or int, optional) – the device where the stream was originally allocated. If device is specified incorrectly, subsequent launches using this stream may fail.
- query() bool
Check if all the work submitted has been completed.
- record_event(event: Event | None = None)
Record an event.
- Parameters:
event (Event, optional) – event to record. If not given, a new one will be allocated.
- Returns:
Recorded event.
- synchronize() None
Wait for all the kernels in this stream to complete.
Stream
classFull reference ↗- class tensorplay.cuda.streams.Stream(device=None, priority=0, **kwargs)[source]
Wrapper around a CUDA stream.
A CUDA stream is a linear sequence of execution that belongs to a specific device, independent from other streams. It supports with statement as a context manager to ensure the operators within the with block are running on the corresponding stream. See the CUDA semantics documentation for details.
- Parameters:
device (tensorplay.Device or int, optional) – a device on which to allocate the stream. If
deviceisNone(default) or a negative integer, this will use the current device.priority (int, optional) – priority of the stream, which can be positive, 0, or negative. A lower number indicates a higher priority. By default, the priority is set to 0.
- record_event(event: Event | None = None)[source]
Record an event.
- Parameters:
event (Event, optional) – event to record. If not given, a new one will be allocated.
- Returns:
Recorded event.

