Open
Description
🐛 Describe the bug
x[idx] = v
fails when
x
has ndim=0, andidx
is a boolean mask (also with ndim=0), andv
requires type promotion.
import torch as xp
x = xp.asarray([0], dtype=xp.float64)
x[x==0] = xp.asarray(1, dtype=xp.float32) # OK
x = xp.asarray(0, dtype=xp.float64)
x[()] = xp.asarray(1, dtype=xp.float32) # OK
x[x==0] = xp.asarray(1, dtype=xp.float64) # OK
x[x==0] = xp.asarray(1, dtype=xp.float32) # error
# RuntimeError: Index put requires the source and destination dtypes match, got Double for the destination and Float for the source.
Versions
torch 2.6.0 cpu