2
PyTorch Profiler is a tool that allows the collection of performance metrics during training and inference.
3
Profiler's context manager API can be used to better understand what model operators are the most expensive,
4
examine their input shapes and stack traces, study device kernel activity and visualize the execution trace.
7
An earlier version of the API in :mod:`torch.autograd` module is considered legacy and will be deprecated.
12
from torch._C._autograd import _supported_activities, DeviceType, kineto_available
13
from torch._C._profiler import _ExperimentalConfig, ProfilerActivity, RecordScope
14
from torch.autograd.profiler import KinetoStepTracker, record_function
15
from torch.optim.optimizer import register_optimizer_step_post_hook
17
from .profiler import (
19
ExecutionTraceObserver,
24
tensorboard_trace_handler,
30
"supported_activities",
31
"tensorboard_trace_handler",
37
"ExecutionTraceObserver",
43
def _optimizer_post_hook(optimizer, args, kwargs):
44
KinetoStepTracker.increment_step("Optimizer")
47
if os.environ.get("KINETO_USE_DAEMON", None):
48
_ = register_optimizer_step_post_hook(_optimizer_post_hook)