forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Py OV] Extend Model to utilize with-expressions (openvinotoolkit#27191)
### Details: - Implement `__enter__` and `__exit__` to create class-based context manager - Remove inheritance from ModelBase in ie_api.Model and make it an attribute. - add private property __model that stores `_pyopenvino.Model`. In `_pyopenvino` such attribute can be accessed as `_Model__model` because of name mangling - update pyAPI methods that have `std::shared_ptr<ov::Model>` in their signatures. - add `test_model_with_statement` and `test_model_tempdir_fails` ### Motivation: On Windows reading `ov.Model` from temporary directory leads to `PermissionError`: ```python mem_model = generate_model_with_memory(input_shape=Shape([2, 1]), data_type=Type.f32) with tempfile.TemporaryDirectory() as model_save_dir: save_model(mem_model, f"{model_save_dir}/model.xml") model = Core().read_model(f"{model_save_dir}/model.xml") ``` ### Tickets: - CVS-106987 --------- Signed-off-by: Alicja Miloszewska <alicja.miloszewska@intel.com>
- Loading branch information
Showing
18 changed files
with
247 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2018-2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from .test_utils_api import compare_functions as compare_functions_base | ||
from openvino.runtime import Model | ||
|
||
|
||
def compare_functions(lhs: Model, rhs: Model, compare_tensor_names: bool = True) -> tuple: | ||
return compare_functions_base(lhs._Model__model, rhs._Model__model, compare_tensor_names) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.