From fc0b21e17b64f3e2f7b5a107271d20ab78f5ca9e Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Mon, 13 Jan 2020 11:04:20 +0800 Subject: [PATCH] Polish fetch error message of parallel executor (#22206) * polish error message of parallel executor, test=develop * change PADDLE_ENFORCE, test=develop --- .../details/fast_threaded_ssa_graph_executor.cc | 7 +++++-- .../details/threaded_ssa_graph_executor.cc | 13 +++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc b/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc index cab1966ecc..aba8e5c6c9 100644 --- a/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.cc @@ -142,8 +142,11 @@ void FastThreadedSSAGraphExecutor::InsertFetchOps( PADDLE_ENFORCE_NE( fetched_var_it, fetched_vars->end(), platform::errors::PreconditionNotMet( - "Cannot find fetched variable(%s). Perhaps the main_program " - "is not set to ParallelExecutor.", + "Cannot find fetched variable(%s) in current computation graph. " + "Possible reasons are:\n" + " 1. The variable to be fetched is not defined in main program.\n" + " 2. The variable to be fetched is not an input or output of any " + "operator.", var_name)); auto &vars = fetched_var_it->second; diff --git a/paddle/fluid/framework/details/threaded_ssa_graph_executor.cc b/paddle/fluid/framework/details/threaded_ssa_graph_executor.cc index 5ee47a3933..55ceb802eb 100644 --- a/paddle/fluid/framework/details/threaded_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/threaded_ssa_graph_executor.cc @@ -170,10 +170,15 @@ void ThreadedSSAGraphExecutor::InsertFetchOps( for (size_t i = 0; i < fetch_tensors.size(); ++i) { auto &var_name = fetch_tensors[i]; auto fetched_var_it = fetched_vars.find(var_name); - PADDLE_ENFORCE(fetched_var_it != fetched_vars.end(), - "Cannot find fetched variable(%s).(Perhaps the main_program " - "is not set to ParallelExecutor)", - var_name); + PADDLE_ENFORCE_NE( + fetched_var_it, fetched_vars.end(), + platform::errors::PreconditionNotMet( + "Cannot find fetched variable(%s) in current computation graph. " + "Possible reasons are:\n" + " 1. The variable to be fetched is not defined in main program.\n" + " 2. The variable to be fetched is not an input or output of any " + "operator.", + var_name)); auto &vars = fetched_var_it->second; -- GitLab