MCPcopy Create free account
hub / github.com/pytorch/pytorch / register

Method register

torch/_python_dispatcher.py:93–112  ·  view source on GitHub ↗
(self, dispatchKeys)

Source from the content-addressed store, hash-verified

91 """
92
93 def register(self, dispatchKeys):
94 # Overriden is not supported and triggers a warning in C++ dispatcher.
95 if len(set(dispatchKeys)) != len(dispatchKeys):
96 raise RuntimeError(
97 f"Overriden is not allowed but found duplicates in {dispatchKeys}."
98 )
99 # We currently forbid this in codegen instead of C++ dispatcher.
100 if (
101 "CompositeImplicitAutograd" in dispatchKeys
102 and "CompositeExplicitAutograd" in dispatchKeys
103 ):
104 raise RuntimeError(
105 "Registration to both CompositeImplicitAutograd and CompositeExplicitAutograd is not allowed."
106 )
107 for key in dispatchKeys:
108 if key not in self.supported_keys:
109 raise RuntimeError(
110 f"{key} is not supported, please select a dispatch key in {self.supported_keys}."
111 )
112 self.ref.impl_t_t("foo", dispatch=key, debug="fn_" + key)
113
114 """
115 Helper function to format (key, kernel).

Callers 6

test_basicMethod · 0.95
test_math_autogradcpuMethod · 0.95
test_autogradotherMethod · 0.95

Calls

no outgoing calls

Tested by 6

test_basicMethod · 0.76
test_math_autogradcpuMethod · 0.76
test_autogradotherMethod · 0.76