forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert_model() in openvino.runtime. (openvinotoolkit#18080)
* Used pip wheel to build OpenVINO wheel * Added convert_model() to openvino.runtime. * Removed duplication of InputCutInfo, LayoutMap * Switched Model Conversion API tests to convert_model from openvino.runtime. * Small correction. * Format correction. * Small correction. * Removed duplication of moc frontend files. * Small correction. * Removed duplication of cli_parser, offline_transformations. * Code corrections. * Removed code duplications. * Removed code duplications. * Updated codeowners. * Switched layer tests to convert_model(). * Improvements * Small correction. * Caffe parser path fix. * Added python api properly into deb / rpm packages * Moved implementation to ovc tool. * Moved implementation to ovc tool. * Small correction. * Use cmake -E variant from cmake 3.13 * Namespace fixes. * Minor fixes. * Pylint fixes. * Fixed BOM file. * Small corrections. * Minor corrections. * Minor fix. * Error fixes. * Added telemetry requirement. * Improvements to fix CI * Some refactoring * Don't use developer package for scripts projects * Added exception in case when MO is not imported. * Removed exception from init. * Removed changes from cmake. * Added unit ovc tests, fixed minor errors. * Added ovc unit tests to azure. * Corrected imports. * Fixed path to tests. * Added missed files. * Corrected github labels. * Removed benchmark app from dev package. * Small fix. * Small corrections. * Comment fixed. * Removed changes from setup.py * Removed not needed change. * Removed duplicating unit tests. * Removed wrong change. * Removed not needed change. * Apply suggestions from code review Co-authored-by: Roman Kazantsev <[email protected]> * Added ovc tool test, corrected imports. * Added legacy TF config test. * Removed not needed files. --------- Co-authored-by: Ilya Lavrenov <[email protected]> Co-authored-by: Roman Kazantsev <[email protected]>
- Loading branch information
1 parent
a2b7d56
commit 5d399fa
Showing
133 changed files
with
11,059 additions
and
3,017 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
Validating CODEOWNERS rules …
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
numpy>=1.16.6 | ||
singledispatchmethod; python_version<'3.8' | ||
openvino-telemetry>=2023.0.0 |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Copyright (C) 2018-2023 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from openvino.tools.mo import convert_model | ||
from openvino.runtime import convert_model | ||
|
||
if __name__ == "__main__": | ||
convert_model(help=True) |
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
89 changes: 89 additions & 0 deletions
89
tests/layer_tests/mo_python_api_tests/test_ovc_cli_tool.py
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,89 @@ | ||
# Copyright (C) 2018-2023 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
import openvino.runtime as ov | ||
from openvino.runtime import PartialShape, Model | ||
from openvino.test_utils import compare_functions | ||
from openvino.tools.ovc import ovc | ||
|
||
from common.mo_convert_test_class import CommonMOConvertTest | ||
from common.tf_layer_test_class import save_to_pb | ||
from common.utils.common_utils import shell | ||
|
||
|
||
def generate_ir_ovc(coverage=False, **kwargs): | ||
# Get OVC file directory | ||
ovc_path = Path(ovc.__file__).parent | ||
|
||
ovc_runner = ovc_path.joinpath('main.py').as_posix() | ||
if coverage: | ||
params = [sys.executable, '-m', 'coverage', 'run', '-p', '--source={}'.format(ovc_runner.parent), | ||
'--omit=*_test.py', ovc_runner] | ||
else: | ||
params = [sys.executable, ovc_runner] | ||
for key, value in kwargs.items(): | ||
if key == "batch": | ||
params.extend(("-b", str(value))) | ||
elif key == "k": | ||
params.extend(("-k", str(value))) | ||
# for FP32 set explicitly compress_to_fp16=False, | ||
# if we omit this argument for FP32, it will be set implicitly to True as the default | ||
elif key == 'compress_to_fp16': | ||
params.append("--{}={}".format(key, value)) | ||
elif isinstance(value, bool) and value: | ||
params.append("--{}".format(key)) | ||
elif isinstance(value, bool) and not value: | ||
continue | ||
elif (isinstance(value, tuple) and value) or (isinstance(value, str)): | ||
params.extend(("--{}".format(key), str('"{}"'.format(value)))) | ||
elif key == "mean_values" and (' ' in value or '(' in value): | ||
params.extend(("--{}".format(key), str('"{}"'.format(value)))) | ||
else: | ||
params.extend(("--{}".format(key), str(value))) | ||
exit_code, stdout, stderr = shell(params) | ||
return exit_code, stderr | ||
|
||
def create_ref_graph(): | ||
shape = PartialShape([1, 3, 2, 2]) | ||
param = ov.opset8.parameter(shape, dtype=np.float32) | ||
relu = ov.opset8.relu(param) | ||
sigm = ov.opset8.sigmoid(relu) | ||
|
||
return Model([sigm], [param], "test") | ||
|
||
class TestOVCTool(CommonMOConvertTest): | ||
def create_tf_model(self, tmp_dir): | ||
import tensorflow as tf | ||
|
||
tf.compat.v1.reset_default_graph() | ||
|
||
with tf.compat.v1.Session() as sess: | ||
inp = tf.compat.v1.placeholder(tf.float32, [1, 3, 2, 2], 'Input') | ||
relu = tf.nn.relu(inp, name='Relu') | ||
output = tf.nn.sigmoid(relu, name='Sigmoid') | ||
tf.compat.v1.global_variables_initializer() | ||
tf_net = sess.graph_def | ||
|
||
# save model to .pb and return path to the model | ||
return save_to_pb(tf_net, tmp_dir) | ||
|
||
|
||
def test_ovc_tool(self, ie_device, precision, ir_version, temp_dir, use_new_frontend, use_old_api): | ||
from openvino.runtime import Core | ||
|
||
model_path = self.create_tf_model(temp_dir) | ||
|
||
core = Core() | ||
|
||
# tests for MO cli tool | ||
exit_code, stderr = generate_ir_ovc(coverage=False, **{"input_model": model_path, "output_dir": temp_dir}) | ||
assert not exit_code | ||
|
||
ov_model = core.read_model(os.path.join(temp_dir, "model.xml")) | ||
flag, msg = compare_functions(ov_model, create_ref_graph(), False) | ||
assert flag, msg |
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.