From 86c2c362ae1079fac11257f32b64ac04fff6f1ab Mon Sep 17 00:00:00 2001 From: Liufang Sang Date: Fri, 11 Oct 2019 13:13:06 +0800 Subject: [PATCH] fix fuse_reduce_op quantization bug (#20306) * fix fuse_reduce_op quantization bug test=develop * close fuse_all_reduce_ops in PaddleSlim, test=develop --- python/paddle/fluid/contrib/slim/core/compressor.py | 5 ++++- python/paddle/fluid/contrib/slim/graph/graph_wrapper.py | 1 + .../fluid/contrib/slim/quantization/quantization_strategy.py | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/contrib/slim/core/compressor.py b/python/paddle/fluid/contrib/slim/core/compressor.py index c076a0764f..5eb8d970ad 100644 --- a/python/paddle/fluid/contrib/slim/core/compressor.py +++ b/python/paddle/fluid/contrib/slim/core/compressor.py @@ -480,9 +480,12 @@ class Compressor(object): executor = SlimGraphExecutor(self.place) if context.optimize_graph.compiled_graph is None: + build_strategy = compiler.BuildStrategy() + build_strategy.fuse_all_reduce_ops = False context.optimize_graph.compiled_graph = compiler.CompiledProgram( context.optimize_graph.program).with_data_parallel( - loss_name=context.optimize_graph.out_nodes['loss']) + loss_name=context.optimize_graph.out_nodes['loss'], + build_strategy=build_strategy) if isinstance(context.train_reader, Variable) or ( isinstance(context.train_reader, diff --git a/python/paddle/fluid/contrib/slim/graph/graph_wrapper.py b/python/paddle/fluid/contrib/slim/graph/graph_wrapper.py index 78697a2023..1c01eb82d7 100644 --- a/python/paddle/fluid/contrib/slim/graph/graph_wrapper.py +++ b/python/paddle/fluid/contrib/slim/graph/graph_wrapper.py @@ -263,6 +263,7 @@ class GraphWrapper(object): build_strategy = compiler.BuildStrategy() build_strategy.enable_inplace = mem_opt build_strategy.memory_optimize = mem_opt + build_strategy.fuse_all_reduce_ops = False # build_strategy.async_mode = False self.compiled_graph = compiler.CompiledProgram( target).with_data_parallel( diff --git a/python/paddle/fluid/contrib/slim/quantization/quantization_strategy.py b/python/paddle/fluid/contrib/slim/quantization/quantization_strategy.py index 5d2b6ea369..5004faeea7 100644 --- a/python/paddle/fluid/contrib/slim/quantization/quantization_strategy.py +++ b/python/paddle/fluid/contrib/slim/quantization/quantization_strategy.py @@ -138,6 +138,7 @@ class QuantizationStrategy(Strategy): build_strategy = BuildStrategy() build_strategy.enable_inplace = False build_strategy.memory_optimize = False + build_strategy.fuse_all_reduce_ops = False # for quantization training context.optimize_graph.compiled_graph = CompiledProgram( train_ir_graph.graph).with_data_parallel( -- GitLab