diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index f038a15fd0fde6e2b171c56ff4dff645d0bcf9aa..9060455f4d7fb0e19914ff3f873a26b71ff23e8c 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()