Optimize the error report information when loadcombine fail to open model files test=develop (#18888)

padding_in_crf
wopeizl 6 years ago committed by GitHub
parent adcfc53b18
commit dfd6a62a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -41,10 +41,15 @@ class LoadCombineOpKernel : public framework::OpKernel<T> {
if (!model_from_memory) {
std::ifstream fin(filename, std::ios::binary);
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);
} 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);
LoadParamsFromBuffer(ctx, place, &fin, load_as_fp16, out_var_names);
}

Loading…
Cancel
Save