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

change '/' method from scale Op to elementwise_div Op #33279

Conversation

MingMingShangTian
Copy link
Contributor

@MingMingShangTian MingMingShangTian commented Jun 2, 2021

PR types

Bug fixes

PR changes

APIs

Describe

  • Fix the bug of div operation result using scale method do not exactly equal the result of elementwise_div method. Remove the _scalar_div_ function.
    The bug is as follow.
    image

And after fixing the bug
image

  • Remove __div__ ,__rdiv__ methods which do not be defined in python3 standard.

@paddle-bot-old
Copy link

paddle-bot-old bot commented Jun 2, 2021

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

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

better to add a unittest for this case?

('__truediv__', _binary_creator_('__truediv__', 'elementwise_div',
False, _scalar_div_)),
('__rdiv__', _binary_creator_('__rdiv__', 'elementwise_div', True,
Copy link
Contributor

@zhwesky2010 zhwesky2010 Jun 2, 2021

Choose a reason for hiding this comment

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

__rdiv__ 在python3也没有了吗

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,没有了。 参考python3 的文档 https://docs.python.org/3/reference/datamodel.html

zhwesky2010
zhwesky2010 previously approved these changes Jun 2, 2021
@@ -187,6 +187,13 @@ def test_tensor_div_scalar(self):
c = paddle.full([2, 2, 2], 0.5, dtype="float32")
self.check_operation(a, b, c, '/')

# tensor(float32) / scalar(int)
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

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

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

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

LGTM

@MingMingShangTian MingMingShangTian merged commit ae93d9c into PaddlePaddle:develop Jun 2, 2021
@MingMingShangTian MingMingShangTian deleted the fix_elementwise_div_bug branch June 2, 2021 11:17
MingMingShangTian added a commit to MingMingShangTian/Paddle that referenced this pull request Jun 3, 2021
…3279)

* fix the bug of div operation result using scale method do not exactly equal the result of elementwise_div method

* remove __div__ , __rdiv__ methods which do not define in python3

* modify the note

* add test case

* add test case
MingMingShangTian added a commit to MingMingShangTian/Paddle that referenced this pull request Sep 10, 2021
MingMingShangTian added a commit that referenced this pull request Sep 13, 2021
AnnaTrainingG pushed a commit to AnnaTrainingG/Paddle that referenced this pull request Sep 29, 2021
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.

3 participants