-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Added fp32 / bf16 forward and backward elementwise_div_mkldnn operator #36158
Added fp32 / bf16 forward and backward elementwise_div_mkldnn operator #36158
Conversation
Thanks for your contribution! |
- Refactor BinaryMKLDNNHandler to use a default parameter
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.
LGTM
@lanxianghit @phlrain Please review and approve. |
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.
Apart from some minor comments, really good job! You can also include in title/description, that this kernel is registered for both forward and backward and supports both bf16 and fp32 dtypes
paddle/fluid/operators/elementwise/mkldnn/elementwise_div_mkldnn_op.cc
Outdated
Show resolved
Hide resolved
self.out = np.divide(self.x, self.y) | ||
|
||
def test_check_grad_normal(self): | ||
pass |
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.
Why backward pass is not checked in this scenario?
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.
Backward pass doesn't work correctly with broadcast for the elementwise_mkldnn mul and div operators. I've consulted this with @jczaja and he said that these tests can be disabled for now. I've added a comment to notify the fact that this should be looked into.
paddle/fluid/operators/elementwise/mkldnn/elementwise_div_mkldnn_op.cc
Outdated
Show resolved
Hide resolved
paddle/fluid/operators/elementwise/mkldnn/elementwise_div_mkldnn_op.cc
Outdated
Show resolved
Hide resolved
self.out = np.divide(self.x, self.y) | ||
|
||
def test_check_grad_normal(self): | ||
self.check_grad(['X', 'Y'], 'Out', max_relative_error=0.05) |
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.
5% of relative error is quite a lot, is oneDNN's precision really that bad?
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.
The original elementwise_div tests also used 5%, so that's what I sticked with. In reality, the errors are just over 1%. I've changed the relative error to 2% to make this more clear.
@arlesniak Please review |
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.
LGTM, really good job
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.
LGTM
@Xreki Hi, please take a look at this PR, it needs approval (PR-CI-APPROVAL) |
@lidanqing-intel Could you be so kind as to help with approval for this PR, please? |
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.
LGTM
Sorry to inform you that dd1c0ab's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
not accepting max_relative_error
a910f52
… piotrekobi_elementwise_div_mkldnn
@piotrekobiIntel Hi, this CheckPRTemplate CI failed do you know why? And Jacek's approval are dismissed because something changed could you please ask his approval and ask him to merge. I have approved. Thanks. |
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.
LGTM
PaddlePaddle#36158) * Add WIP version of elementwise_div_mkldnn without working dy grad * Add dy gradient calculation implementation, disable broadcast tests * Readd removed tests from static_mode_white_list * Add bfloat16 gradient tests, remove int8 and uint8 support * - Change the way dy grad is calculated to improve performance - Refactor BinaryMKLDNNHandler to use a default parameter * Change copyright year * Refactor as suggested * Attempt to bypass CI Approval not accepting max_relative_error * Fix formatting issue
PR types
New features
PR changes
OPs
Describe
Adds elementwise_div fp32/bf16 FWD & BWD oneDNN op kernel.