Event

class paddle.device. Event ( device=None, enable_timing=False, blocking=False, interprocess=False ) [source]

A device event 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.Event, 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.Event, line 5)

Block quote ends without a blank line; unexpected unindent.

Parameters
  • enable_timing (bool, optional) – indicates if the event should measure time, default is False

  • blocking (bool, optional) – if True, wait will be blocking, default is False

  • interprocess (bool) – if True, the event can be shared between processes, default is False

Returns

The event.

Return type

Event

Examples

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

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')
    e1 = paddle.device.Event()
    e2 = paddle.device.Event('custom_cpu')
    e3 = paddle.device.Event('custom_cpu:0')
    e4 = paddle.device.Event(paddle.CustomPlace('custom_cpu', 0))

record ( stream=None )

record

Records the event in a given stream. :param stream: The given stream. By default, stream is None, :type stream: Stream, optional :param event will be recorded in current_stream.:

Returns

None.

Examples

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

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')
    e = paddle.device.Event()
    e.record()

    s = paddle.device.Stream()
    e.record(s)
query ( )

query

Checks if all work currently captured by event has completed. :returns: Whether all work currently captured by event has completed. :rtype: bool

Examples

System Message: ERROR/3 (/usr/local/lib/python3.8/site-packages/paddle/device/__init__.py:docstring of paddle.device.Event.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')
    e = paddle.device.Event()
    e.record()
    e.query()
elapsed_time ( end_event )

elapsed_time

Returns the time elapsed in milliseconds after the event was recorded and before the end_event was recorded. :returns: The time. :rtype: int

Examples

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

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')
    e1 = paddle.device.Event()
    e1.record()

    e2 = paddle.device.Event()
    e2.record()
    e1.elapsed_time(e2)
synchronize ( ) [source]

synchronize

Waits for the event to complete. Waits until the completion of all work currently captured in this event. This prevents the CPU thread from proceeding until the event completes. :returns: None.

Examples

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

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')
    e = paddle.device.Event()
    e.record()
    e.synchronize()