torch.as_strided_scatter
- torch.as_strided_scatter(input, src, size, stride, storage_offset=None) → Tensor
Embeds the values of the
tensor into along the elements corresponding to the result of calling input.as_strided(size, stride, storage_offset).
Embeds the values of the tensor into along
the elements corresponding to the result of calling
input.as_strided(size, stride, storage_offset).
inputThis function returns a tensor with fresh storage; it does not return a view.
Example:
>>> a = torch.arange(4).reshape(2, 2) + 1
>>> a
tensor([[1, 2],
[3, 4]])
>>> b = torch.zeros(3, 3)
>>> b
tensor([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]])
>>> torch.as_strided_scatter(b, a, (2, 2), (1, 2))
tensor([[1., 3., 2.],
[4., 0., 0.],
[0., 0., 0.]])