diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index 984c4c73a85cd0ffb51f528a5a27f8f8ce53688a..d7ea09072e1bddb12c6d0e7754bd369d8dc4fada 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)