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

MKLDNN: SoftmaxGrad Op #11519

Merged

Conversation

jczaja
Copy link
Contributor

@jczaja jczaja commented Jun 15, 2018

  • Introducing Softmax MKLDNN grad operator to take advantage of recently introduced softmax backward primitive in MKLDNN .
  • Redesigned reusing mechanism and applied it softax op and softmax grad op.

With this PR machine translation when MKLDNN is used (use_mkldnn=True, shall be added in fc layer of machine_translation.py) is speeding up significantly

@@ -99,5 +99,124 @@ inline mkldnn::memory::format GetMKLDNNFormat(const mkldnn::memory memory) {
memory.get_primitive_desc().desc().data.format);
}

class MKLDNNHandler {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you give more introductions about MKLDNNHandler
Is this specifically added for softmax grad since this.

When adding functions at mkldnn_helper.h, it should be something common I suppose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tensor-tang You are right that softmax functionality should go to into MKLDNNHandler. MKLDNNHandler will agregate common functionality as for softmax/conv/pool primitive specific functionality there will be designated derived classes eg. SoftmaxMKLDNNHandler , ConvMKLDNNHandler etc. I updated the code adding SoftmaxMKLDNNHandler. Please take a look

@jczaja jczaja force-pushed the prv-softmax-mkldnn-grad-operator branch 5 times, most recently from 8a571ef to 6a2a282 Compare June 21, 2018 11:53
@jczaja
Copy link
Contributor Author

jczaja commented Jun 21, 2018

Hi, I answered on @tensor-tang question within relevant disscussion. My changes were updated
so now it is easier to figure direction of development of MKLDNNHandler. MKLDNNHandler will be extended as next MKLDNN operators will be transofrmed to have it used. If there is a need for more explanation then please ask. Please review:)

@jczaja
Copy link
Contributor Author

jczaja commented Jun 21, 2018

There was a merge conflict but it is resolved now.

- Added hash function inside of MKLDNN softmax op to be used as handle for primitives stroing in a
context

- Style fixes to softmax mkldnn op

- Fixes after review

- Coding style

- Fix to style

- style fixes

- style fix

- style fixes

- Fix to cody style check

- Rephrasing a comment

fix t obroken merge

Fixes to rebase

Conflicts:
	benchmark/fluid/models/machine_translation.py
	cmake/external/mkldnn.cmake
	paddle/fluid/operators/softmax_mkldnn_op.cc

- Bumped revision of MKL-DNN up to have softmax backward primitive

- Added choosing MKLDNN softmax grad operator

- First reuse of softmax backward

- Reinvented reusing for softmax

- Fix to crash in reinvented reuse

- Clang format fixes

- Clang format fixes

- Improved softmax mkldnn reuse mechanism

- clang format fixes

- Fix to broken merge

- Fix
@jczaja jczaja force-pushed the prv-softmax-mkldnn-grad-operator branch from be4a58c to 98f3ad3 Compare June 21, 2018 14:47
Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks very much!

@luotao1 luotao1 merged commit 60647c9 into PaddlePaddle:develop Jun 22, 2018
@jczaja jczaja deleted the prv-softmax-mkldnn-grad-operator branch June 22, 2018 15:28
@luotao1 luotao1 moved this from Doing to Done in Intel Optimization on Fluid Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

3 participants