Skip to content
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 output dtype of elementwise_div #40890

Merged
merged 3 commits into from
Mar 28, 2022
Merged

Fix output dtype of elementwise_div #40890

merged 3 commits into from
Mar 28, 2022

Conversation

linjieccc
Copy link
Contributor

PR types

Bug fixes

PR changes

Others

Describe

整数除法结果还是整数:

import paddle

a = paddle.to_tensor([327])
b = paddle.to_tensor([80])
a / b
'''
Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True,
       [4])
'''

修复后结果为浮点数:

import paddle

a = paddle.to_tensor([327])
b = paddle.to_tensor([80])
a / b
'''
Tensor(shape=[1], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [4.08750010])
'''

@@ -264,6 +264,10 @@ def __impl__(self, other_var):
self = other_var
other_var = tmp

if op_type == 'elementwise_div' and self.dtype in _supported_int_dtype_:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加上注释、以及单测

Copy link
Contributor

@wawltor wawltor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@wawltor wawltor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wawltor wawltor merged commit 2b53c68 into PaddlePaddle:develop Mar 28, 2022
@linjieccc linjieccc deleted the fix_divide branch March 31, 2022 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants