[Pytorch Profiler] Introduce scopes to enableProfiler (#62417)
authorKimish Patel <kimishpatel@fb.com>
Sat, 14 Aug 2021 04:37:57 +0000 (21:37 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Sat, 14 Aug 2021 04:40:15 +0000 (21:40 -0700)
commit1b04d99f554f0d2ec2653e78ba74ef9bb8b38602
tree674cc4322ebc1d47caa88335a3e268268651563c
parentb00afe135d50a325eb01fec0c573562f13bb9860
[Pytorch Profiler] Introduce scopes to enableProfiler (#62417)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/62417

This diff adds an option to make enableProfiler enable callbacks only
for certain RecordScopes.
Why?
Profiling has some overhead when we repeatedly execute callbacks for
alls copes. On mobile side when we often have small quantized models
this overhead can be large. We observed that by only profiling top level
op and skipping profiling of other atend ops called within we can limit
this overhead. For example, instead of profling at::conv2d -> at::convolution ->
at::convolution_ and further more if ops like transpose etc. are called,
skipping profiling of those. Of course this limits the visibility, but
at the least this way we get a choice.

Test Plan: Imported from OSS

Reviewed By: ilia-cher

Differential Revision: D29993659

fbshipit-source-id: 852d3ae7822f0d94dc6e507bd4019b60d488ef69
test/cpp/jit/test_misc.cpp
torch/csrc/autograd/init.cpp
torch/csrc/autograd/profiler_kineto.cpp
torch/csrc/autograd/profiler_kineto.h