-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ONNX Frontend instead of ONNX Reader #7031
Changes from 33 commits
9ec27f5
67cfdd4
cf64e13
714d444
90cd973
d8a4e22
2129dae
aa5bb21
9264675
3f5c55e
51b31c7
f16c67a
1de22dd
f4a4bab
4ca5317
48ad76a
adfd5ab
c5b90ed
b66e61c
cad333b
563afaa
a8aabaf
7eda63e
7e9c2bd
e8b8432
a7de4c9
8112b7d
b295719
3e80a35
422e757
0f0717c
7f8c848
bfa4267
ccfb492
f78d3bc
2728690
a93a14b
44b7642
9aab1cb
3f4edbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,14 +115,6 @@ void registerReaders() { | |
return std::make_shared<Reader>(name, library_name); | ||
}; | ||
|
||
// try to load ONNX reader if library exists | ||
auto onnxReader = | ||
create_if_exists("ONNX", std::string("inference_engine_onnx_reader") + std::string(IE_BUILD_POSTFIX)); | ||
if (onnxReader) { | ||
readers.emplace("onnx", onnxReader); | ||
readers.emplace("prototxt", onnxReader); | ||
} | ||
|
||
// try to load IR reader v10 if library exists | ||
auto irReaderv10 = | ||
create_if_exists("IRv10", std::string("inference_engine_ir_reader") + std::string(IE_BUILD_POSTFIX)); | ||
|
@@ -174,10 +166,6 @@ CNNNetwork details::ReadNetwork(const std::string& modelPath, | |
#endif | ||
// Try to open model file | ||
std::ifstream modelStream(model_path, std::ios::binary); | ||
// save path in extensible array of stream | ||
// notice: lifetime of path pointed by pword(0) is limited by current scope | ||
const std::string path_to_save_in_stream = modelPath; | ||
modelStream.pword(0) = const_cast<char*>(path_to_save_in_stream.c_str()); | ||
if (!modelStream.is_open()) | ||
IE_THROW() << "Model file " << modelPath << " cannot be opened!"; | ||
|
||
|
@@ -259,7 +247,7 @@ CNNNetwork details::ReadNetwork(const std::string& modelPath, | |
} | ||
if (inputModel) { | ||
auto ngFunc = FE->convert(inputModel); | ||
return CNNNetwork(ngFunc); | ||
return CNNNetwork(ngFunc, exts); | ||
} | ||
IE_THROW() << "Unknown model format! Cannot find reader for model format: " << fileExt | ||
<< " and read the model: " << modelPath << ". Please check that reader library exists in your PATH."; | ||
|
@@ -282,6 +270,19 @@ CNNNetwork details::ReadNetwork(const std::string& model, | |
return reader->read(modelStream, exts); | ||
} | ||
} | ||
// Try to load with FrontEndManager | ||
// NOTE: weights argument is ignored | ||
static ngraph::frontend::FrontEndManager manager; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use one instance of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
ngraph::frontend::FrontEnd::Ptr FE; | ||
ngraph::frontend::InputModel::Ptr inputModel; | ||
FE = manager.load_by_model(&modelStream); | ||
if (FE) | ||
inputModel = FE->load(&modelStream); | ||
if (inputModel) { | ||
auto ngFunc = FE->convert(inputModel); | ||
return CNNNetwork(ngFunc, exts); | ||
} | ||
|
||
IE_THROW() << "Unknown model format! Cannot find reader for the model and read it. Please check that reader " | ||
"library exists in your PATH."; | ||
} | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
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.
Why do we need this change?
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.
If we have a scenario
Passing
exts
is needed. It is tested byCustomOpUser_ONNXImporter
unit test