Refactorings to prepare for overwritable kernels (#19776)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19776
The diff stacked on top of this enables overwriting of kernels, but before that, we need to do some refactorings.
This diff:
- hides deregistration logic behind a RAII class so we can keep more information about what exactly to deregister without the API user knowing about it.
- Split KernelRegistration from SchemaRegistration by taking Dispatcher::OperatorDef and moving it to a different file. This is better readable, especially since kernel registration will become more complex in the next diff.
- Move LeftRight synchronization out of DispatchTable to Operator because there will be a mutex added to Operator in the next diff and related synchronization primitives shouldn't live on different abstraction levels.
Reviewed By: dzhulgakov
Differential Revision: D15090322
fbshipit-source-id: 2e51a192075163f0d496956d9e54b9aaf26b2369