pytorch/tools/codegen/api
Meghan Lele 968d7ee46a [structured] Preserve computed elements from meta func to impl (#61746)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/61746

**Summary**
This commit introduces a new feature for structured kernels that allows
kernels to declare quantities as "precomputed" in
`native_functions.yaml`, compute them once in the `meta` function and
reuse them again in the `impl`. The names and types of these quantities
are used to generate code for a struct containing them that the `meta`
function must return. In the case of a handful of surveyed kernels
(`all,`, `any`, `avg_pool2d`), these quantities that are used both in
the `meta` and `impl` have the same meaning as certain kernel arguments
and in fact supersede them. Accordingly, the correspondence between a
kernel argument and the precomputed elements that supersede it is also
captured in `native_functions.yaml`. This information is used to unpack
the struct returned by `meta` and pass its contents correctly to the
`impl` function.

The primary goal is to avoid recompute and enhance developer experience
(e.g. sometimes people can forget to compute these elements while
porting a kernel).

Test Plan: Imported from OSS

Reviewed By: tugsbayasgalan

Differential Revision: D30407831

Pulled By: SplitInfinity

fbshipit-source-id: 00975525ea373721fe52d06f75cd4ac91f3dc556
2021-09-01 14:34:25 -07:00
..
__init__.py
autograd.py [reland] Refactor Tensor::to to call a primitive that is not copy_. (#62262) 2021-07-29 10:49:32 -07:00
cpp.py Reland of "D27708346: generate xla codegen in-tree" (#56601) 2021-04-21 19:36:31 -07:00
dispatcher.py Reland of "D27708346: generate xla codegen in-tree" (#56601) 2021-04-21 19:36:31 -07:00
meta.py Un-ignore F403 in .flake8 (#55838) 2021-04-13 09:24:07 -07:00
native.py [PyTorch] Fix const correctness for resize native functions (#55351) 2021-04-21 14:51:41 -07:00
python.py Add an optional Device parameter to pin_memory/is_pinned that does nothing (#60201) 2021-06-28 10:38:52 -07:00
structured.py [structured] Preserve computed elements from meta func to impl (#61746) 2021-09-01 14:34:25 -07:00
translate.py clamp: port to structured kernel (#61361) 2021-07-23 02:02:07 -07:00
types.py clamp: port to structured kernel (#61361) 2021-07-23 02:02:07 -07:00