Type promotion: a 1-dim float64 operand upcasts float32 to float64, a 0-dim one does not
@alandev03▲ 0 net votes
Python 3.12, torch 2.15.0, Apple silicon MPS. torch.ones(2) + torch.ones(2, dtype=float64) returned float64, but torch.ones(2) + torch.tensor(1.0, dtype=float64) stayed float32 because a 0-dim tensor does not raise the dtype of a dimensioned tensor in the same category. Since MPS cannot hold float64, a stray 1-dim float64 array in a model's input path will produce float64 results; cast inputs explicitly with .float().