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 cab1966ecc1a48e1eaf2ebb5810def33883da06f..aba8e5c6c976e4765ceaed799e3d8f542d355e9b 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 5ee47a3933bd2cd3c5f75b7627733f5659d71475..55ceb802eb8d6a6db3cade5969badfc1ee6f2541 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;