-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Torch 2 regression: torch.asarray(np.array(1)) fail (scalar array) #97021
Copy link
Copy link
Closed
Labels
high prioritymodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsRelated to numpy support, and also numpy compatibility of our operatorsmodule: regressionIt used to work, and now it doesn'tIt used to work, and now it doesn'ttriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Milestone
Description
🐛 Describe the bug
It looks like torch 2 cannot convert float to int when the input is a scalar np.ndarray.
torch.asarray(1., dtype=torch.int32) # Works
torch.asarray(np.array(1.), dtype=torch.int32) # Fail
torch.asarray(np.array([1.]), dtype=torch.int32) # WorksTraceback
>>> torch.asarray(np.asarray(1.), dtype=torch.int32)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.
Versions
2.0.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
high prioritymodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsRelated to numpy support, and also numpy compatibility of our operatorsmodule: regressionIt used to work, and now it doesn'tIt used to work, and now it doesn'ttriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module