When the index is a 1-d tensor by itself, it seems advanced indexing get triggered and we only get a copy:
x = torch.rand(4,3)
print x
x[1].add_(3)
print x
x[torch.LongTensor(1).random_(4)].add_(3)
print x
We get:
0.0500 0.7517 0.7858
0.3007 0.8665 0.8264
0.5933 0.3438 0.8359
0.6214 0.4772 0.1589
[torch.FloatTensor of size 4x3]
0.0500 0.7517 0.7858
3.3007 3.8665 3.8264
0.5933 0.3438 0.8359
0.6214 0.4772 0.1589
[torch.FloatTensor of size 4x3]
0.0500 0.7517 0.7858
3.3007 3.8665 3.8264
0.5933 0.3438 0.8359
0.6214 0.4772 0.1589
[torch.FloatTensor of size 4x3]
Is it possible to update only selected row/column?
Thank you!