Skip to content

Commit

Permalink
fix performance regression
Browse files Browse the repository at this point in the history
  • Loading branch information
zyfncg committed Dec 2, 2022
1 parent 03c86be commit 5d82a37
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void ComputePropagateScalesMkldnnPass::ComputeWeightScales(
ir::Graph* graph, Scope* scope, StringPairMap* var_quant_scales) const {
ComputeVarScales(graph,
scope,
{"conv2d", "depthwise_conv2d"},
{"conv2d", "depthwise_conv2d", "fused_conv2d"},
"Filter",
1,
var_quant_scales);
Expand Down Expand Up @@ -446,7 +446,7 @@ void ComputePropagateScalesMkldnnPass::UpdateReluOutputScales(
if (op->Type() == "relu") {
is_unsigned = true;
} else {
if (op->Type() == "conv2d") {
if (op->Type() == "conv2d" || op->Type() == "fused_conv2d") {
act_name = "fuse_activation";
output_name = "Output";
} else if (op->Type() == "fc") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ void CPUQuantizePlacementPass::ApplyImpl(ir::Graph* graph) const {
auto handler = [&](const GraphPatternDetector::subgraph_t& subgraph,
Graph* g) {
GET_IR_NODE_FROM_SUBGRAPH(op, op, quantize_placement_pattern);

if (std::find(excluded_ids_list.begin(),
excluded_ids_list.end(),
op->id()) != excluded_ids_list.end()) {
Expand All @@ -70,7 +69,6 @@ void CPUQuantizePlacementPass::ApplyImpl(ir::Graph* graph) const {
if (op->Op()->GetAttrIfExists<int>("skip_quant") == 1) {
return;
}

op->Op()->SetAttr("mkldnn_data_type", std::string("int8"));
};
gpd(graph, handler);
Expand Down
6 changes: 6 additions & 0 deletions paddle/fluid/inference/api/mkldnn_quantizer_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ MkldnnQuantizerConfig::MkldnnQuantizerConfig() {
rules_["conv2d"]["ResidualData"] = ScaleAlgo::KL;
rules_["conv2d"]["Output"] = ScaleAlgo::KL;

rules_["fused_conv2d"]["Input"] = ScaleAlgo::KL;
rules_["fused_conv2d"]["Filter"] = ScaleAlgo::MAX_CH;
rules_["fused_conv2d"]["Bias"] = ScaleAlgo::NONE; // do not compute scale
rules_["fused_conv2d"]["ResidualData"] = ScaleAlgo::KL;
rules_["fused_conv2d"]["Output"] = ScaleAlgo::KL;

rules_["pool2d"]["X"] = ScaleAlgo::KL;
rules_["pool2d"]["Out"] = ScaleAlgo::KL;

Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/inference/api/paddle_analysis_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@ struct PD_INFER_DECL AnalysisConfig {
"concat",
"conv2d",
"depthwise_conv2d",
"fused_conv2d",
"elementwise_add",
"elementwise_mul",
"fc",
Expand Down

0 comments on commit 5d82a37

Please sign in to comment.