pytorch
8dfff8b2 - Fix scatter for empty indexes (#70662)

Commit
4 years ago
Fix scatter for empty indexes (#70662) Summary: This PR fixes an issue with `scatter` where the output is garbage for zero-sized indexes. ```py import torch null_index = torch.zeros((0, 4), dtype=torch.int64) null_arr = torch.zeros((0, 4)) zeros_arr = torch.zeros((1, 4)) result = zeros_arr.scatter(0, null_index, null_arr) print(null_index) print(null_arr) print(zeros_arr) print(result) ``` ``` tensor([], size=(0, 4), dtype=torch.int64) tensor([], size=(0, 4)) tensor([[0., 0., 0., 0.]]) tensor([[1.7036e+19, 2.9965e+32, 3.9133e-14, 1.3585e-19]]) ``` the out array is never filled if `index` arg has 0 elements. Pull Request resolved: https://github.com/pytorch/pytorch/pull/70662 Reviewed By: dagitses Differential Revision: D33476807 Pulled By: albanD fbshipit-source-id: 97dbdd9c0133899e58828c43ecba81838807b8af
Author
Emilio Castillo
Parents
Loading