Skip to content

Commit

Permalink
Enable fc on bfloat16 (#43154)
Browse files Browse the repository at this point in the history
* Enable fc on bfloat16

* Add pass for residual connection

* Dissable Residual connection pass for now

* Ban ResidualData from DQ

* style

* WO for python tests
  • Loading branch information
tsocha authored Jun 2, 2022
1 parent ff22a9c commit cb1a0ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion paddle/fluid/framework/ir/mkldnn/cpu_bfloat16_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ class DeQuantizer final : public Quanter {
bool IsNotPermittedName(const std::string& output_name) const override {
std::unordered_map<std::string, std::vector<std::string>> block_list{
{"layer_norm",
{"Mean", "Variance"}}}; // not used in inference in MKLDNN
{"Mean", "Variance"}}, // not used in inference in MKLDNN
{"fc", {"ResidualData"}}}; // artifical output, already dequantized

std::vector<std::string> blocked_outputs{"XShape"}; // blocklist for any op
auto op_name = op->Name();
Expand Down
4 changes: 4 additions & 0 deletions paddle/fluid/inference/api/paddle_pass_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ void CpuPassStrategy::EnableMkldnnQuantizer() {
void CpuPassStrategy::EnableMkldnnBfloat16() {
#ifdef PADDLE_WITH_MKLDNN
if (!use_mkldnn_bfloat16_) {
passes_.push_back("fc_mkldnn_pass");
passes_.push_back("fc_act_mkldnn_fuse_pass");
passes_.push_back("fc_elementwise_add_mkldnn_fuse_pass");

passes_.push_back("cpu_bfloat16_placement_pass");
passes_.push_back("cpu_bfloat16_pass");
passes_.push_back("cpu_quantize_squash_pass");
Expand Down

0 comments on commit cb1a0ec

Please sign in to comment.