put_(index, source, accumulate=False) → Tensor¶
Copies the elements from
sourceinto the positions specified by
index. For the purpose of indexing, the
selftensor is treated as if it were a 1-D tensor.
sourceneed to have the same number of elements, but not necessarily the same shape.
True, the elements in
sourceare added to
self. If accumulate is
False, the behavior is undefined if
indexcontain duplicate elements.
>>> src = torch.tensor([[4, 3, 5], ... [6, 7, 8]]) >>> src.put_(torch.tensor([1, 3]), torch.tensor([9, 10])) tensor([[ 4, 9, 5], [ 10, 7, 8]])