From 0dfb5c943967d85550d54e994145a999f38b6529 Mon Sep 17 00:00:00 2001 From: lilong12 Date: Thu, 5 Dec 2019 17:41:47 +0800 Subject: [PATCH] construct a DistributedStrategy instance if the passed one is None (#21545) (#21567) --- python/paddle/fluid/incubate/fleet/collective/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/paddle/fluid/incubate/fleet/collective/__init__.py b/python/paddle/fluid/incubate/fleet/collective/__init__.py index 26b8e2c3b1..9c7963a1ec 100644 --- a/python/paddle/fluid/incubate/fleet/collective/__init__.py +++ b/python/paddle/fluid/incubate/fleet/collective/__init__.py @@ -151,8 +151,10 @@ class CollectiveOptimizer(DistributedOptimizer): """ def __init__(self, optimizer, strategy=DistributedStrategy()): + if strategy is None: + strategy = DistributedStrategy() super(CollectiveOptimizer, self).__init__(optimizer, strategy) - if strategy is not None and strategy.forward_recompute: + if strategy.forward_recompute: self.forward_recompute = True self.recompute_checkpoints = strategy.recompute_checkpoints else: -- GitLab