fn
record_function
→Iterator[None]record_function(name: str)Annotate an enclosing region with a name visible to the profiler.
Lets user code carve the trace into semantically meaningful regions
(e.g. "encoder", "decoder", "loss") alongside the
automatic per-op events. The hook is a no-op when no profiler is
active and when the engine does not yet support named regions, so
its presence is always safe.
Parameters
namestrLabel to associate with the enclosed block in the trace.
Notes
Intended placement is around coarse-grained phases — invoking it on every micro-op would inflate trace size without aiding analysis.
Examples
>>> import lucid
>>> with lucid.profiler.profile() as prof:
... with lucid.profiler.record_function("matmul-region"):
... y = lucid.randn(64, 64) @ lucid.randn(64, 64)