From 1f686744834abf0c6676e035d9e41506bae21008 Mon Sep 17 00:00:00 2001 From: chengduo <30176695+chengduoZH@users.noreply.github.com> Date: Fri, 20 Sep 2019 09:35:05 +0800 Subject: [PATCH] refine executor bug info (#19887) test=develop --- python/paddle/fluid/executor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index f038a15fd0..9060455f4d 100644 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -621,11 +621,15 @@ class Executor(object): if self._closed: raise RuntimeError("Attempted to use a closed Executor") + use_default_main_program = program is None if program is None: program = default_main_program() - if isinstance(program,Program) and \ + if isinstance(program, Program) and \ len(program.global_block().ops) == 0: - warnings.warn("The current program is empty.") + error_info = "The current program is empty." + if use_default_main_program: + error_info += " Maybe you should pass the Program or the CompiledProgram manually." + warnings.warn(error_info) if scope is None: scope = global_scope() -- GitLab