Skip to content

Commit

Permalink
Move frontend changes to pyopenvino
Browse files Browse the repository at this point in the history
Signed-off-by: Alicja Miloszewska <[email protected]>
  • Loading branch information
almilosz committed Dec 19, 2024
1 parent 547c359 commit a01c519
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src/bindings/python/src/openvino/frontend/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def __init__(self, fe: FrontEndBase) -> None:
super().__init__(fe)

def convert(self, model: Union[Model, InputModel]) -> Model:
if isinstance(model, Model):
model = model._Model__model
converted_model = super().convert(model)
if isinstance(model, InputModel):
return Model(converted_model)
Expand All @@ -29,7 +27,7 @@ def decode(self, model: InputModel) -> Model:
return Model(super().decode(model))

def normalize(self, model: Model) -> None:
super().normalize(model._Model__model)
super().normalize(model)


class FrontEndManager(FrontEndManagerBase):
Expand Down
22 changes: 14 additions & 8 deletions src/bindings/python/src/pyopenvino/frontend/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,13 @@ void regclass_frontend_FrontEnd(py::module m) {
:rtype: openvino.runtime.Model
)");

fem.def("convert",
static_cast<void (FrontEnd::*)(const std::shared_ptr<ov::Model>&) const>(&FrontEnd::convert),
py::arg("model"),
R"(
fem.def(
"convert",
[](FrontEnd& self, const py::object& ie_api_model) {
return self.convert(Common::utils::convert_to_model(ie_api_model));
},
py::arg("model"),
R"(
Completely convert the remaining, not converted part of a function.
:param model: Partially converted OpenVINO model.
Expand Down Expand Up @@ -153,10 +156,13 @@ void regclass_frontend_FrontEnd(py::module m) {
:rtype: openvino.runtime.Model
)");

fem.def("normalize",
&FrontEnd::normalize,
py::arg("model"),
R"(
fem.def(
"normalize",
[](FrontEnd& self, const py::object& ie_api_model) {
self.normalize(Common::utils::convert_to_model(ie_api_model));
},
py::arg("model"),
R"(
Runs normalization passes on function that was loaded with partial conversion.
:param model : Partially converted OpenVINO model.
Expand Down
6 changes: 3 additions & 3 deletions src/bindings/python/tests/test_runtime/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,16 +829,16 @@ def test_model_with_statement():

with Core().read_model(f"{model_save_dir}/model.xml") as model:
assert mem_model.friendly_name == model.friendly_name

with pytest.raises(AttributeError):
save_model(model, f"{model_save_dir}/model.xml")

# Behavior after exiting the context manager
with mem_model as model:
pass
assert type(mem_model) == Model
assert isinstance(mem_model, Model)
with pytest.raises(AttributeError, match="attribute is no longer accessible."):
model.friendly_name
model.friendly_name


@pytest.mark.skipif(sys.platform != "win32", reason="Windows only")
Expand Down

0 comments on commit a01c519

Please sign in to comment.