(self, dispatchKeys)
| 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). |
no outgoing calls