torch.as_strided_scatter#
- torch.as_strided_scatter(input, src, size, stride, storage_offset=None) Tensor#
Embeds the values of the
srctensor intoinputalong the elements corresponding to the result of calling input.as_strided(size, stride, storage_offset).This function returns a tensor with fresh storage; it does not return a view.
- Parameters:
Note
srcmust be of the proper size in order to be embedded intoinput. Specifically, it should have the same shape as torch.as_strided(input, size, stride, storage_offset)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.]])