Where is torch::autograd::profiler?

I am using libtorch, c++ frontend, downloaded from the main page of https://pytorch.org/ and trying to profile layer by layer.

I’ve learn that in python i can use torch.autograd.profiler.profile. And i’ve read some website, including https://github.com/pytorch/pytorch/pull/16580/files#diff-81d29c29bbf9fb05edfa7fd70d189374 and https://caffe2.ai/doxygen-c/html/structtorch_1_1autograd_1_1profiler_1_1_record_profile.html

But when i use CLion to construct my code, use torch::autograd::profiler::RecordProfile , it report an error that

no member named ‘profiler’ in namespace 'torch::autograd

I turned to https://pytorch.org/cppdocs/api/library_root.html, and cannot find something about profiler, so how should i do to use the profiler in my project?

You can include torch/csrc/autograd/profiler.h. I’m not entirely sure of the stability guarantee of the things in torch/csrc/, but it is in the distribution.

Best regards


Thanks for you reply, but now i have some question about the fields that displayed by profiler, since they are different from the python document.

  "name": "size",
  "ph": "X",
  "ts": 236152.000000,
  "dur": 1.000000,
  "tid": 0,
  "pid": "CPU Functions",
  "args": {}

What’s the meaning of ph, ts, dur and tid, and how should i explain their value?