1#include <sstream>
2
3#include <c10/util/irange.h>
4#include <torch/csrc/itt_wrapper.h>
5#include <torch/csrc/profiler/stubs/base.h>
6
7namespace torch {
8namespace profiler {
9namespace impl {
10namespace {
11
12struct ITTMethods : public ProfilerStubs {
13 void record(int* device, ProfilerEventStub* event, int64_t* cpu_ns)
14 const override {}
15
16 float elapsed(const ProfilerEventStub* event, const ProfilerEventStub* event2)
17 const override {
18 return 0;
19 }
20
21 void mark(const char* name) const override {
22 // NOLINTNEXTLINE(cppcoreguidelines-init-variables)
23 torch::profiler::itt_mark(name);
24 }
25
26 void rangePush(const char* name) const override {
27 // NOLINTNEXTLINE(cppcoreguidelines-init-variables)
28 torch::profiler::itt_range_push(name);
29 }
30
31 void rangePop() const override {
32 torch::profiler::itt_range_pop();
33 }
34
35 void onEachDevice(std::function<void(int)> op) const override {}
36
37 void synchronize() const override {}
38
39 bool enabled() const override {
40 return true;
41 }
42};
43
44struct RegisterITTMethods {
45 RegisterITTMethods() {
46 static ITTMethods methods;
47 registerITTMethods(&methods);
48 }
49};
50RegisterITTMethods reg;
51
52} // namespace
53} // namespace impl
54} // namespace profiler
55} // namespace torch
56