pytorch/tools/codegen/api
Meghan Lele 1c80b5220b nll_loss_forward: port to structured kernel (#61443)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/61443

For more information, see #55070.

This PR also adds a new type, `OptionalTensorRef` as a replacement for `c10::optional<Tensor>&` in order to avoid the reference count manipulations that are inevitable with the latter. I have confirmed using Godbolt/Compiler Explorer that this class does indeed avoid manipulating the reference count of the `intrusive_ptr` inside the `Tensor` it refers to:

1. [P429709479](https://www.internalfb.com/phabricator/paste/view/P429709479) - Given a `const Tensor&` in scope, an `OptionalTensorRef` can be constructed without bumping refcount.
2. [P429709883](https://www.internalfb.com/phabricator/paste/view/P429709883) - Given an `OptionalTensorRef`, a `const Tensor&` can be produced without bumping refcount.
3. [P429710335](https://www.internalfb.com/phabricator/paste/view/P429710335) - When `OptionalTensorRef` is destructed, the refcount should not be decremented.
4. [P429769525](https://www.internalfb.com/phabricator/paste/view/P429769525) - `OptionalTensorRef` can be assigned without refcount manipulation.
5. [P429769882](https://www.internalfb.com/phabricator/paste/view/P429769882) - `OptionalTensorRef` can be move assigned without refcount manipulation.

Test Plan: Imported from OSS

Reviewed By: jamesr66a

Differential Revision: D29780666

Pulled By: SplitInfinity

fbshipit-source-id: 7af157215300e9254d635433cbd583f7329fe064
2021-07-20 11:45:44 -07:00
..
__init__.py Rewrite of ATen code generator (#42629) 2020-08-31 09:00:22 -07:00
autograd.py Revert "Revert D28387764: Codegen inplace forward AD formula from out of place one if needed" (#58231) 2021-05-14 08:35:38 -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 nll_loss_forward: port to structured kernel (#61443) 2021-07-20 11:45:44 -07:00
translate.py nll_loss_forward: port to structured kernel (#61443) 2021-07-20 11:45:44 -07:00
types.py nll_loss_forward: port to structured kernel (#61443) 2021-07-20 11:45:44 -07:00