Skip to content
fn

put_along_axis_last_write_wins

::mlx::core::array put_along_axis_last_write_wins(const ::mlx::core::array & b, const ::mlx::core::array & i, const ::mlx::core::array & v, int d)

put_along_axis with last-write-wins tie-breaking along d.

When i names a destination position along d more than once in the same off-d fibre, mlx::core::put_along_axis dispatches one GPU thread per update and lets them race. Under set_deterministic(True), scattering the update's coordinate k in [0, K) along d with mlx_scatter_max selects the highest k that targeted each destination slot — an associative, order-independent integer reduction — and take_along_axis reads v at that k, matching the CPU's sequential 0 .. K - 1 overwrite loop.