pytorch/tools/codegen/api
Edward Yang 37bf6c134b Register DefaultBackend implementations for functional/inplace structured operators (#53037)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/53037

As remarked in #52277 it is easy to give an (inefficient, due to extra
redispatches) DefaultBackend implementation of foo and foo_ in terms of
foo_out.  This patch enables code generation for DefaultBackend in these
cases by default for all structured kernels.  You can see the payoff
in MSNPU extension: it only has to register a kernel for add.out, and it
gets add and add_ kernels automatically.

The actual code changes are very modest:
- When DefaultBackend, call the dispatched (not direct native::)
  functions to allocate tensors, change device guard, etc
- Don't call impl() for DefaultBackend (as it doesn't exist); instead,
  directly generate a call to at::foo_out to do the actual work.
- Do NOT generate DefaultBackend implementation for foo_out.  Actually,
  there is a case to be made for this being a good idea with more infra;
  see comments inside.

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

Test Plan: Imported from OSS

Reviewed By: bdhirsh

Differential Revision: D26731225

Pulled By: ezyang

fbshipit-source-id: 939da7cb69f694722ec293e5e42e74a755dd0985
2021-03-02 14:13:08 -08:00
..
__init__.py Rewrite of ATen code generator (#42629) 2020-08-31 09:00:22 -07:00
autograd.py [pytorch][codegen] migrate gen_variable_type to new data model (#49735) 2021-01-05 14:12:39 -08:00
cpp.py [PyTorch] Pass TensorOptions by value (#51165) 2021-02-01 12:40:08 -08:00
dispatcher.py Remove codegen logic to support non-c10-full ops (#49164) 2021-01-06 14:17:36 -08:00
meta.py Introduce tools.codegen.api.translate (#49122) 2020-12-16 16:18:40 -08:00
native.py [pytorch] fix ConstRefCType usage in codegen/api/native.py (#50742) 2021-01-20 15:01:37 -08:00
python.py Remove codegen logic to support non-c10-full ops (#49164) 2021-01-06 14:17:36 -08:00
structured.py Add api.structured; switch structured kernels to use const Tensor& everywhere (#51490) 2021-02-03 14:03:46 -08:00
translate.py Fix minor inaccuracy in translate error reporting (#53032) 2021-03-02 14:11:28 -08:00
types.py Register DefaultBackend implementations for functional/inplace structured operators (#53037) 2021-03-02 14:13:08 -08:00