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

Unification of BF16 enablement process #31034

Merged
merged 3 commits into from
Feb 23, 2021
Merged

Conversation

wozna
Copy link
Contributor

@wozna wozna commented Feb 18, 2021

PR types

Function optimization

PR changes

Others

Describe

This PR unifies the addition of bfloat16 so that the process of adding quantize and dequantize reorders is similar to the quantization process. This way, pass cpu_quantize_squash_pass.cc can also be used in the bfloat16 process.

Therefore, the following changes have been added:

  • cpu_bfloat16_pass.cc - adds quantize and dequantize before and after each operator which is marked as bfloat16
  • cpu_quantzie_squash_pass.cc
  • checks where we have dequantize and quantize, then inserts requantize` if scales are different or removes both operators when scale is the same (the latter is the most common in the case of bfloat16)
  • removes dequantize op if it occurs before operators that has force _fp32_output attribute

Additionally, to cpu_quantzie_squash_pass.cc has been added:

  • squash, where Scale operator and Quantize operator are merged
  • squash where if we have Quantize operator before Conv2d bfloat16 op then remove Quantize because the input reorder can be executed inside the kernel

@paddle-bot-old
Copy link

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

@wozna wozna requested a review from jczaja February 22, 2021 08:30
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

@luotao1 luotao1 merged commit 781df30 into PaddlePaddle:develop Feb 23, 2021
@wozna wozna deleted the bf16_v3 branch February 24, 2023 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants