Skip to content
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

Merged
merged 40 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9ec27f5
added get_name
Aug 10, 2021
67cfdd4
add support to supported_impl
Aug 11, 2021
cf64e13
remove debug code
Aug 11, 2021
714d444
review remarks
Aug 12, 2021
90cd973
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 12, 2021
d8a4e22
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 12, 2021
2129dae
changed name to onnx_experimental
Aug 12, 2021
aa5bb21
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 12, 2021
9264675
fixed test
Aug 12, 2021
3f5c55e
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 13, 2021
51b31c7
revert onnx_experimental name
Aug 13, 2021
f16c67a
integrate reader and fe api
Aug 16, 2021
1de22dd
add unit tests
Aug 17, 2021
f4a4bab
removed prototxt from model_validator
Aug 17, 2021
4ca5317
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 17, 2021
48ad76a
reader refactor
Aug 17, 2021
adfd5ab
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 18, 2021
c5b90ed
add supress
Aug 18, 2021
b66e61c
Update inference-engine/src/readers/onnx_reader/ie_onnx_reader.cpp
Aug 18, 2021
cad333b
fix segfaults
Aug 18, 2021
563afaa
removed onnx reader
Aug 19, 2021
a8aabaf
handle istringstream
Aug 19, 2021
7eda63e
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 19, 2021
7e9c2bd
wstring support
Aug 20, 2021
e8b8432
removed saving path
Aug 20, 2021
a7de4c9
styles applied
Aug 20, 2021
8112b7d
changed name to onnx experimental
Aug 20, 2021
b295719
Apply suggestions from code review
Aug 20, 2021
3e80a35
Merge branch 'mbencer/LoadByModel' of github.com:mbencer/openvino int…
Aug 20, 2021
422e757
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 20, 2021
0f0717c
skip onnx_experimental frontend in mo.py
Aug 20, 2021
7f8c848
add support of wstring paths
Aug 23, 2021
bfa4267
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 23, 2021
ccfb492
fix wstring ctor of InputModelONNX
Aug 24, 2021
f78d3bc
added NGRAPH_SUPPRESS
Aug 24, 2021
2728690
make one instance of manager
Aug 24, 2021
a93a14b
change onnx_experimental name to onnx
Aug 24, 2021
44b7642
creation frontend manager refactor
Aug 25, 2021
9aab1cb
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 25, 2021
3f4edbf
Merge remote-tracking branch 'upstream/master' into mbencer/LoadByModel
Aug 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ namespace ngraph
std::shared_ptr<ngraph::Function> convert(InputModel::Ptr model) const override;
void convert(std::shared_ptr<ngraph::Function> partially_converted) const override;
std::shared_ptr<ngraph::Function> decode(InputModel::Ptr model) const override;
std::string get_name() const override;
bool supported_impl(
const std::vector<std::shared_ptr<Variant>>& variants) const override;

protected:
InputModel::Ptr
Expand Down
19 changes: 19 additions & 0 deletions ngraph/frontend/onnx/frontend/src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <frontend_manager/frontend_exceptions.hpp>
#include <frontend_manager/frontend_manager.hpp>
#include <input_model.hpp>
#include <ngraph/file_util.hpp>
#include <onnx_frontend/frontend.hpp>
#include <onnx_import/onnx.hpp>
#include <utils/onnx_internal.hpp>
Expand Down Expand Up @@ -54,3 +55,21 @@ std::shared_ptr<ngraph::Function> FrontEndONNX::decode(InputModel::Ptr model) co
NGRAPH_CHECK(model_onnx != nullptr, "Invalid input model");
return model_onnx->decode();
}

std::string FrontEndONNX::get_name() const
{
return "onnx_experimental";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "experimental"? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, we can change it to "onnx", but onnx frontend is still skipped in mo.py

}

bool FrontEndONNX::supported_impl(const std::vector<std::shared_ptr<Variant>>& variants) const
{
if (variants.size() > 0 && is_type<VariantWrapper<std::string>>(variants[0]))
{
const auto path = as_type_ptr<VariantWrapper<std::string>>(variants[0])->get();
if (file_util::get_file_ext(path) == ".onnx")
{
return true;
}
}
return false;
}
15 changes: 15 additions & 0 deletions ngraph/python/tests/test_frontend/test_frontend_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,18 @@ def test_decode_and_convert():
b = np.array([[2, 3], [4, 5]], dtype=np.float32)
expected = np.array([[1.5, 5], [10.5, 18]], dtype=np.float32)
run_function(decoded_function, a, b, expected=[expected])


def test_load_by_model():
skip_if_onnx_frontend_is_disabled()

fe = fem.load_by_model(onnx_model_filename)
assert fe
assert fe.get_name() == "onnx_experimental"
model = fe.load(onnx_model_filename)
assert model
decoded_function = fe.decode(model)
assert decoded_function

assert not fem.load_by_model("test.xx")
assert not fem.load_by_model("onnx.yy")