From 0876fc145175336ffdbbb8211ed45f8006f557bb Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Mon, 5 Mar 2018 11:23:48 +0800 Subject: [PATCH] fix feed var --- python/paddle/fluid/executor.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index 984c4c73a8..d7ea09072e 100644 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -275,17 +275,6 @@ class Executor(object): outputs={'Out': [out]}, attrs={'col': i}) - for op in global_block.ops: - if op.desc.type() == 'feed': - feed_target_name = op.desc.output('Out')[0] - cur_feed = feed[feed_target_name] - if not isinstance(cur_feed, core.LoDTensor): - cur_feed = self.aslodtensor(cur_feed) - idx = op.desc.attr('col') - core.set_feed_variable(scope, cur_feed, feed_var_name, idx) - else: - break - if not has_fetch_operators(global_block, fetch_list, fetch_var_name): for i, var in enumerate(fetch_list): @@ -297,6 +286,18 @@ class Executor(object): outputs={'Out': [fetch_var]}, attrs={'col': i}) + # feed var to framework + for op in program_cache.global_block().ops: + if op.desc.type() == 'feed': + feed_target_name = op.desc.output('Out')[0] + cur_feed = feed[feed_target_name] + if not isinstance(cur_feed, core.LoDTensor): + cur_feed = self.aslodtensor(cur_feed) + idx = op.desc.attr('col') + core.set_feed_variable(scope, cur_feed, feed_var_name, idx) + else: + break + self.executor.run(program_cache.desc, scope, 0, True, True) outs = [ core.get_fetch_variable(scope, fetch_var_name, i) -- GitLab