From c8e49b655b384bcefdd9da4b225c062cbbd14457 Mon Sep 17 00:00:00 2001 From: wanghaoshuang Date: Tue, 16 Apr 2019 23:41:43 +0800 Subject: [PATCH] Fix load persistables in graph wrapper. test=develop --- python/paddle/fluid/contrib/slim/graph/graph_wrapper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/contrib/slim/graph/graph_wrapper.py b/python/paddle/fluid/contrib/slim/graph/graph_wrapper.py index e7f5f0d6a2..f4eed5014a 100644 --- a/python/paddle/fluid/contrib/slim/graph/graph_wrapper.py +++ b/python/paddle/fluid/contrib/slim/graph/graph_wrapper.py @@ -489,8 +489,11 @@ class GraphWrapper(object): def if_exist(var): return os.path.exists(os.path.join(path, var.name)) - io.load_vars( - exe.exe, path, vars=self.persistables.values(), predicate=if_exist) + persistables = [] + for var in self.persistables.values(): + if if_exist(var): + persistables.append(var) + io.load_vars(exe.exe, path, vars=persistables, predicate=if_exist) def update_param_shape(self, scope): """ -- GitLab