current_stream

paddle.device. current_stream ( device=None ) [source]

Return the current stream by the device.

Parameters

device (str|paddle.CUDAPlace(n)|paddle.CustomPlace(n)) – The device which want to get stream from. If device is None, the device is the current device. Default: None. It can be gpu, gpu:x, custom_device, custom_device:x, where custom_device is the name of CustomDevice, where x is the index of the GPUs, CustomDevices. And it can be paddle.CUDAPlace(n) or paddle.CustomPlace(n).

Returns

The stream to the device.

Return type

Stream

Examples

>>> 
>>> import paddle

>>> paddle.set_device('custom_cpu')
>>> s1 = paddle.device.current_stream()
>>> s2 = paddle.device.current_stream("custom_cpu:0")
>>> place = paddle.CustomPlace('custom_cpu', 0)
>>> s3 = paddle.device.current_stream(place)