-
Notifications
You must be signed in to change notification settings - Fork 27.7k
Python scalars should be promoted to the same dtype as the respective tensor #59868
Copy link
Copy link
Open
Labels
module: python array apiIssues related to the Python Array APIIssues related to the Python Array APImodule: type promotionRelated to semantics of type promotionRelated to semantics of type promotionneeds designWe want to add this feature but we need to figure out how firstWe want to add this feature but we need to figure out how firsttriagedThis 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
Metadata
Metadata
Assignees
Labels
module: python array apiIssues related to the Python Array APIIssues related to the Python Array APImodule: type promotionRelated to semantics of type promotionRelated to semantics of type promotionneeds designWe want to add this feature but we need to figure out how firstWe want to add this feature but we need to figure out how firsttriagedThis 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
The array API specification stipulates that for binary operations involving a tensor and a Python scalar, the scalar needs to be converted to the same
dtypeas the tensor before the operation is performed. PyTorch casts the scalar to a tensor based on itsdtypeand afterwards performs the default type promotion for the operator.This can lead to overflows if the tensor
dtypecan hold the values of the scalar, but the automatically determineddtypecannot.cc @mruberry @rgommers @pmeier @asmeurer @leofang @nairbv