From f5221ac19f625293ec153e11ef332047093e69e8 Mon Sep 17 00:00:00 2001 From: "joanna.wozna.intel" Date: Fri, 27 Sep 2019 10:49:10 +0200 Subject: [PATCH] Disable conv requant squash (#20041) * Fix conv2d+dequantize squash for residual fusion test=develop * Disable conv-requant squash test=develop --- .../ir/mkldnn/cpu_quantize_squash_pass.cc | 1 - .../mkldnn/cpu_quantize_squash_pass_tester.cc | 33 ++----------------- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc index 1e23539c80..1c09dc669d 100644 --- a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc @@ -202,7 +202,6 @@ void CPUQuantizeSquashPass::ApplyImpl(ir::Graph* graph) const { std::unordered_map nodes_keep_counter; FindNodesToKeep(graph, &nodes_keep_counter); DequantQuantSquash(graph, &nodes_keep_counter); - ConvRequantSquash(graph); ConvDequantSquash(graph); } diff --git a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass_tester.cc index 08b605a713..0dfef76f8a 100644 --- a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass_tester.cc @@ -277,22 +277,18 @@ TEST(CpuQuantizeSquashPass, equal_scales) { // From Conv1->d->Dequant->e->Quant->f->Conv2 // First change to Conv1->d->Requant->f->Conv2 -// Then Conv1->f->Conv2 TEST(CpuQuantizeSquashPass, unequal_scales) { auto scale_out = 1.0f; auto scale1 = 1.2345f; auto scale2 = 21.0f; auto use_mkldnn = true; - // Remove 4 nodes: Dequant, Quant, e, d - auto remove_nodes = 4; + // Remove 3 nodes: Dequant, Quant, e + // Insert 1 node: Requant + auto remove_nodes = 2; CountNodeTest( BuildConvRequantProgramDesc(use_mkldnn, scale_out, scale1, scale2), remove_nodes); - - EqualScaleOutTest( - BuildConvRequantProgramDesc(use_mkldnn, scale_out, scale1, scale2), - "Conv1", scale2); } // from @@ -322,29 +318,6 @@ TEST(CpuQuantizeSquashPass, branch_to_equal_unequal_and_fp32) { scale, scale2); } -// a->Conv1->b->Requant->c -// d->Conv2->e->Requant->f -// {c,f}->Concat -TEST(CpuQuantizeSquashPass, equal_scales_squash_requantize) { - // Delete both requantize op - auto scale_out = 1.0f; - auto scale = 1.2345f; - auto use_mkldnn = true; - // Remove 4 nodes: b, Requant1, e, Requant2 - auto remove_nodes = 4; - CountNodeTest( - BuildConvsRequantConcatProgramDesc(use_mkldnn, scale_out, scale, scale), - remove_nodes); - - // check equal scale conv->scale_out and requant->scale_out - EqualScaleOutTest( - BuildConvsRequantConcatProgramDesc(use_mkldnn, scale_out, scale, scale), - "Conv1", scale); - EqualScaleOutTest( - BuildConvsRequantConcatProgramDesc(use_mkldnn, scale_out, scale, scale), - "Conv2", scale); -} - // a->Concat->b->Dequant->c->Quant->d->Conv->e // to a->Concat->b->Requant->d->Conv->e TEST(CpuQuantizeSquashPass, -- GitLab