pytorch/test/cpp_extensions
Edward Yang 2db61193bb Add DispatchKey impl overload; remove use of torch::dispatch (#35706)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35706

It is extremely common to define implementations of operators at a
specific dispatch key, so we add an overload to impl specifically for
this case.  I then delete most uses of torch::dispatch

dispatch_autograd call sites can't make use of this overload.  So
instead the new preferred way to specify something as autograd is to
pass kAutograd as the dispatch key (short form, analogous to kCPU/kCUDA
which we support today).

I flip flopped about whether or not kAutograd should have the type
DispatchKey or some other type (to help better encapsulate the
DispatchKey enum); this is more direct and I can't think of any
BC problems from this usage.

Some other reorganization I did:
- I renamed all of the worker functions in op_registration to have
  a leading underscore and made them private, just to make it more
  clear what the public versus private API were (the private API
  shouldn't be used by users because it doesn't come with && overloads)
- In a few places where I was touching lines already, I replaced
  full DispatchKey typed out enums with shorter kFoo names, similar
  to kAutograd but I didn't publish these globally.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Test Plan: Imported from OSS

Differential Revision: D20775783

Pulled By: ezyang

fbshipit-source-id: e45b289e5d1f86c180b24cf14c63cf4459ab5337
2020-04-02 08:51:22 -07:00
..
no_python_abi_suffix_test
torch_test_cpp_extension
cpp_frontend_extension.cpp Better tests/support for Python/C++ inter-op (#15193) 2018-12-14 08:42:10 -08:00
cuda_extension_kernel.cu
cuda_extension_kernel2.cu
cuda_extension.cpp Deprecate tensor.type() (#30281) 2019-12-05 10:55:34 -08:00
cuda_extension.cu
cudnn_extension.cpp
doubler.h
extension.cpp
jit_extension.cpp
jit_extension2.cpp
msnpu_extension.cpp Add DispatchKey impl overload; remove use of torch::dispatch (#35706) 2020-04-02 08:51:22 -07:00
rng_extension.cpp pybind11 type_caster for at::Generator and custom RNG python test (#34774) 2020-03-22 10:57:35 -07:00
setup.py pybind11 type_caster for at::Generator and custom RNG python test (#34774) 2020-03-22 10:57:35 -07:00