# ExternalStream

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

# ExternalStream

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

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](https://docs.python.org/3/library/functions.html#int)) – Integer representation of the cudaStream_t value allocated externally.

- device ([tensorplay.Device](tensorplay.Device.html#tensorplay.Device) or [int](https://docs.python.org/3/library/functions.html#int) , optional ) – the device where the stream was originally allocated. If device is specified incorrectly, subsequent launches using this stream may fail.

query() &#x2192; [bool](https://docs.python.org/3/library/functions.html#bool)

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)

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)

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)

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

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

Synchronize with another stream.
