RecordEvent

class paddle.profiler. RecordEvent ( name: str, event_type: paddle.fluid.libpaddle.TracerEventType = <TracerEventType.PythonUserDefined: 14> ) [source]

Interface for recording a time range by user defined.

Parameters
  • name (str) – Name of the record event.

  • event_type (TracerEventType, optional) – Optional, default value is TracerEventType.PythonUserDefined. It is reserved for internal purpose, and it is better not to specify this parameter.

Examples

import paddle
import paddle.profiler as profiler
# method1: using context manager
with profiler.RecordEvent("record_add"):
    data1 = paddle.randn(shape=[3])
    data2 = paddle.randn(shape=[3])
    result = data1 + data2
# method2: call begin() and end()
record_event = profiler.RecordEvent("record_add")
record_event.begin()
data1 = paddle.randn(shape=[3])
data2 = paddle.randn(shape=[3])
result = data1 + data2
record_event.end()

Note

RecordEvent will take effect only when Profiler is on and at the state of RECORD.

begin ( )

begin

Record the time of beginning.

Examples

import paddle
import paddle.profiler as profiler
record_event = profiler.RecordEvent("record_sub")
record_event.begin()
data1 = paddle.randn(shape=[3])
data2 = paddle.randn(shape=[3])
result = data1 - data2
record_event.end()
end ( )

end

Record the time of ending.

Examples

import paddle
import paddle.profiler as profiler
record_event = profiler.RecordEvent("record_mul")
record_event.begin()
data1 = paddle.randn(shape=[3])
data2 = paddle.randn(shape=[3])
result = data1 * data2
record_event.end()