-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Add error checking for cpp examples. #13828
Conversation
cpp-package/example/mlp_cpu.cpp
Outdated
@@ -63,10 +63,14 @@ int main(int argc, char** argv) { | |||
}; | |||
|
|||
auto train_iter = MXDataIter("MNISTIter"); | |||
setDataIter(&train_iter, "Train", data_files, batch_size); | |||
if (!setDataIter(&train_iter, "Train", data_files, batch_size)) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing return value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
@@ -244,10 +244,14 @@ int main(int argc, char const *argv[]) { | |||
}; | |||
|
|||
auto train_iter = MXDataIter("MNISTIter"); | |||
setDataIter(&train_iter, "Train", data_files, batch_size); | |||
if (!setDataIter(&train_iter, "Train", data_files, batch_size)) { | |||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have some descriptive error messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message already printed in check_datafiles()
@mxnet-label-bot add [pr-awaiting-review] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for addressing my comments. Can you take a look at the CI failure?
Restarted the test |
Description
In current cpp example, if data file isn't exist, example application will crash with sig 11 .
Add error checking to avoid crash.
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.