ClikaRT::ops::scatter
function
scatter()
Tensor scatter(
Tensor x,
int64_t dim,
Tensor index,
ScalarOrTensor src
)
A copy of x with src written at positions given by index along dim, the write mirror of gather: out[index[p]][j][k] = src[p] for dim = 0 (only that axis's coordinate is redirected).
A scalar src broadcasts one value to every indexed position; a tensor src matches index's shape. On duplicate destinations one write wins; use scatter_add / scatter_reduce for well-defined accumulation. Index dtype law as gather.
Throws
ClikaRT::Error: (INVALID_ARGUMENT) whendimis out of range, the shapes disagree, or the index dtype is wrong (code_name()carries the reason).
Returns: a new tensor shaped like x.
auto onehot = ClikaRT::ops::scatter(zeros, 1, ids, 1.0);
Declared in ClikaRT/compute/ops.h, line 2563