add check for num_rows

This commit is contained in:
yanghaitao 2020-06-12 14:56:51 +08:00
parent a6a9f88453
commit 20524f37e4
2 changed files with 10 additions and 0 deletions

View File

@ -116,6 +116,11 @@ Status ImageFolderOp::PrescanMasterEntry(const std::string &filedir) {
}
image_label_pairs_.shrink_to_fit();
num_rows_ = image_label_pairs_.size();
if (num_rows_ == 0) {
RETURN_STATUS_UNEXPECTED(
"There is no valid data matching the dataset API ImageFolderDatasetV2.Please check file path or dataset "
"API validation first.");
}
// free memory of two queues used for pre-scan
folder_name_queue_->Reset();
image_name_queue_->Reset();

View File

@ -350,6 +350,11 @@ Status MnistOp::ParseMnistData() {
}
image_label_pairs_.shrink_to_fit();
num_rows_ = image_label_pairs_.size();
if (num_rows_ == 0) {
RETURN_STATUS_UNEXPECTED(
"There is no valid data matching the dataset API MnistDataset.Please check file path or dataset API "
"validation first.");
}
return Status::OK();
}