MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / DispatchKeySet

Class DispatchKeySet

paddle/phi/api/include/compat/c10/core/DispatchKeySet.h:54–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54class DispatchKeySet final {
55 public:
56 enum Full { FULL };
57 enum FullAfter { FULL_AFTER };
58 enum Raw { RAW };
59
60 constexpr DispatchKeySet() = default;
61
62 constexpr DispatchKeySet(Full /*unused*/)
63 : repr_((1ULL << (num_backends + num_functionality_keys - 1)) - 1) {}
64
65 constexpr DispatchKeySet(FullAfter /*unused*/, DispatchKey t)
66 : repr_((1ULL << (num_backends +
67 static_cast<uint8_t>(toFunctionalityKey(t)) - 1)) -
68 1) {
69 *this = add(DispatchKey::PythonDispatcher);
70 }
71
72 constexpr DispatchKeySet(Raw /*unused*/, uint64_t x) : repr_(x) {}
73
74 constexpr explicit DispatchKeySet(BackendComponent k) {
75 if (k == BackendComponent::InvalidBit) {
76 repr_ = 0;
77 } else {
78 repr_ = 1ULL << (static_cast<uint8_t>(k) - 1);
79 }
80 }
81
82 constexpr explicit DispatchKeySet(DispatchKey k) { // NOLINT
83 if (k == DispatchKey::Undefined) {
84 repr_ = 0;
85 } else if (k <= DispatchKey::EndOfFunctionalityKeys) {
86 uint64_t functionality_val =
87 1ULL << (num_backends + static_cast<uint8_t>(k) - 1);
88 repr_ = functionality_val;
89 } else if (k <= DispatchKey::EndOfRuntimeBackendKeys) {
90 auto functionality_k = toFunctionalityKey(k);
91 uint64_t functionality_val =
92 1ULL << (num_backends + static_cast<uint8_t>(functionality_k) - 1);
93
94 auto backend_k = toBackendComponent(k);
95 uint64_t backend_val = backend_k == BackendComponent::InvalidBit
96 ? 0
97 : 1ULL
98 << (static_cast<uint8_t>(backend_k) - 1);
99 repr_ = functionality_val + backend_val;
100 } else {
101 repr_ = 0;
102 }
103 }
104
105 constexpr uint64_t keys_to_repr(std::initializer_list<DispatchKey> ks) {
106 uint64_t repr = 0;
107 for (auto k : ks) {
108 repr |= DispatchKeySet(k).repr_;
109 }
110 return repr;
111 }

Callers 15

key_setMethod · 0.85
keys_to_reprMethod · 0.85
backend_bits_to_reprMethod · 0.85
hasMethod · 0.85
has_backendMethod · 0.85
has_anyMethod · 0.85
operator|Method · 0.85
operator&Method · 0.85
operator-Method · 0.85
operator^Method · 0.85
addMethod · 0.85
removeMethod · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68