From 6e4c2c5adae1d4d41a8e7892f6113d946fa44746 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Fri, 16 Jul 2021 17:11:59 +0800 Subject: [PATCH] [CPU-PSLIB] Add clearer error log when sparse key name is not int type, test=develop (#34173) (#34206) --- paddle/fluid/framework/fleet/fleet_wrapper.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/fleet/fleet_wrapper.cc b/paddle/fluid/framework/fleet/fleet_wrapper.cc index f80e735bdc7..6287c9d2acc 100644 --- a/paddle/fluid/framework/fleet/fleet_wrapper.cc +++ b/paddle/fluid/framework/fleet/fleet_wrapper.cc @@ -575,7 +575,14 @@ void FleetWrapper::PushSparseVarsWithLabelAsync( int64_t* ids = tensor->data(); int slot = 0; if (dump_slot) { - slot = boost::lexical_cast(sparse_key_names[i]); + try { + slot = boost::lexical_cast(sparse_key_names[i]); + } catch (boost::bad_lexical_cast const& e) { + PADDLE_THROW(platform::errors::PreconditionNotMet( + "sparse var's name: %s, doesn't support non-integer type name when " + "dump_slot=True", + sparse_key_names[i])); + } } Variable* g_var = scope.FindVar(sparse_grad_names[i]); if (g_var == nullptr) { -- GitLab