# Stream

Source: https://www.tensorplay.cn/docs/generated/tensorplay.cuda.streams.Stream.html

# Stream

class tensorplay.cuda.streams.Stream(device=None, priority=0, **kwargs)[[source]](../_modules/tensorplay/cuda/streams.html#Stream)

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](tensorplay.Device.html#tensorplay.Device) or [int](https://docs.python.org/3/library/functions.html#int) , optional ) – a device on which to allocate the stream. If device is None (default) or a negative integer, this will use the current device.

- priority ([int](https://docs.python.org/3/library/functions.html#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.

query() &#x2192; [bool](https://docs.python.org/3/library/functions.html#bool)[[source]](../_modules/tensorplay/cuda/streams.html#Stream.query)

Check if all the work submitted has been completed.

record_event(event: [Event](tensorplay.cuda.streams.Event.html#tensorplay.cuda.streams.Event) | [None](https://docs.python.org/3/library/constants.html#None) = None)[[source]](../_modules/tensorplay/cuda/streams.html#Stream.record_event)

Record an event.

Parameters:

event ([Event](tensorplay.cuda.streams.Event.html#tensorplay.cuda.streams.Event), optional) – event to record. If not given, a new one
will be allocated.

Returns:

Recorded event.

synchronize() &#x2192; [None](https://docs.python.org/3/library/constants.html#None)[[source]](../_modules/tensorplay/cuda/streams.html#Stream.synchronize)

Wait for all the kernels in this stream to complete.

wait_event(event: [Event](tensorplay.cuda.streams.Event.html#tensorplay.cuda.streams.Event) | tensorplay.Event) &#x2192; [None](https://docs.python.org/3/library/constants.html#None)[[source]](../_modules/tensorplay/cuda/streams.html#Stream.wait_event)

Make all future work submitted to the stream wait for an event.

wait_stream(stream: [Stream](#tensorplay.cuda.streams.Stream)) &#x2192; [None](https://docs.python.org/3/library/constants.html#None)[[source]](../_modules/tensorplay/cuda/streams.html#Stream.wait_stream)

Synchronize with another stream.
