[Pytorch Edge] Enable kineto profiler on mobile via EdgeKinetoProfiler (#62419)
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:19 +0000 (21:40 -0700)
commit38c185189c4e7b11f9bd9b60afed75b367ee00e2
treebf379af917c625be7dda9959039bacdaa04bcfcf
parent77a6436cac21e2569e298ba91d4ccd3118174f13
[Pytorch Edge] Enable kineto profiler on mobile via EdgeKinetoProfiler (#62419)

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

This diff adds support for cpu only kineto profiler on mobile. Thus
enabling chrome trace generation on mobile. This bring cpp API for
mobile profiling on part with Torchscript.
This is done via:
1. Utilizating debug handle annotations in KinetoEvent.
2. Adding post processing capability, via callbacks, to
KinetoThreadLocalState
3. Creating new RAII stype profiler, KinetoEdgeCPUProfiler, which can be
used in surrounding scope of model execution. This will write chrome
trace to the location specified in profiler constructor.

Test Plan:
MobileProfiler.ModuleHierarchy

Imported from OSS

Reviewed By: raziel

Differential Revision: D29993660

fbshipit-source-id: 0b44f52f9e9c5f5aff81ebbd9273c254c3c03299
24 files changed:
.jenkins/pytorch/build.sh
CMakeLists.txt
android/common.sh
android/pytorch_android/build.gradle
aten/src/ATen/record_function.h
caffe2/CMakeLists.txt
cmake/Dependencies.cmake
scripts/build_ios.sh
test/cpp/jit/test_backend.cpp
test/cpp/jit/test_lite_interpreter.cpp
test/cpp/jit/test_misc.cpp
test/cpp/lite_interpreter_runtime/CMakeLists.txt
test/cpp/lite_interpreter_runtime/test_lite_interpreter_runtime.cpp
test/cpp/lite_interpreter_runtime/test_mobile_profiler.cpp [new file with mode: 0644]
test/cpp/lite_interpreter_runtime/to_be_profiled_module.ptl [new file with mode: 0644]
tools/build_variables.bzl
torch/csrc/autograd/profiler_kineto.cpp
torch/csrc/autograd/profiler_kineto.h
torch/csrc/jit/mobile/debug_info.cpp
torch/csrc/jit/mobile/interpreter.cpp
torch/csrc/jit/mobile/module.cpp
torch/csrc/jit/mobile/module.h
torch/csrc/jit/mobile/profiler_edge.cpp [new file with mode: 0644]
torch/csrc/jit/mobile/profiler_edge.h [new file with mode: 0644]