File: privateuse1_observer.h

package info (click to toggle)
pytorch-cuda 2.6.0%2Bdfsg-7
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid, trixie
  • size: 161,620 kB
  • sloc: python: 1,278,832; cpp: 900,322; ansic: 82,710; asm: 7,754; java: 3,363; sh: 2,811; javascript: 2,443; makefile: 597; ruby: 195; xml: 84; objc: 68
file content (46 lines) | stat: -rw-r--r-- 1,445 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <torch/csrc/profiler/api.h>

namespace torch::profiler::impl {

using CallBackFnPtr = void (*)(
    const ProfilerConfig& config,
    const std::unordered_set<at::RecordScope>& scopes);

struct PushPRIVATEUSE1CallbacksStub {
  PushPRIVATEUSE1CallbacksStub() = default;
  PushPRIVATEUSE1CallbacksStub(const PushPRIVATEUSE1CallbacksStub&) = delete;
  PushPRIVATEUSE1CallbacksStub& operator=(const PushPRIVATEUSE1CallbacksStub&) =
      delete;
  PushPRIVATEUSE1CallbacksStub(PushPRIVATEUSE1CallbacksStub&&) = default;
  PushPRIVATEUSE1CallbacksStub& operator=(PushPRIVATEUSE1CallbacksStub&&) =
      default;
  ~PushPRIVATEUSE1CallbacksStub() = default;

  template <typename... ArgTypes>
  void operator()(ArgTypes&&... args) {
    return (*push_privateuse1_callbacks_fn)(std::forward<ArgTypes>(args)...);
  }

  void set_privateuse1_dispatch_ptr(CallBackFnPtr fn_ptr) {
    push_privateuse1_callbacks_fn = fn_ptr;
  }

 private:
  CallBackFnPtr push_privateuse1_callbacks_fn = nullptr;
};

extern TORCH_API struct PushPRIVATEUSE1CallbacksStub
    pushPRIVATEUSE1CallbacksStub;

struct RegisterPRIVATEUSE1Observer {
  RegisterPRIVATEUSE1Observer(
      PushPRIVATEUSE1CallbacksStub& stub,
      CallBackFnPtr value) {
    stub.set_privateuse1_dispatch_ptr(value);
  }
};

#define REGISTER_PRIVATEUSE1_OBSERVER(name, fn) \
  static RegisterPRIVATEUSE1Observer name##__register(name, fn);
} // namespace torch::profiler::impl