Skip to content
class

OpEvent

OpEvent(impl: _C_engine.OpEvent)

A single recorded event captured by the profiler.

An OpEvent is one op the engine dispatched, or backward work: a whole backward pass ("backward") or one node of it, named after the node ("MulBackward", "AccumulateGrad") — which backward tells apart. Each carries a name, wall-clock duration, shape, an FLOP estimate and the net memory delta. Profilers expose lists of these events so that per-op cost can be aggregated, exported, and visualised.

Parameters

implobject
Underlying engine OpEvent handle returned from the C++ profiler.

Notes

Durations are reported in nanoseconds at the source; helper properties expose the same value in microseconds and milliseconds for convenience.

Examples

>>> import lucid
>>> with lucid.profiler.profile() as prof:
...     y = lucid.randn(64, 64) @ lucid.randn(64, 64)
>>> [ev.name for ev in prof.events()]
['randn', 'randn', 'matmul']
>>> all(ev.time_us >= 0.0 for ev in prof.events())   # timings vary run to run
True

Used by 1

Constructors

1
dunder

__init__

→None
__init__(impl: _C_engine.OpEvent)

Initialise the instance. See the class docstring for parameter semantics.

Properties

8
prop

backward

→bool
backward: bool

Whether the event is backward work — a backward pass or one node of it — rather than a dispatched op. A node's shape is its gradient's element count: an eager gradient carries no shape of its own.

prop

flops

→int
flops: int

Estimated FLOPs for this operation.

prop

memory_delta_bytes

→int
memory_delta_bytes: int

Net memory allocated by this operation in bytes.

prop

name

→str
name: str

Operation name (e.g. 'matmul', 'add').

prop

shape

→list[int]
shape: list[int]

Output tensor shape.

prop

time_ms

→float
time_ms: float

Wall-clock duration in milliseconds.

prop

time_ns

→int
time_ns: int

Wall-clock duration of the operation in nanoseconds.

prop

time_us

→float
time_us: float

Wall-clock duration in microseconds.

Dunder methods

1
dunder

__repr__

→str
__repr__()

Return a developer-facing string representation of the instance.