OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[PyOV] Update Python API stub files (#34647)
sys-openvino-cie32ac138d59f
diff --git a/src/bindings/python/src/openvino/_pyopenvino/__init__.pyi b/src/bindings/python/src/openvino/_pyopenvino/__init__.pyiindex b6c707272d9..f1ece401d41 100644--- a/src/bindings/python/src/openvino/_pyopenvino/__init__.pyi+++ b/src/bindings/python/src/openvino/_pyopenvino/__init__.pyi@@ -553,7 +553,7 @@ class Core:def __repr__(self) -> str:...@typing.overload- def add_extension(self, library_path: str) -> None:+ def add_extension(self, library_path: os.PathLike | str | bytes) -> None:"""Registers an extension to a Core object.@@ -628,7 +628,7 @@ class Core:GIL is released while running this function.:param model_path: A path to a model in IR / ONNX / PDPD / TF and TFLite format.- :type model_path: typing.Union[str, pathlib.Path]+ :type model_path: Union[str, bytes, pathlib.Path]:param device_name: Name of the device to load the model to.:type device_name: str:param properties: Optional dict of pairs: (property name, property value) relevant only for this load operation.@@ -666,7 +666,7 @@ class Core:GIL is released while running this function.:param model_path: A path to a model in IR / ONNX / PDPD / TF and TFLite format.- :type model_path: typing.Union[str, pathlib.Path]+ :type model_path: Union[str, bytes, pathlib.Path]:param properties: Optional dict of pairs: (property name, property value) relevant only for this load operation.:type properties: dict[str, typing.Any]:return: A compiled model.@@ -847,28 +847,6 @@ class Core::rtype: openvino.Model"""@typing.overload- def read_model(self, model: str, weights: str = '', config: collections.abc.Mapping[str, typing.Any] = {}) -> Model:- """- Reads models from IR / ONNX / PDPD / TF and TFLite formats.-- GIL is released while running this function.-- :param model: A path to a model in IR / ONNX / PDPD / TF and TFLite format.- :type model: str- :param weights: A path to a data file For IR format (*.bin): if path is empty,- it tries to read a bin file with the same name as xml and if the bin- file with the same name was not found, loads IR without weights.- For ONNX format (*.onnx): weights parameter is not used.- For PDPD format (*.pdmodel) weights parameter is not used.- For TF format (*.pb) weights parameter is not used.- For TFLite format (*.tflite) weights parameter is not used.- :type weights: str- :param config: Optional map of pairs: (property name, property value) relevant only for this read operation.- :type config: dict[str, typing.Any], optional- :return: A model.- :rtype: openvino.Model- """- @typing.overloaddef read_model(self, model: str, weights: Tensor) -> Model:"""Reads models from IR / ONNX / PDPD / TF and TFLite formats.@@ -890,8 +868,8 @@ class Core:GIL is released while running this function.- :param model: A path to a model in IR / ONNX / PDPD / TF and TFLite format or a model itself wrapped in io.ByesIO format.- :type model: typing.Union[pathlib.Path, io.BytesIO]+ :param model: A path to a model in IR / ONNX / PDPD / TF and TFLite format or a model itself wrapped in io.BytesIO format.+ :type model: Union[str, pathlib.Path, io.BytesIO]:param weights: A path to a data file For IR format (*.bin): if path is empty,it tries to read a bin file with the same name as xml and if the binfile with the same name was not found, loads IR without weights.@@ -899,7 +877,7 @@ class Core:For PDPD format (*.pdmodel) weights parameter is not used.For TF format (*.pb): weights parameter is not used.For TFLite format (*.tflite) weights parameter is not used.- :type weights: typing.Union[pathlib.Path, io.BytesIO]+ :type weights: Union[str, pathlib.Path, io.BytesIO]:param config: Optional map of pairs: (property name, property value) relevant only for this read operation.:type config: dict[str, typing.Any], optional:return: A model.@@ -1474,12 +1452,12 @@ class FrontEndManager:"""Selects and loads appropriate frontend depending on model type or model file extension and other file info (header).- :param model_path: A model object or path to a model file/directory.- :type model_path: Any+ :param model: A model object or path to a model file/directory.+ :type model: Any:return: Frontend interface for further loading of models. 'None' if no suitable frontend is found.:rtype: openvino.frontend.FrontEnd"""- def register_front_end(self, name: str, library_path: str) -> None:+ def register_front_end(self, name: str, library_path: typing.Any) -> None:"""Register frontend with name and factory loaded from provided library.@@ -1489,7 +1467,7 @@ class FrontEndManager::param library_path: Path (absolute or relative) or name of a frontend library. If name isprovided, depending on platform, it will be wrapped with shared library suffix and prefixto identify library full name.- :type library_path: str+ :type library_path: Union[str, pathlib.Path]:return: None"""diff --git a/src/bindings/python/src/openvino/tools/ovc/convert.pyi b/src/bindings/python/src/openvino/tools/ovc/convert.pyiindex 97d86f809d3..8f394793729 100644--- a/src/bindings/python/src/openvino/tools/ovc/convert.pyi+++ b/src/bindings/python/src/openvino/tools/ovc/convert.pyi@@ -8,7 +8,7 @@ from openvino.tools.ovc.logger import restore_logger_stateimport openvino._ov_apiimport pathlib as pathlib__all__: list[str] = ['Model', 'convert_model', 'get_all_cli_parser', 'get_logger_state', 'pathlib', 'restore_logger_state']-def convert_model(input_model: [str, pathlib.Path, typing.Any, list], input: [list, dict, str] = None, output: [str, list] = None, example_input: typing.Any = None, extension: [str, pathlib.Path, list, typing.Any] = None, verbose: bool = False, share_weights: bool = True) -> openvino._ov_api.Model:+def convert_model(input_model: [str, pathlib.Path, typing.Any, list], input: [list, dict, str] = None, output: [str, list] = None, example_input: typing.Any = None, extension: [str, pathlib.Path, list, typing.Any] = None, verbose: bool = False, share_weights: bool = True, dynamo: bool = False) -> openvino._ov_api.Model:"""Converts the model from original framework to OpenVino Model.@@ -83,6 +83,15 @@ def convert_model(input_model: [str, pathlib.Path, typing.Any, list], input: [lithen mmap is used to allocate weights directly from file. If input model isruntime object, then original memory regions allocated in the original modelare reused for weights in the converted model.+ :param dynamo:+ Export a PyTorch torch.nn.Module using torch.export instead of+ torch.jit.trace. Requires example_input and PyTorch >= 2.6.+ Default is False.+ The resulting model uses static shapes derived from example_input by default.+ To enable dynamic dimensions, combine with the input parameter:+ dimensions set to -1 or Dimension(-1) become fully dynamic+ (torch.export.Dim.AUTO), and bounded dimensions such as Dimension(1, 10)+ are exported with explicit min/max constraints.Returns:openvino.Modeldiff --git a/src/bindings/python/src/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.pyi b/src/bindings/python/src/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.pyiindex 1802dbcb64d..a379895076f 100644--- a/src/bindings/python/src/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.pyi+++ b/src/bindings/python/src/openvino/tools/ovc/moc_frontend/pytorch_frontend_utils.pyi@@ -3,13 +3,35 @@ from __future__ import annotationsfrom openvino._pyopenvino import PartialShapefrom openvino._pyopenvino import Tensorfrom openvino.tools.ovc.cli_parser import InputCutInfo as _InputCutInfo+from openvino.tools.ovc.cli_parser import input_to_input_cut_infofrom openvino.tools.ovc.cli_parser import single_input_to_input_cut_infofrom openvino.tools.ovc.error import Errorimport logging as logimport numpy as npimport pathlib as pathlibimport sys as sys-__all__: list[str] = ['Error', 'PartialShape', 'Tensor', 'extract_input_info_from_example', 'extract_module_extensions', 'flatten_inputs', 'get_pytorch_decoder', 'get_pytorch_decoder_for_model_on_disk', 'get_value_from_list_or_dict', 'log', 'np', 'pathlib', 'prepare_torch_inputs', 'single_input_to_input_cut_info', 'sys', 'to_torch_tensor', 'update_list_or_dict']+__all__: list[str] = ['Error', 'PartialShape', 'Tensor', 'extract_input_info_from_example', 'extract_module_extensions', 'flatten_inputs', 'get_pytorch_decoder', 'get_pytorch_decoder_for_model_on_disk', 'get_value_from_list_or_dict', 'input_to_input_cut_info', 'log', 'np', 'pathlib', 'prepare_torch_inputs', 'single_input_to_input_cut_info', 'sys', 'to_torch_tensor', 'update_list_or_dict']+def _build_dynamic_shapes(inputs, input_specs = None):+ """+ Build dynamic_shapes for torch.export.export.++ If input_specs (list of _InputCutInfo from the 'input' parameter) is provided+ and contains shapes, dimensions marked as -1 (fully dynamic) get Dim.AUTO,+ dimensions with min/max constraints (e.g. Dimension(1, 10)) get+ Dim("dI_D", min=..., max=...), and fixed dimensions stay static.+ When no specs are given returns None so that torch.export.export produces+ a fully static graph.++ The input_specs list is flat (one spec per leaf tensor), while inputs may+ contain nested tuples/lists (e.g. past_key_values). pytree is used to+ flatten inputs, pair each leaf with its spec, and then unflatten the+ result back into the original structure that torch.export expects.++ """+def _export_torch_model(model, inputs, input_specs = None):+ """+ Export a torch.nn.Module using torch.export.export with Dim.AUTO dynamic shapes.+ """def extract_input_info_from_example(args, inputs):...def extract_module_extensions(args):