From b63901f52352fdd1c2ea792566217a9f87d667f2 Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Tue, 6 Mar 2018 11:19:33 +0800 Subject: [PATCH] optimize program_cache_key, delete cache when use_program_cache is false --- python/paddle/fluid/executor.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index 98f28938fe6..ceff04286c6 100644 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -260,14 +260,17 @@ class Executor(object): scope = global_scope() program_cache = None - program_cache_key = None + + feed_var_names = feed.keys() + fetch_var_names = [var.desc.name() for var in fetch_list] + program_cache_key = str(feed_var_names + fetch_var_names) + if use_program_cache: # find program cache by cache_key - feed_var_names = feed.keys() - fetch_var_names = [var.desc.name() for var in fetch_list] - program_cache_key = str(feed_var_names + fetch_var_names) program_cache = self.program_caches.get(program_cache_key, None) # TODO(qiao): Should check program_cache and program are exactly the same. + else: + self.program_caches.pop(program_cache_key, None) if program_cache is None: program_cache = program.clone() -- GitLab