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

Added conv + hard_sigmoid oneDNN fuse pass #36869

Merged
merged 3 commits into from
Nov 2, 2021

Conversation

jakpiase
Copy link
Contributor

@jakpiase jakpiase commented Oct 29, 2021

PR types

New features

PR changes

OPs

Describe

Added conv + hard_sigmoid oneDNN fuse pass. It is designed mainly for PPLCNets architectures. This fuse pass improves PPLCNet_x0_25 model performance by 3% and PPLCNet_x1_0 performance by 1.4%
OneDNN does not have pure hard_sigmoid activation, that's why 2 eltwise postops are needed.

hard_sigmoid(x, slope, offset) = max(0, min(1, slope * x + offset))
With oneDNN, we can get the inner equation by
eltwise_linear(x, slope, offset) = slope * x + offset
And adding clip after that would give us the exact equation as pure hard_sigmoid
eltwise_clip(eltwise_linear(x, slope, offset), 0, 1) = max(0, min(1, slope * x + offset))

@paddle-bot-old
Copy link

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

@jakpiase
Copy link
Contributor Author

@piotrekobiIntel Please, review this PR

@lidanqing-intel lidanqing-intel changed the title Added conv + hard_sigmoid oneDNN fuse pass [Need review] Added conv + hard_sigmoid oneDNN fuse pass Nov 2, 2021
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

LGTM, it's weird how you basically have to write the same thing in conv_activation_mkldnn_fuse_pass.cc and hard_sigmoid.pbtxt (the latter looks much cleaner), but I guess that's just the beauty of our framework :)

Copy link
Contributor

@jczaja jczaja left a comment

Choose a reason for hiding this comment

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

LGTM

@jakpiase
Copy link
Contributor Author

jakpiase commented Nov 2, 2021

@jczaja please merge

@jczaja jczaja merged commit 5369071 into PaddlePaddle:develop Nov 2, 2021
ghost pushed a commit to piotrekobi/Paddle that referenced this pull request Nov 3, 2021
…e#36869)

* added conv + hard_sigmoid fuse pass

* Removed IsOptional() statements

* Reverted removing optional
@jakpiase jakpiase changed the title [Need review] Added conv + hard_sigmoid oneDNN fuse pass Added conv + hard_sigmoid oneDNN fuse pass Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants