import torch
for obj in (True, 1, 1.0):
print(f"{obj} -> {torch.asarray(obj).dtype}")
True -> torch.float32
1 -> torch.float32
1.0 -> torch.float32
The documentation does not mention support for Python scalars, but since the function doesn't bail out, the behavior shown above is at least unexpected.
torch.asarray was added in #60627 and specifically mentions the array API standard for compatibility, but this defines behavior for scalars.
cc @gchanan @mruberry @rgommers @pmeier @asmeurer @leofang @AnirudhDagar @asi1024 @emcastillo @kmaehashi
The documentation does not mention support for Python scalars, but since the function doesn't bail out, the behavior shown above is at least unexpected.
torch.asarraywas added in #60627 and specifically mentions the array API standard for compatibility, but this defines behavior for scalars.cc @gchanan @mruberry @rgommers @pmeier @asmeurer @leofang @AnirudhDagar @asi1024 @emcastillo @kmaehashi