Support of unnamed input for MO Python API. (#16373)
* Support of unnamed input for MO Python API. * Code correction, tests fix. * Small fix. * Added tests for unnamed input, code fixes. * Small code correction. * Removed code comment. * Added tests, fixed bugs. * Minor corrections, added comments. * Code refactoring. * Added defaults for InputCutInfo. * Fixed error. * Small fixes. * Removed wrong change. * Fixed error. * Corrected input description.
This commit is contained in:
committed by
GitHub
parent
ae34720818
commit
24c9d95779
@@ -43,6 +43,27 @@ class TestComplexParams(CommonMOConvertTest):
|
||||
# save model to .pb and return path to the model
|
||||
return save_to_pb(tf_net, tmp_dir)
|
||||
|
||||
def create_tf_model_no_concat(self, tmp_dir):
|
||||
import tensorflow as tf
|
||||
|
||||
tf.compat.v1.reset_default_graph()
|
||||
|
||||
with tf.compat.v1.Session() as sess:
|
||||
inp1 = tf.compat.v1.placeholder(tf.float32, [1, 3, 2, 2], 'Input1')
|
||||
inp2 = tf.compat.v1.placeholder(tf.float32, [1, 3, 2, 2], 'Input2')
|
||||
inp3 = tf.compat.v1.placeholder(tf.bool, [], 'Input3')
|
||||
output2 = inp3
|
||||
|
||||
relu1 = tf.nn.sigmoid(inp1, name='Relu1')
|
||||
relu2 = tf.nn.sigmoid(inp2, name='Relu2')
|
||||
output = relu1 + relu2
|
||||
|
||||
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 create_tf_model_single_input_output(self, tmp_dir):
|
||||
#
|
||||
# Create Tensorflow model with single input/output
|
||||
@@ -119,8 +140,8 @@ class TestComplexParams(CommonMOConvertTest):
|
||||
[Dimension(), 3, Dimension(4, -1), Dimension(-1, 5)]],
|
||||
'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), None),
|
||||
InputCutInfo("Relu2", PartialShape([Dimension(3, 10), Dimension(2, -1)]), np.int32, None),
|
||||
{'params_test': {'input': [InputCutInfo("Relu1", Shape([3, 2]), Type(np.int32)),
|
||||
InputCutInfo("Relu2", PartialShape([Dimension(3, 10), Dimension(2, -1)]), np.int32),
|
||||
InputCutInfo("Relu3", [3, 2], Type(np.int32), [1, 2, 3, 4, 5, 6])]},
|
||||
'params_ref': {'input': "Relu1[3 2]{i32},Relu2[3..10 2..]{i32},Relu3[3 2]{i32}->[1 2 3 4 5 6]"}},
|
||||
{'params_test': {'input': [("Relu1", Shape([3, 2]), Type(np.int32)),
|
||||
@@ -150,7 +171,14 @@ class TestComplexParams(CommonMOConvertTest):
|
||||
'Input2': LayoutMap(source_layout="nc??", target_layout=Layout("n??c")),
|
||||
'Input3': LayoutMap(source_layout="abcd", target_layout="acdb")}},
|
||||
'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'}},
|
||||
{'params_test': {'input': [np.int32, Type(np.int32), np.int32]},
|
||||
'params_ref': {'input': 'Input1{i32},Input2{i32},Input3{i32}'}},
|
||||
{'params_test': {'input': [InputCutInfo(shape=[1], type=np.int32, value=[10]),
|
||||
InputCutInfo(shape=[1], type=np.int32, value=[20]),
|
||||
InputCutInfo(shape=[1], type=np.int32, value=[30])]},
|
||||
'params_ref': {'input': 'Input1[1]{i32}->[10],Input2[1]{i32}->[20],Input3[1]{i32}->[30]'}}
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("params", test_data)
|
||||
@@ -165,6 +193,39 @@ class TestComplexParams(CommonMOConvertTest):
|
||||
ref_params.update({'input_model': tf_net_path})
|
||||
self._test(temp_dir, test_params, ref_params)
|
||||
|
||||
test_data = [
|
||||
{'params_test': {'input_shape': [[Dimension(1), 2, 3], [Dimension(1), 2, 3]],
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'},
|
||||
|
||||
'params_ref': {'input_shape': '[1,2,3],[1,2,3]',
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'}},
|
||||
{'params_test': {'input': [PartialShape([Dimension(-1), 5, 6]), [-1, 5, 6]],
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'},
|
||||
|
||||
'params_ref': {'input': 'Input1[?,5,6],Input2[?,5,6]',
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'}},
|
||||
{'params_test': {'input': [np.float16, np.float16],
|
||||
'input_shape': [[10, 20], [10, 20]],
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'},
|
||||
|
||||
'params_ref': {'input': 'Input1{f16},Input2{f16}',
|
||||
'input_shape': "[10,20],[10,20]",
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'}},
|
||||
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("params", test_data)
|
||||
@pytest.mark.nightly
|
||||
def test_mo_convert_tf_model_no_concat(self, params, ie_device, precision, ir_version,
|
||||
temp_dir, use_new_frontend, use_old_api):
|
||||
tf_net_path = self.create_tf_model_no_concat(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)
|
||||
|
||||
test_data = [
|
||||
{'params_test': {'input_shape': PartialShape([2, 3, 4])},
|
||||
'params_ref': {'input_shape': "[2,3,4]"}},
|
||||
@@ -191,7 +252,29 @@ class TestComplexParams(CommonMOConvertTest):
|
||||
{'params_test': {'layout': LayoutMap(source_layout=Layout("nchw"), target_layout="nhwc")},
|
||||
'params_ref': {'layout': "nchw->nhwc"}},
|
||||
{'params_test': {'layout': Layout("nchw")},
|
||||
'params_ref': {'layout': "nchw"}}
|
||||
'params_ref': {'layout': "nchw"}},
|
||||
{'params_test': {'input': [3, 2]},
|
||||
'params_ref': {'input': "Input[3 2]"}},
|
||||
{'params_test': {'input': [Dimension(3,10), 2]},
|
||||
'params_ref': {'input': "Input[3..10 2]"}},
|
||||
{'params_test': {'input': (-1, 10)},
|
||||
'params_ref': {'input': "Input[?,10]"}},
|
||||
{'params_test': {'input': PartialShape([-1, 10])},
|
||||
'params_ref': {'input': "Input[?,10]"}},
|
||||
{'params_test': {'input': np.int32},
|
||||
'params_ref': {'input': "Input{i32}"}},
|
||||
{'params_test': {'input': InputCutInfo(shape=[1], type=np.int32, value=[10])},
|
||||
'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_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_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_ref': {'input': "Input[1,100,100,3]", 'scale_values': "[0.5,1.3,0.67]"}},
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("params", test_data)
|
||||
|
||||
Reference in New Issue
Block a user