Writes all values from the tensor into at the indices
specified in the tensor. For each value in , its output
index is specified by its index in for and by
the corresponding value in for .
src
self
index
src
src
dimension!=dim
index
dimension=dim
For a 3-D tensor, self is updated as:
self[index[i][j][k]][j][k]=src[i][j][k]# if dim == 0self[i][index[i][j][k]][k]=src[i][j][k]# if dim == 1self[i][j][index[i][j][k]]=src[i][j][k]# if dim == 2
This is the reverse operation of the manner described in gather().
It is also required that
index.size(d)<=src.size(d) for all dimensions d, and that
index.size(d)<=self.size(d) for all dimensions d!=dim.
Note that input and index do not broadcast against each other for NPUs,
so when running on NPUs, input and index must have the same number of dimensions.
Standard broadcasting occurs in all other cases.
Moreover, as for gather(), the values of index must be
between 0 and self.size(dim)-1 inclusive.
Additionally accepts an optional reduce argument that allows
specification of an optional reduction operation, which is applied to all
values in the tensor src into self at the indices
specified in the index. For each value in src, the reduction
operation is applied to an index in self which is specified by
its index in src for dimension!=dim and by the corresponding
value in index for dimension=dim.
Given a 3-D tensor and reduction using the multiplication operation, self
is updated as:
self[index[i][j][k]][j][k]*=src[i][j][k]# if dim == 0self[i][index[i][j][k]][k]*=src[i][j][k]# if dim == 1self[i][j][index[i][j][k]]*=src[i][j][k]# if dim == 2
Reducing with the addition operation is the same as using
scatter_add_().
index (LongTensor) – the indices of elements to scatter, can be either empty
or of the same dimensionality as src. When empty, the operation
returns self unchanged.
Writes the value from value into self at the indices
specified in the index tensor. This operation is equivalent to the previous version,
with the src tensor filled entirely with value.
index (LongTensor) – the indices of elements to scatter, can be either empty
or of the same dimensionality as src. When empty, the operation
returns self unchanged.
value (Scalar) – the value to scatter.
Keyword Arguments:
reduce (str, optional) – reduction operation to apply, can be either
'add' or 'multiply'.