Skip to content

Commit 77665e9

Browse files
chaekitpytorchmergebot
authored andcommitted
[kineto] ClientInterface stub for ProfilerKineto (#75525)
Summary: Pull Request resolved: #75525 Creating injection point for ProfilerKineto to attach global callback. We'll disable the KinetoObserver via `'kineto.disable_libkineto_observer=1'` and enable this to swap out the implementations. Test Plan: 1. add temporary logs in the stub + registration method 2. `buck build mode/opt //kineto/libkineto/fb/integration_tests:trace_tester --config 'kineto.disable_libkineto_observer=1' --config "kineto.enable_libkineto_client=1` 3. `./buck-out/gen/kineto/libkineto/fb/integration_tests/trace_tester --test_ondemand --libkineto_runner_iterations 1000000` should see log for registration 4. `dyno gputrace` should see log for start/stop Reviewed By: aaronenyeshi, robieta Differential Revision: D35456304 fbshipit-source-id: c0a23a57181818e5a0ee495410163d90874355a9 (cherry picked from commit 5dfc723)
1 parent aa51704 commit 77665e9

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tools/build_variables.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ libtorch_profiler_sources = [
163163
"torch/csrc/profiler/collection.cpp",
164164
"torch/csrc/profiler/kineto_shim.cpp",
165165
"torch/csrc/profiler/nvtx_observer.cpp",
166+
"torch/csrc/profiler/kineto_client_interface.cpp",
166167
"torch/csrc/monitor/counters.cpp",
167168
"torch/csrc/monitor/events.cpp",
168169
]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#ifdef USE_KINETO
2+
#include <libkineto.h>
3+
4+
namespace torch {
5+
namespace profiler {
6+
namespace impl {
7+
8+
namespace {
9+
10+
class LibKinetoClient : public libkineto::ClientInterface {
11+
public:
12+
void init() override {
13+
// TODO: implement
14+
}
15+
16+
void warmup(bool setupOpInputsCollection) override {
17+
// TODO: implement
18+
}
19+
20+
void start() override {
21+
// TODO: implement
22+
}
23+
24+
void stop() override {
25+
// TODO: implement
26+
}
27+
};
28+
29+
} // namespace
30+
31+
32+
} // namespace impl
33+
} // namespace profiler
34+
35+
#ifdef ENABLE_LIBKINETO_CLIENT
36+
struct RegisterLibKinetoClient {
37+
RegisterLibKinetoClient() {
38+
static profiler::impl::LibKinetoClient client;
39+
libkineto::api().registerClient(&client);
40+
}
41+
} register_libkineto_client;
42+
#endif // ENABLE_LIBKINETO_CLIENT
43+
44+
} // namespace torch
45+
#endif // USE_KINETO

0 commit comments

Comments
 (0)