Event¶
- class paddle.device. Event ( device=None, enable_timing=False, blocking=False, interprocess=False ) [source]
 - 
         
A device event wrapper around StreamBase.
- Parameters
 - 
           
device (str|paddle.CUDAPlace(n)|paddle.CustomPlace(n)) – Which device the stream runn on. If device is None, the device is the current device. Default: None. It can be
gpu,gpu:x,custom_device,custom_device:x, wherecustom_deviceis the name of CustomDevicec, wherexis the index of the GPUs, XPUs. And it can be paddle.CUDAPlace(n) or paddle.CustomPlace(n).enable_timing (bool, optional) – indicates if the event should measure time, default is False
blocking (bool, optional) – if True,
waitwill be blocking, default is Falseinterprocess (bool) – if True, the event can be shared between processes, default is False
 - Returns
 - 
           
The event.
 - Return type
 - 
           
Event
 
Examples
>>> >>> 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.
- Parameters
 - 
             
stream (Stream, optional) – The given stream. By default, stream is None,
current_stream. (event will be recorded in) –
 - Returns
 - 
             
None.
 
Examples
>>> >>> 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.
 - Return type
 - 
             
bool
 
Examples
>>> >>> 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.
 - Return type
 - 
             
int
 
Examples
>>> >>> 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
>>> >>> import paddle >>> paddle.set_device('custom_cpu') >>> e = paddle.device.Event() >>> e.record() >>> e.synchronize()
 
 
