Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GHA] Enable parallel execution of OVC Python API python tests (#26598)

Hubert Błaszczyk351e272af317
diff --git a/.github/workflows/job_python_unit_tests.yml b/.github/workflows/job_python_unit_tests.yml
index 5ce582bc144..c4ab208c54e 100644
--- a/.github/workflows/job_python_unit_tests.yml
+++ b/.github/workflows/job_python_unit_tests.yml
@@ -195,7 +195,7 @@ jobs:
export LD_PRELOAD=${GOMP_LIB}
fi
- python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/ovc_python_api_tests --junitxml=${INSTALL_TEST_DIR}/TEST-test_ovc_convert.xml
+ python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/ovc_python_api_tests -n logical --junitxml=${INSTALL_TEST_DIR}/TEST-test_ovc_convert.xml
env:
TEST_DEVICE: CPU
TEST_PRECISION: FP16
diff --git a/tests/layer_tests/ovc_python_api_tests/test_onnx.py b/tests/layer_tests/ovc_python_api_tests/test_onnx.py
index 1b200594fa6..7a1bd7efcc7 100644
--- a/tests/layer_tests/ovc_python_api_tests/test_onnx.py
+++ b/tests/layer_tests/ovc_python_api_tests/test_onnx.py
@@ -82,13 +82,13 @@ def create_bytes_io():
class TestMoConvertONNX(CommonMOConvertTest):
- test_data = [create_bytes_io]
+ test_data = ['create_bytes_io']
@pytest.mark.parametrize("create_model", test_data)
@pytest.mark.nightly
@pytest.mark.precommit
def test_mo_convert_onnx(self, create_model, ie_device, precision, ir_version,
temp_dir):
- fw_model, graph_ref, mo_params = create_model()
+ fw_model, graph_ref, mo_params = eval(create_model)()
test_params = {'input_model': fw_model}
if mo_params is not None:
diff --git a/tests/layer_tests/ovc_python_api_tests/test_paddle.py b/tests/layer_tests/ovc_python_api_tests/test_paddle.py
index 8e854170af7..831813a2437 100644
--- a/tests/layer_tests/ovc_python_api_tests/test_paddle.py
+++ b/tests/layer_tests/ovc_python_api_tests/test_paddle.py
@@ -92,15 +92,15 @@ def create_paddle_hapi_module(tmp_dir):
class TestMoConvertPaddle(CommonMOConvertTest):
test_data = [
- create_paddle_dynamic_module,
- create_paddle_static_module,
- create_paddle_hapi_module
+ 'create_paddle_dynamic_module',
+ 'create_paddle_static_module',
+ 'create_paddle_hapi_module'
]
@pytest.mark.skip(reason="Paddlepaddle has incompatible protobuf. Ticket: 95904")
@pytest.mark.parametrize("create_model", test_data)
def test_mo_import_from_memory_paddle_fe(self, create_model, ie_device, precision, ir_version,
temp_dir):
- fw_model, graph_ref, mo_params = create_model(temp_dir)
+ fw_model, graph_ref, mo_params = eval(create_model)(temp_dir)
test_params = {'input_model': fw_model}
if mo_params is not None:
test_params.update(mo_params)
diff --git a/tests/layer_tests/ovc_python_api_tests/test_pytorch.py b/tests/layer_tests/ovc_python_api_tests/test_pytorch.py
index 2e22f3d626d..3fbe25ee130 100644
--- a/tests/layer_tests/ovc_python_api_tests/test_pytorch.py
+++ b/tests/layer_tests/ovc_python_api_tests/test_pytorch.py
@@ -1180,63 +1180,63 @@ def create_pytorch_module_with_nested_dict_input(tmp_dir):
class TestMoConvertPyTorch(CommonMOConvertTest):
test_data = [
- create_pytorch_nn_module_case1,
- create_pytorch_nn_module_case2,
- create_pytorch_nn_module_case3,
- create_pytorch_nn_module_case4,
- create_pytorch_nn_module_case5,
- create_pytorch_nn_module_case6,
- create_pytorch_nn_module_case7,
- create_pytorch_nn_module_torch_size,
- create_pytorch_nn_module_sample_input_int32,
- create_pytorch_nn_module_sample_input_int32_two_inputs,
- create_pytorch_jit_script_module,
- create_pytorch_jit_script_function,
- create_pytorch_nn_module_layout_list,
- create_pytorch_nn_module_layout_list_case2,
- create_pytorch_nn_module_mean_list_compression_default,
- create_pytorch_nn_module_mean_list_compression_disabled,
- create_pytorch_nn_module_mean_list_compression_enabled,
- create_pytorch_nn_module_scale_list_compression_default,
- create_pytorch_nn_module_scale_list_compression_disabled,
- create_pytorch_nn_module_scale_list_compression_enabled,
- create_pytorch_nn_module_with_compressed_constants,
- create_pytorch_nn_module_shapes_list_static,
- create_pytorch_nn_module_shapes_list_static_via_input,
- create_pytorch_nn_module_reorder_inputs,
- create_pytorch_nn_module_shapes_list_dynamic,
- create_pytorch_nn_module_shapes_list_dynamic_via_input,
- create_pytorch_nn_module_shapes_list_dynamic_single_input,
- create_pytorch_nn_module_shapes_list_static_single_input,
- create_pytorch_nn_module_shapes_list_dynamic_single_input_via_input,
- create_pytorch_nn_module_shapes_list_static_single_input_via_input,
- create_pytorch_nn_module_convert_pytorch_frontend1,
- create_pytorch_nn_module_convert_pytorch_frontend2,
- create_pytorch_nn_module_convert_pytorch_frontend3,
- create_pytorch_nn_module_convert_pytorch_frontend4,
- create_pytorch_jit_script_module_convert_pytorch_frontend,
- create_pytorch_jit_trace_module_convert_pytorch_frontend,
- create_pytorch_module_convert_pytorch_frontend_oob,
- create_pytorch_module_with_optional_inputs_case1,
- create_pytorch_module_with_optional_inputs_case2,
- create_pytorch_module_with_optional_inputs_case3,
- create_pytorch_module_with_tuple_case1,
- create_pytorch_module_with_tuple_case2,
- create_pytorch_module_with_tuple_case3,
- create_pytorch_module_with_dict_case1,
- create_pytorch_module_with_dict_case2,
- create_pytorch_nn_module_with_scalar_input,
- create_pytorch_module_with_compressed_int8_constant,
- create_pytorch_module_with_compressed_int8_constant_compress_to_fp16_default,
- create_pytorch_module_with_nested_inputs,
- create_pytorch_module_with_nested_inputs2,
- create_pytorch_module_with_nested_inputs3,
- create_pytorch_module_with_nested_inputs4,
- create_pytorch_module_with_nested_inputs5,
- create_pytorch_module_with_nested_inputs6,
- create_pytorch_module_with_nested_list_and_single_input,
- create_pytorch_module_with_single_input_as_list,
- create_pytorch_module_with_nested_dict_input
+ 'create_pytorch_nn_module_case1',
+ 'create_pytorch_nn_module_case2',
+ 'create_pytorch_nn_module_case3',
+ 'create_pytorch_nn_module_case4',
+ 'create_pytorch_nn_module_case5',
+ 'create_pytorch_nn_module_case6',
+ 'create_pytorch_nn_module_case7',
+ 'create_pytorch_nn_module_torch_size',
+ 'create_pytorch_nn_module_sample_input_int32',
+ 'create_pytorch_nn_module_sample_input_int32_two_inputs',
+ 'create_pytorch_jit_script_module',
+ 'create_pytorch_jit_script_function',
+ 'create_pytorch_nn_module_layout_list',
+ 'create_pytorch_nn_module_layout_list_case2',
+ 'create_pytorch_nn_module_mean_list_compression_default',
+ 'create_pytorch_nn_module_mean_list_compression_disabled',
+ 'create_pytorch_nn_module_mean_list_compression_enabled',
+ 'create_pytorch_nn_module_scale_list_compression_default',
+ 'create_pytorch_nn_module_scale_list_compression_disabled',
+ 'create_pytorch_nn_module_scale_list_compression_enabled',
+ 'create_pytorch_nn_module_with_compressed_constants',
+ 'create_pytorch_nn_module_shapes_list_static',
+ 'create_pytorch_nn_module_shapes_list_static_via_input',
+ 'create_pytorch_nn_module_reorder_inputs',
+ 'create_pytorch_nn_module_shapes_list_dynamic',
+ 'create_pytorch_nn_module_shapes_list_dynamic_via_input',
+ 'create_pytorch_nn_module_shapes_list_dynamic_single_input',
+ 'create_pytorch_nn_module_shapes_list_static_single_input',
+ 'create_pytorch_nn_module_shapes_list_dynamic_single_input_via_input',
+ 'create_pytorch_nn_module_shapes_list_static_single_input_via_input',
+ 'create_pytorch_nn_module_convert_pytorch_frontend1',
+ 'create_pytorch_nn_module_convert_pytorch_frontend2',
+ 'create_pytorch_nn_module_convert_pytorch_frontend3',
+ 'create_pytorch_nn_module_convert_pytorch_frontend4',
+ 'create_pytorch_jit_script_module_convert_pytorch_frontend',
+ 'create_pytorch_jit_trace_module_convert_pytorch_frontend',
+ 'create_pytorch_module_convert_pytorch_frontend_oob',
+ 'create_pytorch_module_with_optional_inputs_case1',
+ 'create_pytorch_module_with_optional_inputs_case2',
+ 'create_pytorch_module_with_optional_inputs_case3',
+ 'create_pytorch_module_with_tuple_case1',
+ 'create_pytorch_module_with_tuple_case2',
+ 'create_pytorch_module_with_tuple_case3',
+ 'create_pytorch_module_with_dict_case1',
+ 'create_pytorch_module_with_dict_case2',
+ 'create_pytorch_nn_module_with_scalar_input',
+ 'create_pytorch_module_with_compressed_int8_constant',
+ 'create_pytorch_module_with_compressed_int8_constant_compress_to_fp16_default',
+ 'create_pytorch_module_with_nested_inputs',
+ 'create_pytorch_module_with_nested_inputs2',
+ 'create_pytorch_module_with_nested_inputs3',
+ 'create_pytorch_module_with_nested_inputs4',
+ 'create_pytorch_module_with_nested_inputs5',
+ 'create_pytorch_module_with_nested_inputs6',
+ 'create_pytorch_module_with_nested_list_and_single_input',
+ 'create_pytorch_module_with_single_input_as_list',
+ 'create_pytorch_module_with_nested_dict_input'
]
@pytest.mark.parametrize("create_model", test_data)
@@ -1244,7 +1244,7 @@ class TestMoConvertPyTorch(CommonMOConvertTest):
@pytest.mark.precommit
def test_mo_import_from_memory(self, create_model, ie_device, precision, ir_version,
temp_dir, use_legacy_frontend):
- fw_model, graph_ref, mo_params = create_model(temp_dir)
+ fw_model, graph_ref, mo_params = eval(create_model)(temp_dir)
test_params = {'input_model': fw_model}
if mo_params is not None:
diff --git a/tests/layer_tests/ovc_python_api_tests/test_tf.py b/tests/layer_tests/ovc_python_api_tests/test_tf.py
index e1859297fe1..ff6dd4d9a23 100644
--- a/tests/layer_tests/ovc_python_api_tests/test_tf.py
+++ b/tests/layer_tests/ovc_python_api_tests/test_tf.py
@@ -689,32 +689,32 @@ def create_ref_model_single_input(shape=[1, 2, 3, 4], dtype=np.float32):
class TestMoConvertTF(CommonMOConvertTest):
test_data = [
# TF2
- create_keras_model,
- create_keras_layer,
- create_tf_function,
- create_tf_module,
- create_tf_checkpoint,
- create_keras_layer_dynamic,
- create_tf_module_dynamic,
- create_tf_stateful_partioned_call_net,
- create_keras_layer_with_example_input_1,
- create_keras_layer_with_example_input_2,
- create_keras_layer_with_input_shapes_case1,
- create_keras_layer_with_input_shapes_case2,
- create_keras_layer_with_input_shapes_case3,
- create_keras_layer_with_input_shapes_case4,
- create_keras_layer_with_tf_function_call,
- create_keras_layer_with_tf_function_call_default_compressed_to_fp16,
- create_keras_layer_with_compressed_constants,
- create_keras_layer_with_tf_function_call_no_signature,
- create_keras_layer_with_tf_function_call_no_signature_single_input,
- create_keras_layer_with_string_tensor,
+ 'create_keras_model',
+ 'create_keras_layer',
+ 'create_tf_function',
+ 'create_tf_module',
+ 'create_tf_checkpoint',
+ 'create_keras_layer_dynamic',
+ 'create_tf_module_dynamic',
+ 'create_tf_stateful_partioned_call_net',
+ 'create_keras_layer_with_example_input_1',
+ 'create_keras_layer_with_example_input_2',
+ 'create_keras_layer_with_input_shapes_case1',
+ 'create_keras_layer_with_input_shapes_case2',
+ 'create_keras_layer_with_input_shapes_case3',
+ 'create_keras_layer_with_input_shapes_case4',
+ 'create_keras_layer_with_tf_function_call',
+ 'create_keras_layer_with_tf_function_call_default_compressed_to_fp16',
+ 'create_keras_layer_with_compressed_constants',
+ 'create_keras_layer_with_tf_function_call_no_signature',
+ 'create_keras_layer_with_tf_function_call_no_signature_single_input',
+ 'create_keras_layer_with_string_tensor',
# TF1
- create_tf_graph,
- create_tf_graph_def,
- create_tf1_wrap_function,
- create_tf_session,
+ 'create_tf_graph',
+ 'create_tf_graph_def',
+ 'create_tf1_wrap_function',
+ 'create_tf_session',
]
@pytest.mark.parametrize("create_model", test_data)
@@ -723,7 +723,7 @@ class TestMoConvertTF(CommonMOConvertTest):
@pytest.mark.precommit
def test_mo_import_from_memory_tf_fe(self, create_model, ie_device, precision, ir_version,
temp_dir):
- fw_model, graph_ref, mo_params = create_model(temp_dir)
+ fw_model, graph_ref, mo_params = eval(create_model)(temp_dir)
test_params = {'input_model': fw_model}
if mo_params is not None:
@@ -1051,33 +1051,59 @@ class TestTFConversionParams(CommonMOConvertTest):
test_data = [
{'params_test': {
'input': [tf.shape(tf.zeros((2, 3, 4))), tf.zeros((2, 3, 4)).shape, tf.TensorShape((2, 3, 4))]},
- 'fw_model': create_tf_model_three_inputs([1, 2, 3, 4]),
- 'ref_model': create_ref_model_three_inputs([2, 3, 4])},
+ 'fw_model': {
+ 'create_model': 'create_tf_model_three_inputs',
+ 'params': [[1, 2, 3, 4]]},
+ 'ref_model': {
+ 'create_model': 'create_ref_model_three_inputs',
+ 'params': [[2, 3, 4]]}},
{'params_test': {'input': [tf.float32, tf.float32, tf.float32]},
- 'fw_model': create_tf_model_three_inputs([2, 3], tf.int32),
- 'ref_model': create_ref_model_three_inputs([2, 3], np.float32)},
+ 'fw_model': {
+ 'create_model': 'create_tf_model_three_inputs',
+ 'params': [[2, 3], tf.int32]},
+ 'ref_model': {
+ 'create_model': 'create_ref_model_three_inputs',
+ 'params': [[2, 3], np.float32]}},
{'params_test': {'input': tf.shape(tf.zeros((5, 8, 2)))},
- 'fw_model': create_tf_model_single_input(),
- 'ref_model': create_ref_model_single_input([5, 8, 2])},
+ 'fw_model': {
+ 'create_model': 'create_tf_model_single_input',
+ 'params': []},
+ 'ref_model': {
+ 'create_model': 'create_ref_model_single_input',
+ 'params': [[5, 8, 2]]}},
{'params_test': {'input': tf.zeros((9, 2)).shape},
- 'fw_model': create_tf_model_single_input(),
- 'ref_model': create_ref_model_single_input([9, 2])},
+ 'fw_model': {
+ 'create_model': 'create_tf_model_single_input',
+ 'params': []},
+ 'ref_model': {
+ 'create_model': 'create_ref_model_single_input',
+ 'params': [[9, 2]]}},
{'params_test': {'input': tf.TensorShape((4, 8, 3))},
- 'fw_model': create_tf_model_single_input(),
- 'ref_model': create_ref_model_single_input([4, 8, 3])},
+ 'fw_model': {
+ 'create_model': 'create_tf_model_single_input',
+ 'params': []},
+ 'ref_model': {
+ 'create_model': 'create_ref_model_single_input',
+ 'params': [[4, 8, 3]]}},
{'params_test': {'input': tf.int32},
- 'fw_model': create_tf_model_single_input(),
- 'ref_model': create_ref_model_single_input([1, 2, 3, 4], np.int32)}
+ 'fw_model': {
+ 'create_model': 'create_tf_model_single_input',
+ 'params': []},
+ 'ref_model': {
+ 'create_model': 'create_ref_model_single_input',
+ 'params': [[1, 2, 3, 4], np.int32]}},
]
@pytest.mark.parametrize("params", test_data)
@pytest.mark.nightly
def test_mo_convert_tf_model(self, params, ie_device, precision, ir_version,
temp_dir, use_legacy_frontend):
- fw_model = params['fw_model']
+ fw_model_dict = params['fw_model']
+ ref_model_dict = params['ref_model']
test_params = params['params_test']
- ref_model = params['ref_model']
+ ref_model = eval(ref_model_dict['create_model'])(*ref_model_dict['params'])
+ fw_model = eval(fw_model_dict['create_model'])(*fw_model_dict['params'])
test_params.update({'input_model': fw_model})
self._test_by_ref_graph(temp_dir, test_params, ref_model, compare_tensor_names=False)
diff --git a/tests/layer_tests/ovc_python_api_tests/test_tf_output_order.py b/tests/layer_tests/ovc_python_api_tests/test_tf_output_order.py
index 3c3fb47f6fa..fd04775b496 100644
--- a/tests/layer_tests/ovc_python_api_tests/test_tf_output_order.py
+++ b/tests/layer_tests/ovc_python_api_tests/test_tf_output_order.py
@@ -67,12 +67,12 @@ class TestTFInputOutputOrder():
self.tmp_dir = tempfile.TemporaryDirectory(dir=constants.out_path).name
@pytest.mark.parametrize("save_to_file, create_model_method, compare_model_method", [
- (False, create_net_list, check_outputs_by_order),
- (False, create_net_dict, check_outputs_by_names),
+ (False, 'create_net_list', 'check_outputs_by_order'),
+ (False, 'create_net_dict', 'check_outputs_by_names'),
# next two cases are failing due to TensorFlow bug https://github.com/tensorflow/tensorflow/issues/75177
- pytest.param(True, create_net_list, check_outputs_by_order,
+ pytest.param(True, 'create_net_list', 'check_outputs_by_order',
marks=pytest.mark.xfail(reason='https://github.com/tensorflow/tensorflow/issues/75177')),
- pytest.param(True, create_net_dict, check_outputs_by_names,
+ pytest.param(True, 'create_net_dict', 'check_outputs_by_names',
marks=pytest.mark.xfail(reason='https://github.com/tensorflow/tensorflow/issues/75177')),
])
def test_order(self, ie_device, precision, save_to_file, create_model_method, compare_model_method):
@@ -81,7 +81,7 @@ class TestTFInputOutputOrder():
input_shapes = [[1, 1], [1, 3], [1, 2], [1, 5], [1, 4]]
epsilon = 0.001
- fw_model = create_model_method(input_names, input_shapes)
+ fw_model = eval(create_model_method)(input_names, input_shapes)
if save_to_file:
fw_model.export(self.tmp_dir + "./model")
@@ -97,4 +97,4 @@ class TestTFInputOutputOrder():
fw_output = fw_model(test_inputs)
ov_output = cmp_model(test_inputs)
- compare_model_method(fw_output, ov_output, epsilon)
+ eval(compare_model_method)(fw_output, ov_output, epsilon)