Skip to content

Fix output dtype of elementwise_div#40890

Merged
wawltor merged 3 commits intoPaddlePaddle:developfrom
linjieccc:fix_divide
Mar 28, 2022
Merged

Fix output dtype of elementwise_div#40890
wawltor merged 3 commits intoPaddlePaddle:developfrom
linjieccc:fix_divide

Conversation

@linjieccc
Copy link
Copy Markdown
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])
'''

self = other_var
other_var = tmp

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

Choose a reason for hiding this comment

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

加上注释、以及单测

Copy link
Copy Markdown
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
Copy Markdown
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