未验证 提交 dfd6a62a 编写于 作者: W wopeizl 提交者: GitHub

Optimize the error report information when loadcombine fail to open model...

Optimize the error report information when loadcombine fail to open model files test=develop (#18888)
上级 adcfc53b
...@@ -41,10 +41,15 @@ class LoadCombineOpKernel : public framework::OpKernel<T> { ...@@ -41,10 +41,15 @@ class LoadCombineOpKernel : public framework::OpKernel<T> {
if (!model_from_memory) { if (!model_from_memory) {
std::ifstream fin(filename, std::ios::binary); std::ifstream fin(filename, std::ios::binary);
PADDLE_ENFORCE(static_cast<bool>(fin), PADDLE_ENFORCE(static_cast<bool>(fin),
"Cannot open file %s for load_combine op", filename); "OP(LoadCombine) fail to open file %s, please check "
"whether the model file is complete or damaged.",
filename);
LoadParamsFromBuffer(ctx, place, &fin, load_as_fp16, out_var_names); LoadParamsFromBuffer(ctx, place, &fin, load_as_fp16, out_var_names);
} else { } else {
PADDLE_ENFORCE(!filename.empty(), "Cannot load file from memory"); PADDLE_ENFORCE(!filename.empty(),
"OP(LoadCombine) fail to open file %s, please check "
"whether the model file is complete or damaged.",
filename);
std::stringstream fin(filename, std::ios::in | std::ios::binary); std::stringstream fin(filename, std::ios::in | std::ios::binary);
LoadParamsFromBuffer(ctx, place, &fin, load_as_fp16, out_var_names); LoadParamsFromBuffer(ctx, place, &fin, load_as_fp16, out_var_names);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册