[Python API] Rename offline_transformations in the new api (#9634)
* [Python API] Rename offline_transformations in the new api * remove comments * one more place to rename * fix mo building * fix after merge * fix for pot import
This commit is contained in:
parent
97df59a4ab
commit
8f12b72f46
@ -40,9 +40,8 @@ packages = [
|
|||||||
"ngraph.impl.op.util",
|
"ngraph.impl.op.util",
|
||||||
"ngraph.impl.passes",
|
"ngraph.impl.passes",
|
||||||
"openvino",
|
"openvino",
|
||||||
# TODO: change the module name according to the description in 69196
|
|
||||||
"openvino.frontend",
|
"openvino.frontend",
|
||||||
"openvino.offline_transformations_pybind",
|
"openvino.offline_transformations",
|
||||||
"openvino.runtime.opset1",
|
"openvino.runtime.opset1",
|
||||||
"openvino.runtime.opset2",
|
"openvino.runtime.opset2",
|
||||||
"openvino.runtime.opset3",
|
"openvino.runtime.opset3",
|
||||||
|
@ -29,13 +29,13 @@ if sys.platform == "win32":
|
|||||||
os.environ["PATH"] = os.path.abspath(lib_path) + ";" + os.environ["PATH"]
|
os.environ["PATH"] = os.path.abspath(lib_path) + ";" + os.environ["PATH"]
|
||||||
|
|
||||||
|
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import apply_moc_transformations
|
from openvino.pyopenvino.offline_transformations import apply_moc_transformations
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import apply_moc_legacy_transformations
|
from openvino.pyopenvino.offline_transformations import apply_moc_legacy_transformations
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import apply_pot_transformations
|
from openvino.pyopenvino.offline_transformations import apply_pot_transformations
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import apply_low_latency_transformation
|
from openvino.pyopenvino.offline_transformations import apply_low_latency_transformation
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import apply_pruning_transformation
|
from openvino.pyopenvino.offline_transformations import apply_pruning_transformation
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import generate_mapping_file
|
from openvino.pyopenvino.offline_transformations import generate_mapping_file
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import apply_make_stateful_transformation
|
from openvino.pyopenvino.offline_transformations import apply_make_stateful_transformation
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import serialize
|
from openvino.pyopenvino.offline_transformations import serialize
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import compress_model_transformation
|
from openvino.pyopenvino.offline_transformations import compress_model_transformation
|
||||||
from openvino.pyopenvino.offline_transformations_pybind import compress_quantize_weights_transformation
|
from openvino.pyopenvino.offline_transformations import compress_quantize_weights_transformation
|
@ -37,9 +37,7 @@ inline Version convert_to_version(const std::string& version) {
|
|||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
|
|
||||||
void regmodule_offline_transformations(py::module m) {
|
void regmodule_offline_transformations(py::module m) {
|
||||||
// TODO: change the submodule name according to the description in 69196
|
py::module m_offline_transformations = m.def_submodule("offline_transformations", "Offline transformations module");
|
||||||
py::module m_offline_transformations =
|
|
||||||
m.def_submodule("offline_transformations_pybind", "Offline transformations module");
|
|
||||||
|
|
||||||
m_offline_transformations.def(
|
m_offline_transformations.def(
|
||||||
"apply_moc_transformations",
|
"apply_moc_transformations",
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import numpy as np
|
import numpy as np
|
||||||
# TODO: change the module name according to the description in 69196
|
from openvino.offline_transformations import apply_moc_transformations, apply_pot_transformations, \
|
||||||
from openvino.offline_transformations_pybind import apply_moc_transformations, apply_pot_transformations, \
|
|
||||||
apply_low_latency_transformation, apply_pruning_transformation, apply_make_stateful_transformation, \
|
apply_low_latency_transformation, apply_pruning_transformation, apply_make_stateful_transformation, \
|
||||||
compress_model_transformation, serialize
|
compress_model_transformation, serialize
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
if(NOT ENABLE_PYTHON)
|
if(NOT ENABLE_PYTHON)
|
||||||
message(WARNING "Please enable IE & nGraph Python API (ie_api and offline_transformations_api) targets to enable Model Optimizer target")
|
message(WARNING "Please enable IE & nGraph Python API (pyopenvino) targets to enable Model Optimizer target")
|
||||||
else()
|
else()
|
||||||
add_custom_target(model_optimizer DEPENDS ie_api offline_transformations_api ov_ir_frontend pyopenvino)
|
add_custom_target(model_optimizer DEPENDS ie_api ov_ir_frontend pyopenvino)
|
||||||
if(ENABLE_TESTS)
|
if(ENABLE_TESTS)
|
||||||
add_subdirectory(unit_tests/mock_mo_frontend/ov_mock_mo_frontend)
|
add_subdirectory(unit_tests/mock_mo_frontend/ov_mock_mo_frontend)
|
||||||
add_dependencies(model_optimizer ov_mock_mo_frontend)
|
add_dependencies(model_optimizer ov_mock_mo_frontend)
|
||||||
|
@ -11,9 +11,9 @@ from openvino.tools.mo.utils.error import Error
|
|||||||
|
|
||||||
def get_available_transformations():
|
def get_available_transformations():
|
||||||
try:
|
try:
|
||||||
from openvino.offline_transformations_pybind import apply_low_latency_transformation # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import apply_low_latency_transformation # pylint: disable=import-error,no-name-in-module
|
||||||
from openvino.offline_transformations_pybind import apply_make_stateful_transformation # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import apply_make_stateful_transformation # pylint: disable=import-error,no-name-in-module
|
||||||
from openvino.offline_transformations_pybind import apply_pruning_transformation # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import apply_pruning_transformation # pylint: disable=import-error,no-name-in-module
|
||||||
return {
|
return {
|
||||||
'MakeStateful': apply_make_stateful_transformation,
|
'MakeStateful': apply_make_stateful_transformation,
|
||||||
'LowLatency2': apply_low_latency_transformation,
|
'LowLatency2': apply_low_latency_transformation,
|
||||||
@ -35,17 +35,17 @@ def apply_user_transformations(func: object, transforms: list):
|
|||||||
|
|
||||||
|
|
||||||
def apply_moc_transformations(func: object):
|
def apply_moc_transformations(func: object):
|
||||||
from openvino.offline_transformations_pybind import apply_moc_transformations # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import apply_moc_transformations # pylint: disable=import-error,no-name-in-module
|
||||||
apply_moc_transformations(func, False)
|
apply_moc_transformations(func, False)
|
||||||
|
|
||||||
|
|
||||||
def apply_moc_legacy_transformations(func: object, params_with_custom_types: List[str]):
|
def apply_moc_legacy_transformations(func: object, params_with_custom_types: List[str]):
|
||||||
from openvino.offline_transformations_pybind import apply_moc_legacy_transformations # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import apply_moc_legacy_transformations # pylint: disable=import-error,no-name-in-module
|
||||||
apply_moc_legacy_transformations(func, params_with_custom_types)
|
apply_moc_legacy_transformations(func, params_with_custom_types)
|
||||||
|
|
||||||
|
|
||||||
def compress_model(func: object):
|
def compress_model(func: object):
|
||||||
from openvino.offline_transformations_pybind import compress_model_transformation # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import compress_model_transformation # pylint: disable=import-error,no-name-in-module
|
||||||
compress_model_transformation(func)
|
compress_model_transformation(func)
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ def apply_offline_transformations(input_model: str, argv: argparse.Namespace):
|
|||||||
# to produce correct mapping
|
# to produce correct mapping
|
||||||
extract_names = argv.framework in ['tf', 'mxnet', 'kaldi']
|
extract_names = argv.framework in ['tf', 'mxnet', 'kaldi']
|
||||||
|
|
||||||
from openvino.offline_transformations_pybind import generate_mapping_file, serialize # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import generate_mapping_file, serialize # pylint: disable=import-error,no-name-in-module
|
||||||
from openvino.frontend import FrontEndManager # pylint: disable=no-name-in-module,import-error
|
from openvino.frontend import FrontEndManager # pylint: disable=no-name-in-module,import-error
|
||||||
from openvino.tools.mo.back.preprocessing import apply_preprocessing # pylint: disable=no-name-in-module,import-error
|
from openvino.tools.mo.back.preprocessing import apply_preprocessing # pylint: disable=no-name-in-module,import-error
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ def moc_emit_ir(ngraph_function: Model, argv: argparse.Namespace):
|
|||||||
|
|
||||||
apply_user_transformations(ngraph_function, parse_transform(argv.transform))
|
apply_user_transformations(ngraph_function, parse_transform(argv.transform))
|
||||||
apply_moc_transformations(ngraph_function)
|
apply_moc_transformations(ngraph_function)
|
||||||
from openvino.offline_transformations_pybind import compress_quantize_weights_transformation
|
from openvino.offline_transformations import compress_quantize_weights_transformation
|
||||||
compress_quantize_weights_transformation(ngraph_function)
|
compress_quantize_weights_transformation(ngraph_function)
|
||||||
|
|
||||||
if argv.framework == "onnx":
|
if argv.framework == "onnx":
|
||||||
@ -39,7 +39,7 @@ def moc_emit_ir(ngraph_function: Model, argv: argparse.Namespace):
|
|||||||
|
|
||||||
orig_model_name = os.path.normpath(os.path.join(output_dir, argv.model_name))
|
orig_model_name = os.path.normpath(os.path.join(output_dir, argv.model_name))
|
||||||
|
|
||||||
from openvino.offline_transformations_pybind import serialize # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import serialize # pylint: disable=import-error,no-name-in-module
|
||||||
serialize(ngraph_function, (orig_model_name + ".xml").encode('utf-8'), (orig_model_name + ".bin").encode('utf-8'))
|
serialize(ngraph_function, (orig_model_name + ".xml").encode('utf-8'), (orig_model_name + ".bin").encode('utf-8'))
|
||||||
|
|
||||||
del argv.feManager
|
del argv.feManager
|
||||||
|
@ -48,10 +48,10 @@ def import_core_modules(silent: bool, path_to_module: str):
|
|||||||
:return: True if all imports were successful and False otherwise
|
:return: True if all imports were successful and False otherwise
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
from openvino.offline_transformations_pybind import apply_moc_transformations, apply_moc_legacy_transformations, \
|
from openvino.offline_transformations import apply_moc_transformations, apply_moc_legacy_transformations,\
|
||||||
apply_low_latency_transformation # pylint: disable=import-error,no-name-in-module
|
apply_low_latency_transformation # pylint: disable=import-error,no-name-in-module
|
||||||
from openvino.offline_transformations_pybind import apply_make_stateful_transformation, generate_mapping_file # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import apply_make_stateful_transformation, generate_mapping_file # pylint: disable=import-error,no-name-in-module
|
||||||
from openvino.offline_transformations_pybind import generate_mapping_file, apply_make_stateful_transformation, serialize # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations import generate_mapping_file, apply_make_stateful_transformation, serialize # pylint: disable=import-error,no-name-in-module
|
||||||
|
|
||||||
from openvino.runtime import Model, get_version # pylint: disable=import-error,no-name-in-module
|
from openvino.runtime import Model, get_version # pylint: disable=import-error,no-name-in-module
|
||||||
from openvino.runtime.op import Parameter # pylint: disable=import-error,no-name-in-module
|
from openvino.runtime.op import Parameter # pylint: disable=import-error,no-name-in-module
|
||||||
|
@ -9,6 +9,9 @@ from openvino.tools.mo.utils.ir_reader.restore_graph import restore_graph_from_i
|
|||||||
from openvino.tools.mo.utils.logger import init_logger
|
from openvino.tools.mo.utils.logger import init_logger
|
||||||
from openvino.runtime import Core # pylint: disable=E0401,E0611
|
from openvino.runtime import Core # pylint: disable=E0401,E0611
|
||||||
from openvino.runtime.passes import Manager # pylint: disable=E0401,E0611
|
from openvino.runtime.passes import Manager # pylint: disable=E0401,E0611
|
||||||
|
try:
|
||||||
|
from openvino.offline_transformations import apply_pot_transformations # pylint: disable=import-error,no-name-in-module
|
||||||
|
except ImportError:
|
||||||
from openvino.offline_transformations_pybind import apply_pot_transformations # pylint: disable=import-error,no-name-in-module
|
from openvino.offline_transformations_pybind import apply_pot_transformations # pylint: disable=import-error,no-name-in-module
|
||||||
|
|
||||||
from ..graph.passes import ModelPreprocessor, remove_converts, add_removed_converts
|
from ..graph.passes import ModelPreprocessor, remove_converts, add_removed_converts
|
||||||
|
Loading…
Reference in New Issue
Block a user