mlx equivalent to np.add.at / torch.Tensor.scatter_add_ #1317
Answered
by
awni
louisamand
asked this question in
Q&A
-
Would it be complicated to make an equivalent of np.add.at and torch.Tensor.scatter_add_ (as shown in the example bellow) in mlx ?
|
Beta Was this translation helpful? Give feedback.
Answered by
awni
Aug 11, 2024
Replies: 1 comment 1 reply
-
We have something like a scatter add in MLX: import mlx.core as mx
idx = mx.array([0, 1, 2, 2, 1, 0])
b = mx.array([0.1, 9, -1, 4, 3, 2])
a = mx.zeros(shape=3)
a = a.at[idx].add(b) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
louisamand
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We have something like a scatter add in MLX:
docs: https://ml-explore.github.io/mlx/build/html/python/_autosummary/mlx.core.array.at.html#mlx.core.array.at