[Frontend] pickle.dumps support for FrontEndManager (#6370)

* [Frontend] pickle.dumps support for FrontEndManager

* Fix clang-format

* Reorganize imports in test_frontendmanager.py
This commit is contained in:
Mikhail Nosov 2021-06-25 15:51:33 +03:00 committed by GitHub
parent 391aeebf7e
commit 9868bde421
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -21,6 +21,10 @@ void regclass_pyngraph_FrontEndManager(py::module m)
fem.def(py::init<>()); fem.def(py::init<>());
// Empty pickle dumps are supported as FrontEndManager doesn't have any state
fem.def(py::pickle([](const ngraph::frontend::FrontEndManager&) { return py::make_tuple(0); },
[](py::tuple t) { return ngraph::frontend::FrontEndManager(); }));
fem.def("get_available_front_ends", fem.def("get_available_front_ends",
&ngraph::frontend::FrontEndManager::get_available_front_ends, &ngraph::frontend::FrontEndManager::get_available_front_ends,
R"( R"(

View File

@ -1,13 +1,16 @@
# Copyright (C) 2018-2021 Intel Corporation # Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
import numpy as np import pickle
import pytest
from ngraph import PartialShape from ngraph import PartialShape
from ngraph.frontend import FrontEndCapabilities, FrontEndManager, InitializationFailure from ngraph.frontend import FrontEndCapabilities, FrontEndManager, InitializationFailure
from ngraph.utils.types import get_element_type from ngraph.utils.types import get_element_type
import numpy as np
import pytest
mock_available = True mock_available = True
try: try:
from pybind_mock_frontend import get_fe_stat, get_mdl_stat, get_place_stat from pybind_mock_frontend import get_fe_stat, get_mdl_stat, get_place_stat
@ -24,6 +27,10 @@ mock_needed = pytest.mark.skipif(not mock_available,
# ---------- FrontEnd tests --------------- # ---------- FrontEnd tests ---------------
def test_pickle():
pickle.dumps(fem)
@mock_needed @mock_needed
def test_load_by_framework_caps(): def test_load_by_framework_caps():
frontEnds = fem.get_available_front_ends() frontEnds = fem.get_available_front_ends()