Move outplace ops to ATen (#16788)

Summary:
Based on https://github.com/pytorch/pytorch/pull/12413, with the following additional changes:

-  Inside `native_functions.yml` move those outplace operators right next to everyone's corresponding inplace operators for convenience of checking if they match when reviewing
- `matches_jit_signature: True` for them
- Add missing `scatter` with Scalar source
- Add missing `masked_fill` and `index_fill` with Tensor source.
- Add missing test for `scatter` with Scalar source
- Add missing test for `masked_fill` and `index_fill` with Tensor source by checking the gradient w.r.t source
- Add missing docs to `tensor.rst`

Differential Revision: D14069925

Pulled By: ezyang

fbshipit-source-id: bb3f0cb51cf6b756788dc4955667fead6e8796e5
This commit is contained in:
Xiang Gao
2019-02-15 15:54:50 -08:00
committed by Facebook Github Bot
parent 5737c5259c
commit 4fcab92d6c
12 changed files with 218 additions and 59 deletions

View File

@ -2963,6 +2963,55 @@ pinverse() -> Tensor
See :func:`torch.pinverse`
""")
add_docstr_all('index_add',
r"""
index_add(dim, index, tensor) -> Tensor
Out-of-place version of :meth:`torch.Tensor.index_add_`
""")
add_docstr_all('index_copy',
r"""
index_copy(dim, index, tensor) -> Tensor
Out-of-place version of :meth:`torch.Tensor.index_copy_`
""")
add_docstr_all('index_fill',
r"""
index_fill(dim, index, value) -> Tensor
Out-of-place version of :meth:`torch.Tensor.index_fill_`
""")
add_docstr_all('scatter',
r"""
scatter(dim, index, source) -> Tensor
Out-of-place version of :meth:`torch.Tensor.scatter_`
""")
add_docstr_all('scatter_add',
r"""
scatter_add(dim, index, source) -> Tensor
Out-of-place version of :meth:`torch.Tensor.scatter_add_`
""")
add_docstr_all('masked_scatter',
r"""
masked_scatter(mask, tensor) -> Tensor
Out-of-place version of :meth:`torch.Tensor.masked_scatter_`
""")
add_docstr_all('masked_fill',
r"""
masked_fill(mask, value) -> Tensor
Out-of-place version of :meth:`torch.Tensor.masked_fill_`
""")
add_docstr_all('grad',
r"""
This attribute is ``None`` by default and becomes a Tensor the first time a call to