Skip to content

Commit

Permalink
Fix missleading error message when bad path to onnx model is given (l…
Browse files Browse the repository at this point in the history
…lvm#1025)

* Fix missleading output when bad path to onnx model is given

Signed-off-by: Yasushi Negishi <negishi@jp.ibm.com>

* Simply the fix by avoiding to open the input file twice.

Signed-off-by: Yasushi Negishi <negishi@jp.ibm.com>
  • Loading branch information
negiyas committed Dec 2, 2021
1 parent ca7e746 commit f5da70c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Builder/FrontendDialectTransformer.cpp
Expand Up @@ -1433,6 +1433,11 @@ void ImportFrontendModelFile(std::string model_fname, MLIRContext &context,
OwningModuleRef &module, std::string *errorMessage, ImportOptions options) {
onnx::ModelProto model;
std::fstream input(model_fname, std::ios::in | std::ios::binary);
// check if the input file is opened
if (!input.is_open()) {
*errorMessage = "Unable to open or access " + model_fname;
return;
}

auto parse_success = model.ParseFromIstream(&input);
if (!parse_success) {
Expand Down

0 comments on commit f5da70c

Please sign in to comment.