How to assign values to tensor based on index array efficiently?

`
something like the following tensorflow equivalent.

tf.TensorArray.scatter(indices, value, name=None)

Scatter the values of a Tensor in specific indices of a TensorArray.

Args:
    indices: A 1-D Tensor taking values in [0, max_value). If the TensorArray is not dynamic, max_value=size().
    value: (N+1)-D. Tensor of type dtype. The Tensor to unpack.
name: A name for the operation (optional).

Returns:
    A new TensorArray object with flow that ensures the scatter occurs. Use this object all for subsequent operations.

Raises:

ValueError: if the shape inference fails.

You’re probably looking for scatter or index_fill.

3 Likes

I think index_put_ also works.