Skip to content

Document that autograd::Profiler::RecordFunction is available in Python #19422

@heiner

Description

@heiner

🚀 Feature

torch.autograd.profiler.profile().export_chrome_trace is great. Adding information to it from Python would make it even better.

Motivation

In multi-threaded PyTorch code, it can be useful to further annotate the tracing output by adding additional information to it.

Pitch

One easy / cheap way of doing this:

PYBIND11_MODULE(torch, m) {
  py::class_<torch::autograd::profiler::RecordFunction>(m, "Record")
      .def(py::init<std::string>(), py::arg("name"));
}

And then in Python

record = torch.Record("model")
outputs = model(frame)
del record  # Alternatively, turn it into a context manager.

Metadata

Metadata

Assignees

Labels

high prioritymodule: autogradRelated to torch.autograd, and the autograd engine in generalmodule: docsRelated to our documentation, both in docs/ and docblockssmallWe think this is a small issue to fix. Consider knocking off high priority small issuestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions