Stream

class paddle.device. Stream ( device=None, priority=2, stream_base=None ) [source]

A device stream wrapper around StreamBase. :param device: Which device the stream runn on. If device is None, the device is the current device. Default: None.

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream, line 3)

Unexpected indentation.

It can be gpu, gpu:x,``custom_device``, custom_device:x, where custom_device is the name of CustomDevicec, where x is the index of the GPUs, XPUs. And it can be paddle.CUDAPlace(n) or paddle.CustomPlace(n).

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream, line 5)

Block quote ends without a blank line; unexpected unindent.

Parameters

priority (int, optional) – priority of the CUDA stream. Can be either 1 (high priority) or 2 (low priority). By default, streams have priority 2.

Returns

The stream.

Return type

Stream

Examples

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream, line 16)

Error in “code-block” directive: maximum 1 argument(s) allowed, 6 supplied.

.. code-block:: python
    # required: custom_device
    import paddle

    paddle.set_device('custom_cpu')
    s1 = paddle.device.Stream()
    s2 = paddle.device.Stream('custom_cpu')
    s3 = paddle.device.Stream('custom_cpu:0')
    s4 = paddle.device.Stream(paddle.CustomPlace('custom_cpu', 0))

wait_event ( event )

wait_event

Makes all future work submitted to the stream wait for an event. :param event: an event to wait for. :type event: Event

Returns

None.

Examples

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream.wait_event, line 9)

Error in “code-block” directive: maximum 1 argument(s) allowed, 6 supplied.

.. code-block:: python
    # required: custom_device
    import paddle

    paddle.set_device('custom_cpu')
    s1 = paddle.device.Stream()
    s2 = paddle.device.Stream()
    e = paddle.device.Event()
    e.record(s1)
    s2.wait_event(e)
wait_stream ( stream )

wait_stream

Synchronizes with another stream. All future work submitted to this stream will wait until all kernels submitted to a given stream at the time of call complete. :param stream: a stream to synchronize. :type stream: Stream

Returns

None.

Examples

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream.wait_stream, line 11)

Error in “code-block” directive: maximum 1 argument(s) allowed, 6 supplied.

.. code-block:: python
    # required: custom_device
    import paddle

    paddle.set_device('custom_cpu')
    s1 = paddle.device.Stream()
    s2 = paddle.device.Stream()
    s1.wait_stream(s2)
record_event ( event=None )

record_event

Records an event. :param event: event to record. If not given, a new one

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream.record_event, line 3)

Unexpected indentation.

will be allocated.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream.record_event, line 4)

Block quote ends without a blank line; unexpected unindent.

Returns

Recorded event.

Return type

Event

Examples

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream.record_event, line 11)

Error in “code-block” directive: maximum 1 argument(s) allowed, 6 supplied.

.. code-block:: python
    # required: custom_device
    import paddle

    paddle.set_device('custom_cpu')
    s = paddle.device.Stream()
    e1 = s.record_event()

    e2 = paddle.device.Event()
    s.record_event(e2)
query ( )

query

Checks if all the work submitted has been completed. :returns: Whether all kernels in this stream are completed. :rtype: bool

Examples

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream.query, line 7)

Error in “code-block” directive: maximum 1 argument(s) allowed, 6 supplied.

.. code-block:: python
    # required: custom_device
    import paddle

    paddle.set_device('custom_cpu')
    s = paddle.device.Stream()
    s.query()
synchronize ( ) [source]

synchronize

Wait for all the kernels in this stream to complete. :returns: None.

Examples

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Stream.synchronize, line 6)

Error in “code-block” directive: maximum 1 argument(s) allowed, 6 supplied.

.. code-block:: python
    # required: custom_device
    import paddle

    paddle.set_device('custom_cpu')
    s = paddle.device.Stream()
    s.synchronize()