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 div error when dtype is int64 in static mode #53705

Merged
merged 2 commits into from
May 11, 2023

Conversation

0x45f
Copy link
Contributor

@0x45f 0x45f commented May 10, 2023

PR types

Bug fixes

PR changes

APIs

Description

下面代码动态图返回结果是0.75,动转静(静态图)返回结果是0。正确结果应该是0.75,因为这里的除法是truediv。

import paddle

@paddle.jit.to_static
def fn(x, y):
    z = x / y
    return z

x = paddle.to_tensor([3], dtype='int64')
y = paddle.to_tensor([4], dtype='int64')

out = fn(x, y)
print(out)

动态图的代码中将类型统一转成了float32类型,所以计算结果正确
image
但是静态图variable的__truediv__方法中没有对应类型转换的代码,本PR的修改参考了老动态图varbase的truediv的代码

PCard-64703

@paddle-bot
Copy link

paddle-bot bot commented May 10, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot
Copy link

paddle-bot bot commented May 10, 2023

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

Copy link
Contributor

@Aurelius84 Aurelius84 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

@2742195759 2742195759 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
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTM~~~

@0x45f 0x45f merged commit 00ded2e into PaddlePaddle:develop May 11, 2023
@0x45f 0x45f deleted the fix-static-truediv branch May 11, 2023 02:49
0x45f added a commit to 0x45f/Paddle that referenced this pull request May 11, 2023
* Fix div error when dtype is int64 in static mode

* Fix out dtype
XiaoguangHu01 pushed a commit that referenced this pull request May 11, 2023
* Fix div error when dtype is int64 in static mode

* Fix out dtype
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.

4 participants