未验证 提交 06d4aa4e 编写于 作者: L liym27 提交者: GitHub

API (BuildStrategy) error message enhancement. (#23462)

上级 674355a0
...@@ -192,11 +192,24 @@ class ParallelExecutorPassBuilder : public ir::PassBuilder { ...@@ -192,11 +192,24 @@ class ParallelExecutorPassBuilder : public ir::PassBuilder {
CollectiveContext *context = CollectiveContext::GetInstance(); CollectiveContext *context = CollectiveContext::GetInstance();
context->endpoints_ = strategy_.trainers_endpoints_; context->endpoints_ = strategy_.trainers_endpoints_;
context->trainer_id_ = strategy_.trainer_id_; context->trainer_id_ = strategy_.trainer_id_;
PADDLE_ENFORCE_GE(strategy_.trainer_id_, 0, "trainer_id_ >= 0"); PADDLE_ENFORCE_GE(
strategy_.trainer_id_, 0,
platform::errors::InvalidArgument(
"The trainer_id_ of strategy_ must be greater than or equal to 0, "
"but received strategy_.trainer_id_ = %d.",
strategy_.trainer_id_));
if (strategy_.trainer_id_ > 0 && strategy_.trainers_endpoints_.size() > 0) { if (strategy_.trainer_id_ > 0 && strategy_.trainers_endpoints_.size() > 0) {
PADDLE_ENFORCE_LT(static_cast<size_t>(strategy_.trainer_id_), PADDLE_ENFORCE_LT(
strategy_.trainers_endpoints_.size(), static_cast<size_t>(strategy_.trainer_id_),
"trainer_id_ < endpoints_ size"); strategy_.trainers_endpoints_.size(),
platform::errors::InvalidArgument(
"The trainer_id_ of strategy_ must be less than the "
"size of vector strategy_.trainers_endpoints_, "
"but received strategy_.trainer_id_ = %d, "
"the size of strategy_.trainers_endpoints_ is %d.",
static_cast<size_t>(strategy_.trainer_id_),
strategy_.trainers_endpoints_.size()));
} }
VLOG(1) << "CollectiveContext:" << context->String(); VLOG(1) << "CollectiveContext:" << context->String();
} }
...@@ -269,8 +282,11 @@ class ParallelExecutorPassBuilder : public ir::PassBuilder { ...@@ -269,8 +282,11 @@ class ParallelExecutorPassBuilder : public ir::PassBuilder {
"FLAGS_use_mkldnn=false."; "FLAGS_use_mkldnn=false.";
} }
#else #else
PADDLE_ENFORCE(!FLAGS_use_mkldnn, PADDLE_ENFORCE_NE(FLAGS_use_mkldnn, true,
"Please compile with MKLDNN first to use MKLDNN"); platform::errors::PreconditionNotMet(
"FLAGS_use_mkldnn has been set to True, but "
"PaddlePaddle is compiled without MKLDNN. "
"Please compile PaddlePaddle with MKLDNN first."));
#endif #endif
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册