OVC cleanup. (#18649)

* WIP: parameters cleanup

* Removed debug output, fixed CLI

* Fixed python objects conversion

* Finally renamed mmap to share_weights

* Fixed TF conversion from a file or a directory

* Fixed obvious errors in unit tests

* Deleted layouts from OVC. Fixed most of the fails in ovc unit tests (there are still failures)

* Clenaup other references to layouts and fixed --version

* Fixed case when two model files are passed in TF case

* Fixed multiple model parts passing in ovc command line

* Tests fixed, support of unnamed input in cli parser.

* Remove convert_model from runtime.

* Changed silent to verbose.

* Removed transform param.

* Removed example_input, share_weights from ovc cli tool.

* Remove wrong change.

* Test fix.

* Code corrections.

* Returned comment.

* WA to fix process hanging after extension loading.

* Removed not needed code.

* Added comment.

---------

Co-authored-by: Sergey Lyalin <sergey.lyalin@intel.com>
This commit is contained in:
Anastasiia Pnevskaia
2023-07-20 20:11:28 +00:00
committed by GitHub
co-authored by Sergey Lyalin
parent 1ce744a00f
commit 8d5a0b1d53
42 changed files with 563 additions and 4278 deletions
@@ -1,7 +1,7 @@
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.runtime import convert_model
from openvino.tools.mo import convert_model
if __name__ == "__main__":
convert_model(help=True)
@@ -4,7 +4,9 @@
import numpy as np
import os
import pytest
from openvino.runtime import Model, Layout, PartialShape, Shape, layout_helpers, Type, Dimension, InputCutInfo, LayoutMap
from openvino.runtime import Model, Layout, PartialShape, Shape, layout_helpers, Type, Dimension
from openvino.tools.ovc import InputCutInfo
from openvino.tools.mo import LayoutMap
from common.mo_convert_test_class import CommonMOConvertTest
from common.tf_layer_test_class import save_to_pb
@@ -132,11 +134,11 @@ class TestComplexParams(CommonMOConvertTest):
{'params_test': {'input_shape': [PartialShape([2, 3, 4]),
[2, 3, 4],
[Dimension(2), Dimension(3), Dimension(4)]],
'input':['Input1', 'Input2', 'Relu3']},
'input':['Input1', 'Input2', 'Relu3'], 'use_convert_model_from_mo': True},
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Relu3'}},
{'params_test': {'input_shape': [PartialShape([Dimension(), Dimension(1, 3), Dimension(4, -1), Dimension(-1, 5)]),
[Dimension(), Dimension(1, 3), 4, Dimension(-1, 5)],
[Dimension(), 3, Dimension(4, -1), Dimension(-1, 5)]],
[Dimension(), 3, Dimension(4, -1), Dimension(-1, 5)]], 'use_convert_model_from_mo': True,
'input':['Input1', 'Input2', 'Relu3']},
'params_ref': {'input_shape': "[?,1..3,4..,..5],[?,1..3,4,..5],[?,3,4..,..5]", 'input': 'Input1,Input2,Relu3'}},
{'params_test': {'input': [InputCutInfo("Relu1", Shape([3, 2]), Type(np.int32)),
@@ -149,26 +151,28 @@ class TestComplexParams(CommonMOConvertTest):
'params_ref': {'input': "Relu1[3 2]{i32},Relu2[3..10 2..]{i32},Relu3[3 2]{i32}"}},
{'params_test': {'output': ["Sigmoid_0", "Sigmoid_2"]},
'params_ref': {'output': "Sigmoid_0,Sigmoid_2"}},
{'params_test': {'mean_values': {'Input1': [0.5,1.3,0.67], 'Input2':[4.2, 6.7, 3.15], 'Input3':[0.757, 4.6, 7.3]}},
{'params_test': {'mean_values': {'Input1': [0.5,1.3,0.67], 'Input2':[4.2, 6.7, 3.15], 'Input3':[0.757, 4.6, 7.3]},
'use_convert_model_from_mo': True},
'params_ref': {'mean_values': "Input1[0.5,1.3,0.67],Input2[4.2,6.7,3.15],Input3[0.757,4.6,7.3]"}},
{'params_test': {
'mean_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]]},
'mean_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]], 'use_convert_model_from_mo': True},
'params_ref': {'mean_values': "[0.5,1.3,0.67],[4.2,6.7,3.15],[0.757,4.6,7.3]"}},
{'params_test': {'scale_values': {'Input1': [0.5,1.3,0.67], 'Input2':[4.2, 6.7, 3.15], 'Input3':[0.757, 4.6, 7.3]}},
{'params_test': {'scale_values': {'Input1': [0.5,1.3,0.67], 'Input2':[4.2, 6.7, 3.15], 'Input3':[0.757, 4.6, 7.3]},
'use_convert_model_from_mo': True},
'params_ref': {'scale_values': "Input1[0.5,1.3,0.67],Input2[4.2,6.7,3.15],Input3[0.757,4.6,7.3]"}},
{'params_test': {
'scale_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]]},
'scale_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]], 'use_convert_model_from_mo': True},
'params_ref': {'scale_values': "[0.5,1.3,0.67],[4.2,6.7,3.15],[0.757,4.6,7.3]"}},
{'params_test': {
'source_layout': {'Input1': Layout("nchw"), 'Input2': "nchw", 'Input3': "nc??"}},
'source_layout': {'Input1': Layout("nchw"), 'Input2': "nchw", 'Input3': "nc??"}, 'use_convert_model_from_mo': True},
'params_ref': {'source_layout': "Input1(nchw),Input2(nchw),Input3(nc??)"}},
{'params_test': {
'target_layout': {'Input1': Layout("nhwc"), 'Input2': "nhwc", 'Input3': "n??c"}},
'target_layout': {'Input1': Layout("nhwc"), 'Input2': "nhwc", 'Input3': "n??c"}, 'use_convert_model_from_mo': True},
'params_ref': {'target_layout': "Input1(nhwc),Input2(nhwc),Input3(n??c)"}},
{'params_test': {
'layout': {'Input1': LayoutMap(source_layout=Layout("nchw"), target_layout="nhwc"),
'Input2': LayoutMap(source_layout="nc??", target_layout=Layout("n??c")),
'Input3': LayoutMap(source_layout="abcd", target_layout="acdb")}},
'Input3': LayoutMap(source_layout="abcd", target_layout="acdb")}, 'use_convert_model_from_mo': True},
'params_ref': {'layout': "Input1(nchw->nhwc),Input2(nc??->n??c),Input3(abcd->acdb)"}},
{'params_test': {'input': [PartialShape([2, 3, 4]), [2, 3, 4], [Dimension(2), Dimension(3), Dimension(4)]]},
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}},
@@ -222,13 +226,14 @@ class TestComplexParams(CommonMOConvertTest):
test_params = params['params_test']
ref_params = params['params_ref']
test_params.update({'input_model': tf_net_path})
test_params.update({'use_convert_model_from_mo': True})
ref_params.update({'input_model': tf_net_path})
self._test(temp_dir, test_params, ref_params)
test_data = [
{'params_test': {'input_shape': PartialShape([2, 3, 4])},
{'params_test': {'input_shape': PartialShape([2, 3, 4]), 'use_convert_model_from_mo': True},
'params_ref': {'input_shape': "[2,3,4]"}},
{'params_test': {'input_shape': [Dimension(), Dimension(1, 3), 4, Dimension(-1, 5)]},
{'params_test': {'input_shape': [Dimension(), Dimension(1, 3), 4, Dimension(-1, 5)], 'use_convert_model_from_mo': True},
'params_ref': {'input_shape': "[?,1..3,4,..5]"}},
{'params_test': {'input': InputCutInfo("Relu", [3, 2], Type(np.int32), [1, 2, 3, 4, 5, 6])},
'params_ref': {'input': "Relu[3 2]{i32}->[1 2 3 4 5 6]"}},
@@ -240,17 +245,17 @@ class TestComplexParams(CommonMOConvertTest):
'params_ref': {'input': "Relu[3 2]"}},
{'params_test': {'input': ("Relu")},
'params_ref': {'input': "Relu"}},
{'params_test': {'mean_values': [0.5, 1.3, 0.67]},
{'params_test': {'mean_values': [0.5, 1.3, 0.67], 'use_convert_model_from_mo': True},
'params_ref': {'mean_values': "[0.5,1.3,0.67]"}},
{'params_test': {'scale_values': [0.5, 1.3, 0.67]},
{'params_test': {'scale_values': [0.5, 1.3, 0.67], 'use_convert_model_from_mo': True},
'params_ref': {'scale_values': "[0.5,1.3,0.67]"}},
{'params_test': {'source_layout': Layout("nchw")},
{'params_test': {'source_layout': Layout("nchw"), 'use_convert_model_from_mo': True},
'params_ref': {'source_layout': "nchw"}},
{'params_test': {'target_layout': Layout("nchw")},
{'params_test': {'target_layout': Layout("nchw"), 'use_convert_model_from_mo': True},
'params_ref': {'target_layout': "nchw"}},
{'params_test': {'layout': LayoutMap(source_layout=Layout("nchw"), target_layout="nhwc")},
{'params_test': {'layout': LayoutMap(source_layout=Layout("nchw"), target_layout="nhwc"), 'use_convert_model_from_mo': True},
'params_ref': {'layout': "nchw->nhwc"}},
{'params_test': {'layout': Layout("nchw")},
{'params_test': {'layout': Layout("nchw"), 'use_convert_model_from_mo': True},
'params_ref': {'layout': "nchw"}},
{'params_test': {'input': [3, 2]},
'params_ref': {'input': "Input[3 2]"}},
@@ -266,13 +271,13 @@ class TestComplexParams(CommonMOConvertTest):
'params_ref': {'input': "Input[1]{i32}->[10]"}},
{'params_test': {'input': (np.int32, [1, 2, 3])},
'params_ref': {'input': "Input[1,2,3]{i32}"}},
{'params_test': {'input_shape': [Dimension(3, 10), 10, -1]},
{'params_test': {'input_shape': [Dimension(3, 10), 10, -1], 'use_convert_model_from_mo': True},
'params_ref': {'input_shape': '[3..10,10,?]'}},
{'params_test': {'input': [Dimension(3, 10), 10, -1]},
'params_ref': {'input': 'Input[3..10,10,?]'}},
{'params_test': {'input': PartialShape([1, 100, 100, 3]), 'mean_values': [0.5, 1.3, 0.67]},
{'params_test': {'input': PartialShape([1, 100, 100, 3]), 'mean_values': [0.5, 1.3, 0.67], 'use_convert_model_from_mo': True},
'params_ref': {'input': "Input[1,100,100,3]", 'mean_values': "[0.5,1.3,0.67]"}},
{'params_test': {'input': [1, 100, 100, 3], 'scale_values': [0.5, 1.3, 0.67]},
{'params_test': {'input': [1, 100, 100, 3], 'scale_values': [0.5, 1.3, 0.67], 'use_convert_model_from_mo': True},
'params_ref': {'input': "Input[1,100,100,3]", 'scale_values': "[0.5,1.3,0.67]"}},
]
@@ -289,24 +294,6 @@ class TestComplexParams(CommonMOConvertTest):
ref_params.update({'input_model': tf_net_path})
self._test(temp_dir, test_params, ref_params)
test_data = [
{
'params_test': {'transform': ('MakeStateful', {'param_res_names': {'Input:0': 'Identity:0'}})},
'params_ref': {'transform': "MakeStateful[param_res_names={\'Input:0\':\'Identity:0\'}]"}}
]
@pytest.mark.parametrize("params", test_data)
@pytest.mark.nightly
def test_mo_convert_transform(self, params, ie_device, precision, ir_version,
temp_dir, use_new_frontend, use_old_api):
tf_net_path = self.create_tf_param_res_model(temp_dir)
test_params = params['params_test']
ref_params = params['params_ref']
test_params.update({'input_model': tf_net_path})
ref_params.update({'input_model': tf_net_path})
self._test(temp_dir, test_params, ref_params)
@pytest.mark.nightly
@pytest.mark.precommit
def test_mo_convert_clearing_transformation_registry(self, ie_device, precision, ir_version,
@@ -10,8 +10,8 @@ import openvino.runtime as ov
import pytest
import torch
import unittest
from openvino.runtime import PartialShape, Dimension, Model, Type, InputCutInfo
from openvino.runtime import PartialShape, Dimension, Model, Type
from openvino.tools.ovc import InputCutInfo
from common.mo_convert_test_class import CommonMOConvertTest
@@ -159,7 +159,7 @@ def create_pytorch_nn_module_case2(tmp_dir):
sample_input2 = torch.zeros(1, 3, 10, 10)
sample_input = sample_input1, sample_input2
return pt_model, ref_model, {'input_shape': ["[?,3,?,?]", PartialShape([-1, 3, -1, -1])],
return pt_model, ref_model, {'input': [PartialShape("[?,3,?,?]"), PartialShape([-1, 3, -1, -1])],
'example_input': sample_input}
@@ -171,7 +171,7 @@ def create_pytorch_nn_module_with_scalar_input(tmp_dir):
sample_input2 = torch.zeros(1, 3, 10, 10)
sample_input = sample_input1, sample_input2
return pt_model, ref_model, {'input_shape': ["[]", PartialShape([-1, 3, -1, -1])],
return pt_model, ref_model, {'input': ["[]", PartialShape([-1, 3, -1, -1])],
'example_input': sample_input}
@@ -183,7 +183,7 @@ def create_pytorch_nn_module_case3(tmp_dir):
sample_input2 = torch.zeros(1, 3, 10, 10)
sample_input = tuple([sample_input1, sample_input2])
return pt_model, ref_model, {'input_shape': "[?,3,?,?],[?,3,?,?]",
return pt_model, ref_model, {'input': "[?,3,?,?],[?,3,?,?]",
'example_input': sample_input}
@@ -194,7 +194,7 @@ def create_pytorch_nn_module_case4(tmp_dir):
ref_model = make_ref_pt_model_one_input(PartialShape([1, 3, 20, 20]))
return pt_model, ref_model, {'example_input': sample_input, "input_shape": [1, 3, 20, 20]}
return pt_model, ref_model, {'example_input': sample_input, "input": [1, 3, 20, 20]}
def create_pytorch_nn_module_case5(tmp_dir):
@@ -247,7 +247,7 @@ def create_pytorch_nn_module_sample_input_int32(tmp_dir):
def create_pytorch_nn_module_sample_input_int32_two_inputs(tmp_dir):
pt_model = make_pt_model_two_inputs()
inp_shapes = ["[?,3,?,?]", PartialShape([-1, 3, -1, -1])]
inp_shapes = [PartialShape("[?,3,?,?]"), PartialShape([-1, 3, -1, -1])]
sample_input1 = torch.zeros(1, 3, 10, 10, dtype=torch.int32)
sample_input2 = torch.zeros(1, 3, 10, 10, dtype=torch.int32)
@@ -255,8 +255,7 @@ def create_pytorch_nn_module_sample_input_int32_two_inputs(tmp_dir):
ref_model = make_ref_pt_model_two_inputs(
[PartialShape([-1, 3, -1, -1]), inp_shapes[1]], dtype=np.int32)
return pt_model, ref_model, {'input_shape': inp_shapes,
'input': [np.int32, np.int32],
return pt_model, ref_model, {'input': [(np.int32, inp_shapes[0]), (np.int32, inp_shapes[1])],
'example_input': sample_input}
@@ -293,7 +292,7 @@ def create_pytorch_nn_module_layout_list(tmp_dir):
ref_model.inputs[1].node.layout = Layout('nhwc')
return pt_model, ref_model, {
'input_shape': [shape, shape], 'layout': ['nchw', Layout('nhwc')],
'input_shape': [shape, shape], 'layout': ['nchw', Layout('nhwc')], 'use_convert_model_from_mo': True
}
@@ -308,7 +307,7 @@ def create_pytorch_nn_module_layout_list_case2(tmp_dir):
ref_model.inputs[1].node.layout = Layout('nhwc')
return pt_model, ref_model, {
'input_shape': [shape, shape], 'layout': ('nchw', Layout('nhwc'))}
'input_shape': [shape, shape], 'layout': ('nchw', Layout('nhwc')), 'use_convert_model_from_mo': True}
def create_pytorch_nn_module_mean_list(tmp_dir):
@@ -330,7 +329,8 @@ def create_pytorch_nn_module_mean_list(tmp_dir):
ref_model = Model([sigm], parameter_list, "test")
return pt_model, ref_model, {
'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], 'compress_to_fp16': False}
'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], 'compress_to_fp16': False,
'use_convert_model_from_mo': True}
def create_pytorch_nn_module_mean_list_default_no_compression(tmp_dir):
@@ -352,7 +352,7 @@ def create_pytorch_nn_module_mean_list_default_no_compression(tmp_dir):
parameter_list = [param1, param2]
ref_model = Model([sigm], parameter_list, "test")
return pt_model, ref_model, {'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]]}
return pt_model, ref_model, {'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]], 'use_convert_model_from_mo': True}
def create_pytorch_nn_module_mean_list_compression_enabled(tmp_dir):
@@ -375,7 +375,7 @@ def create_pytorch_nn_module_mean_list_compression_enabled(tmp_dir):
return pt_model, ref_model, {
'input_shape': [shape, shape], 'mean_values': [[0, 0, 0], [0, 0, 0]],
'compress_to_fp16': False}
'compress_to_fp16': False, 'use_convert_model_from_mo': True}
def create_pytorch_nn_module_scale_list(tmp_dir):
@@ -396,7 +396,8 @@ def create_pytorch_nn_module_scale_list(tmp_dir):
parameter_list = [param1, param2]
ref_model = Model([sigm], parameter_list, "test")
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], 'compress_to_fp16': False}
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], 'compress_to_fp16': False,
'use_convert_model_from_mo': True}
def create_pytorch_nn_module_scale_list_default_no_compression(tmp_dir):
@@ -418,7 +419,7 @@ def create_pytorch_nn_module_scale_list_default_no_compression(tmp_dir):
parameter_list = [param1, param2]
ref_model = Model([sigm], parameter_list, "test")
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]]}
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]], 'use_convert_model_from_mo': True}
def create_pytorch_nn_module_scale_list_compression_enabled(tmp_dir):
@@ -444,14 +445,14 @@ def create_pytorch_nn_module_scale_list_compression_enabled(tmp_dir):
ref_model = Model([sigm], parameter_list, "test")
return pt_model, ref_model, {'input_shape': [shape, shape], 'scale_values': [[1, 1, 1], [1, 1, 1]],
'compress_to_fp16': True}
'compress_to_fp16': True, 'use_convert_model_from_mo': True}
def create_pytorch_nn_module_shapes_list_static(tmp_dir):
pt_model = make_pt_model_two_inputs()
ref_model = make_ref_pt_model_two_inputs([1, 3, 20, 20])
return pt_model, ref_model, {'input_shape': [[1, 3, 20, 20], [1, 3, 20, 20]]}
return pt_model, ref_model, {'input': [[1, 3, 20, 20], [1, 3, 20, 20]]}
def create_pytorch_nn_module_shapes_list_static_via_input(tmp_dir):
@@ -476,7 +477,7 @@ def create_pytorch_nn_module_shapes_list_dynamic(tmp_dir):
parameter_list = [param1, param2]
ref_model = Model([sigm], parameter_list, "test")
return pt_model, ref_model, {'input_shape': inp_shapes}
return pt_model, ref_model, {'input': inp_shapes}
def create_pytorch_nn_module_shapes_list_dynamic_via_input(tmp_dir):
@@ -501,7 +502,7 @@ def create_pytorch_nn_module_shapes_list_dynamic_single_input(tmp_dir):
pt_model = make_pt_model_one_input()
inp_shapes = [[Dimension(-1), 3, 20, Dimension(20, -1)]]
ref_model = make_ref_pt_model_one_input(inp_shapes[0])
return pt_model, ref_model, {'input_shape': inp_shapes}
return pt_model, ref_model, {'input': inp_shapes}
def create_pytorch_nn_module_shapes_list_dynamic_single_input_via_input(tmp_dir):
@@ -515,7 +516,7 @@ def create_pytorch_nn_module_shapes_list_static_single_input(tmp_dir):
pt_model = make_pt_model_one_input()
inp_shapes = [[1, 3, 20, 20]]
ref_model = make_ref_pt_model_one_input(inp_shapes[0])
return pt_model, ref_model, {'input_shape': inp_shapes}
return pt_model, ref_model, {'input': inp_shapes}
def create_pytorch_nn_module_shapes_list_static_single_input_via_input(tmp_dir):
@@ -677,7 +678,7 @@ def create_pytorch_module_with_optional_inputs_case3(tmp_dir):
(1, 3, 10, 10)), "z": torch.ones((1, 3, 10, 10))}
ref_model = make_ref_pt_model_with_optional_inputs(
[3, 3, 3, 3], z_exist=True)
return net, ref_model, {"example_input": example_input, "input_shape": [[3, 3, 3, 3], [3, 3, 3, 3]]}
return net, ref_model, {"example_input": example_input, "input": [[3, 3, 3, 3], [3, 3, 3, 3]]}
def create_pytorch_module_with_optional_inputs_case4(tmp_dir):
@@ -691,7 +692,7 @@ def create_pytorch_module_with_optional_inputs_case5(tmp_dir):
net = make_pt_model_with_optional_input()
ref_model = make_ref_pt_model_with_optional_inputs(
[1, 3, -1, -1], z_exist=True)
return net, ref_model, {"input": ["x", "z"], "input_shape": [[1, 3, -1, -1], [1, 3, -1, -1]]}
return net, ref_model, {"input": [("x",[1, 3, -1, -1]), ("z", [1, 3, -1, -1])]}
def create_pytorch_module_with_compressed_int8_constant(tmp_dir):
@@ -956,11 +957,11 @@ def create_pt_model_with_custom_op():
class ConvertRaises(unittest.TestCase):
def test_example_inputs(self):
from openvino.runtime import convert_model
from openvino.tools.ovc import convert_model
pytorch_model = create_pt_model_with_custom_op()
# Check that mo raises error message of wrong argument.
with self.assertRaisesRegex(AssertionError, ".*argument is not recognized.*"):
with self.assertRaisesRegex(TypeError, ".*got an unexpected keyword argument 'example_inputs'.*"):
convert_model(pytorch_model, example_inputs=(torch.tensor(1),))
def test_failed_extension(self):
@@ -139,7 +139,7 @@ def create_tf_module(tmp_dir):
model_ref = Model([sigm], parameter_list, "test")
net = Net()
return net, model_ref, {'input_shape': [PartialShape([1, 2, 3]), PartialShape([1, 2, 3])]}
return net, model_ref, {'input': [PartialShape([1, 2, 3]), PartialShape([1, 2, 3])]}
def create_tf_module_layout_list(tmp_dir):
@@ -166,7 +166,8 @@ def create_tf_module_layout_list(tmp_dir):
model_ref.inputs[1].node.layout = Layout('NHC')
net = Net()
return net, model_ref, {'input_shape': [PartialShape([1, 2, 3]), PartialShape([1, 2, 3])], 'layout': ["NCH", "NHC"]}
return net, model_ref, {'input_shape': [PartialShape([1, 2, 3]), PartialShape([1, 2, 3])], 'layout': ["NCH", "NHC"],
'use_convert_model_from_mo': True}
def create_tf_module_dynamic(tmp_dir):
@@ -192,7 +193,7 @@ def create_tf_module_dynamic(tmp_dir):
model_ref = Model([sigm], parameter_list, "test")
net = Net()
return net, model_ref, {'input_shape': input_shapes}
return net, model_ref, {'input': input_shapes}
def create_keras_layer(tmp_dir):
@@ -216,7 +217,7 @@ def create_keras_layer(tmp_dir):
model_ref = Model([sigm], parameter_list, "test")
net = LayerModel()
return net, model_ref, {'input_shape': [PartialShape([1, 2, 3]), PartialShape([1, 2, 3])]}
return net, model_ref, {'input': [PartialShape([1, 2, 3]), PartialShape([1, 2, 3])]}
def create_keras_layer_dynamic(tmp_dir):
@@ -242,7 +243,7 @@ def create_keras_layer_dynamic(tmp_dir):
model_ref = Model([sigm], parameter_list, "test")
net = LayerModel()
return net, model_ref, {'input_shape': input_shapes}
return net, model_ref, {'input': input_shapes}
def create_tf_checkpoint(tmp_dir):
@@ -518,7 +519,7 @@ def create_keras_layer_with_example_input_2(tmp_dir):
def create_keras_layer_with_input_shapes_case1(tmp_dir):
model, model_ref = create_keras_layer_input_list()
return model, model_ref, {'input_shape': [[1, 2, 3], [1, 2, 3]]}
return model, model_ref, {'input': [[1, 2, 3], [1, 2, 3]]}
def create_keras_layer_with_input_shapes_case2(tmp_dir):
@@ -528,7 +529,7 @@ def create_keras_layer_with_input_shapes_case2(tmp_dir):
def create_keras_layer_with_input_shapes_case3(tmp_dir):
model, model_ref = create_keras_layer_input_dict_one_inp()
return model, model_ref, {'input': ['args'], 'input_shape': [1, 2, 3]}
return model, model_ref, {'input': [('args', [1, 2, 3])]}
def create_keras_layer_with_input_shapes_case4(tmp_dir):
@@ -669,7 +670,7 @@ class TestMoConvertTF(CommonMOConvertTest):
temp_dir):
fw_model, graph_ref, mo_params = create_model(temp_dir)
test_params = {'input_model': fw_model, 'use_new_frontend': True}
test_params = {'input_model': fw_model}
if mo_params is not None:
test_params.update(mo_params)
self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False)
@@ -679,10 +680,10 @@ class TestMoConvertTF(CommonMOConvertTest):
def test_unnamed_saved_model_dir(self, ie_device, precision, ir_version, temp_dir):
saved_model_dir, graph_ref = create_tf_saved_model_dir(temp_dir)
test_params = {'input_model': saved_model_dir, 'use_new_frontend': True}
test_params = {'input_model': saved_model_dir}
self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False)
test_params = {'input_model': saved_model_dir, 'use_new_frontend': False}
test_params = {'input_model': saved_model_dir}
self._test_by_ref_graph(temp_dir, test_params, graph_ref, compare_tensor_names=False)
def test_zero_copy(self, ie_device, precision, ir_version, temp_dir):
@@ -741,7 +742,7 @@ class TestMoConvertTF(CommonMOConvertTest):
import tensorflow as tf
tf.compat.v1.reset_default_graph()
from openvino.tools.mo import convert_model
from openvino.tools.ovc import convert_model
from openvino.runtime import compile_model
import gc
@@ -795,7 +796,7 @@ class TFConvertTest(unittest.TestCase):
@pytest.mark.precommit
def test_tf_function_no_signature(self):
import tensorflow as tf
from openvino.runtime import convert_model
from openvino.tools.ovc import convert_model
@tf.function()
def function(x1, x2):
@@ -5,8 +5,9 @@
import os
import sys
import unittest
from openvino.tools.mo import mo
from openvino.tools.ovc import ovc
from openvino.tools.ovc.cli_parser import get_mo_convert_params
from openvino.tools.mo.utils.cli_parser import get_mo_convert_params as legacy_mo_params
from pathlib import Path
from common.utils.common_utils import shell
@@ -16,8 +17,8 @@ class TestSubprocessMoConvert(unittest.TestCase):
def test_mo_convert(self):
mo_convert_params = get_mo_convert_params()
# Test cli tool help
mo_path = Path(mo.__file__).parent
# Test ovc tool help
mo_path = Path(ovc.__file__).parent
mo_runner = mo_path.joinpath('main.py').as_posix()
params = [sys.executable, mo_runner, "--help"]
_, mo_output, _ = shell(params)
@@ -29,11 +30,12 @@ class TestSubprocessMoConvert(unittest.TestCase):
for param_name in group:
assert param_name in mo_output
# Test Python API help
# Test Python API help, applicable for convert_model from tools.mo only
mo_help_file = os.path.join(os.path.dirname(__file__), "mo_convert_help.py")
params = [sys.executable, mo_help_file]
_, mo_output, _ = shell(params)
for group in mo_convert_params:
legacy_params = legacy_mo_params()
for group in legacy_params:
for param_name in group:
assert param_name in mo_output
@@ -27,7 +27,9 @@ def generate_ir_ovc(coverage=False, **kwargs):
else:
params = [sys.executable, ovc_runner]
for key, value in kwargs.items():
if key == "batch":
if key == "input_model":
params.append((str(value)))
elif key == "batch":
params.extend(("-b", str(value)))
elif key == "k":
params.extend(("-k", str(value)))
@@ -81,7 +83,7 @@ class TestOVCTool(CommonMOConvertTest):
core = Core()
# tests for MO cli tool
exit_code, stderr = generate_ir_ovc(coverage=False, **{"input_model": model_path, "output_dir": temp_dir})
exit_code, stderr = generate_ir_ovc(coverage=False, **{"input_model": model_path, "output_model": temp_dir + os.sep + "model"})
assert not exit_code
ov_model = core.read_model(os.path.join(temp_dir, "model.xml"))