From 3b96e3d20a12112b37622ec3822c2ecddc8389c6 Mon Sep 17 00:00:00 2001 From: tangwei12 Date: Sun, 3 Nov 2019 17:05:41 +0800 Subject: [PATCH] fix FetchHandler (#20900) * bug fix, test=develop --- python/paddle/fluid/executor.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index 3a72c8381e7..ab2c690a5c4 100644 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -987,11 +987,6 @@ class Executor(object): dataset._prepare_to_run() - if fetch_handler is not None: - fetch_instance = fetch_handler - else: - fetch_instance = FetchHandler([]) - scope, trainer = self._prepare_trainer( program=program, dataset=dataset, @@ -1006,17 +1001,26 @@ class Executor(object): trainer._gen_trainer_desc() self._dump_debug_info(program=program, trainer=trainer) + dataset._dynamic_adjust_before_train(trainer.proto_desc.thread_num) trainer_instance = self._default_executor.init_for_dataset( program.desc, trainer._desc(), scope, dataset.dataset) - scope0 = trainer_instance.get_worker_scope(0) + if fetch_handler is not None: + scope0 = trainer_instance.get_worker_scope(0) + fetch_monitor = FetchHandlerMonitor(scope0, fetch_handler) + fetch_monitor.start() + + self._default_executor.run_from_dataset(trainer_instance) - fetch_monitor = FetchHandlerMonitor(scope0, fetch_instance) - fetch_monitor.start() - self._default_executor.run_from_dataset(trainer_instance) - fetch_monitor.stop() + fetch_monitor.stop() + else: + + self._default_executor.run_from_dataset(trainer_instance) + + dataset._dynamic_adjust_after_train() dataset._finish_to_run() + return None def infer_from_dataset(self, -- GitLab