-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix type promotion for pow
.
#6745
Conversation
I will add a test case for this, later. |
// Float scalar literal in Python defaults to F64. But we want to produce | ||
// F32 as this is the default Pytorch behavior. | ||
if (xla_type == xla::PrimitiveType::F64) { | ||
xla_type = xla::PrimitiveType::F32; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @qihqi added this downcasting rule and you removed it in this pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this anymore, since at::result_type
resolves to the appropriate type, as we can observe with the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a test to test/test_operation.py
for the result type?
not sure why CI is not running... |
Maybe due to merge conflicts? I will try rebasing. |
5c9d1df
to
aba3534
Compare
Fix: #6521
This PR fixes how PyTorch/XLA promotes types for
pow
function. It does so by resolving the resulting type of the operation by callingat::result_type
(similar to howadd
is implemented in PyTorch/XLA). This aligns the implementation with PyTorch's. See the example below:cc @miladm @JackCaoG