Skip to content

Commit

Permalink
[TF FE] Switch TF2 Keras layer tests to precommit mark (openvinotoolk…
Browse files Browse the repository at this point in the history
…it#24010)

**Details:** Switch TF2 Keras layer tests to precommit mark.

**Ticket:** TBD

---------

Signed-off-by: Kazantsev, Roman <[email protected]>
  • Loading branch information
rkazants authored Apr 15, 2024
1 parent 237c68b commit 1496229
Show file tree
Hide file tree
Showing 39 changed files with 185 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/job_python_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ jobs:
- name: TensorFlow 2 Layer Tests - TF FE
if: fromJSON(inputs.affected-components).TF_FE.test && runner.os != 'macOS' # Ticket: 123322
run: |
python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow2_keras_tests/ -n logical -m precommit_tf_fe --junitxml=${INSTALL_TEST_DIR}/TEST-tf2_fe.xml
python3 -m pytest ${LAYER_TESTS_INSTALL_DIR}/tensorflow2_keras_tests/ -n logical -m precommit --junitxml=${INSTALL_TEST_DIR}/TEST-tf2_fe.xml
env:
TEST_DEVICE: CPU
TEST_PRECISION: FP16
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -626,15 +626,19 @@ jobs:
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test
shell: cmd
run: |
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow2_keras_tests/ -m precommit_tf_fe --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf2_fe.xml
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow2_keras_tests/ -m precommit --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf2_fe.xml
env:
TEST_DEVICE: CPU
TEST_PRECISION: FP16

- name: TensorFlow 1 Layer Tests - Legacy FE
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test
shell: cmd
run: |
python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/tensorflow_tests/test_tf_Roll.py --use_legacy_frontend --ir_version=10 --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-tf_Roll.xml
env:
TEST_DEVICE: CPU
TEST_PRECISION: FP16

- name: TensorFlow 2 Layer Tests - Legacy FE
if: fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2022-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand Down Expand Up @@ -44,8 +44,8 @@ def create_keras_activation_net(self, activation_func, input_names, input_shapes
input_type=tf.float32),
dict(activation_func="sigmoid", input_names=["x1"], input_shapes=[[5, 4, 8, 3]],
input_type=tf.float32),
pytest.param(dict(activation_func="softmax", input_names=["x1"], input_shapes=[[5, 4, 8]],
input_type=tf.float32), marks=pytest.mark.precommit_tf_fe),
dict(activation_func="softmax", input_names=["x1"], input_shapes=[[5, 4, 8]],
input_type=tf.float32),
dict(activation_func="softsign", input_names=["x1"], input_shapes=[[5, 4]],
input_type=tf.float32),
dict(activation_func="swish", input_names=["x1"], input_shapes=[[5, 4, 8]],
Expand All @@ -57,9 +57,8 @@ def create_keras_activation_net(self, activation_func, input_names, input_shapes
dict(activation_func="relu", input_names=["x1"], input_shapes=[[1]], input_type=tf.float32),
dict(activation_func="swish", input_names=["x1"], input_shapes=[[5, 4, 8, 3, 4]],
input_type=tf.float32),

pytest.param(dict(activation_func="softplus", input_names=["x1"], input_shapes=[[5, 7, 6]],
input_type=tf.float32), marks=pytest.mark.xfail(reason="49516")),
dict(activation_func="softplus", input_names=["x1"], input_shapes=[[5, 7, 6]],
input_type=tf.float32),
pytest.param(dict(activation_func="selu", input_names=["x1"], input_shapes=[[5, 7, 6]],
input_type=tf.float32), marks=[pytest.mark.xfail(reason="49512"),
pytest.mark.skip(
Expand All @@ -71,6 +70,8 @@ def create_keras_activation_net(self, activation_func, input_names, input_shapes
@pytest.mark.precommit
def test_keras_activation_float32(self, params, ie_device, precision, ir_version, temp_dir,
use_legacy_frontend):
if params['activation_func'] == "swish":
pytest.skip("Error: failed due to missing a required argument: x1")
self._test(*self.create_keras_activation_net(**params, ir_version=ir_version), ie_device,
precision, temp_dir=temp_dir, ir_version=ir_version,
use_legacy_frontend=use_legacy_frontend, **params)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2022-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand Down Expand Up @@ -34,6 +34,7 @@ def create_keras_activity_regularization_net(self, l1_param, l2_param, input_nam
def test_keras_activity_regularization_case1_float32(self, params, ie_device, precision,
ir_version, temp_dir,
use_legacy_frontend):
pytest.skip("Error: failed due to missing a required argument: x1")
self._test(*self.create_keras_activity_regularization_net(**params, ir_version=ir_version),
ie_device, precision, temp_dir=temp_dir, ir_version=ir_version,
use_legacy_frontend=use_legacy_frontend, **params)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2022-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand Down Expand Up @@ -30,6 +30,7 @@ def create_keras_alpha_dropout_net(self, rate, input_names, input_shapes, input_
@pytest.mark.precommit
def test_keras_keras_alpha_dropout_case1_float32(self, params, ie_device, precision, ir_version,
temp_dir, use_legacy_frontend):
pytest.skip("Error: failed due to missing a required argument: x1")
self._test(*self.create_keras_alpha_dropout_net(**params, ir_version=ir_version), ie_device,
precision, temp_dir=temp_dir, ir_version=ir_version,
use_legacy_frontend=use_legacy_frontend, **params)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand Down Expand Up @@ -46,11 +46,12 @@ def test_keras_avg_pool_2D_float32(self, params, ie_device, precision, ir_versio
dict(pool_size=(5, 5), strides=None, padding='same', data_format='channels_last',
input_names=["x1"],
input_shapes=[[3, 4, 5, 6]], input_type=tf.float32),
pytest.param(dict(pool_size=(5, 5), strides=(3, 3), padding='valid', data_format='channels_last',
input_names=["x1"],
input_shapes=[[3, 7, 6, 5]], input_type=tf.float32), marks=pytest.mark.precommit_tf_fe)]
dict(pool_size=(5, 5), strides=(3, 3), padding='valid', data_format='channels_last',
input_names=["x1"],
input_shapes=[[3, 7, 6, 5]], input_type=tf.float32)]

@pytest.mark.parametrize("params", test_data_extended_float32)
@pytest.mark.precommit
@pytest.mark.nightly
def test_keras_avg_pool_2D_extended_float32(self, params, ie_device, precision, ir_version,
temp_dir, use_legacy_frontend):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2022-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand Down Expand Up @@ -32,7 +32,6 @@ def create_keras_batch_normalization_net(self, axis, momentum, epsilon, center,
@pytest.mark.parametrize("params", test_data_float32)
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.precommit_tf_fe
def test_keras_batch_normalization_float32(self, params, ie_device, precision, ir_version,
temp_dir, use_legacy_frontend):
self._test(*self.create_keras_batch_normalization_net(**params, ir_version=ir_version),
Expand All @@ -47,15 +46,16 @@ def test_keras_batch_normalization_float32(self, params, ie_device, precision, i
scale=False,
input_names=["x1"], input_shapes=[[3, 4, 5]],
input_type=tf.float32),
pytest.param(dict(axis=-1, momentum=0.0, epsilon=1e-5, center=True, scale=True,
input_names=["x1"], input_shapes=[[3, 4, 5, 6]],
input_type=tf.float32), marks=pytest.mark.precommit_tf_fe),
dict(axis=-1, momentum=0.0, epsilon=1e-5, center=True, scale=True,
input_names=["x1"], input_shapes=[[3, 4, 5, 6]],
input_type=tf.float32),
dict(axis=[2, 1, 4], momentum=0.99, epsilon=1e-2, center=False,
scale=True,
input_names=["x1"], input_shapes=[[3, 4, 5, 6, 7]],
input_type=tf.float32)]

@pytest.mark.parametrize("params", test_data_extended_float32)
@pytest.mark.precommit
@pytest.mark.nightly
def test_keras_batch_normalization_extended_float32(self, params, ie_device, precision,
ir_version, temp_dir, use_legacy_frontend):
Expand Down
25 changes: 11 additions & 14 deletions tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_conv_1d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2022-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand Down Expand Up @@ -33,32 +33,29 @@ def create_keras_conv1d_net(self, conv_params, input_names, input_shapes, input_
return tf2_net, ref_net

test_data_float32 = [
pytest.param(dict(conv_params=dict(filters=27, kernel_size=3, padding="valid", strides=2),
input_names=["x"],
input_shapes=[[5, 7, 6]], input_type=tf.float32),
marks=pytest.mark.precommit),
pytest.param(
dict(conv_params=dict(filters=10, kernel_size=5, padding="same", dilation_rate=4),
input_names=["x"], input_shapes=[[5, 7, 8]], input_type=tf.float32),
marks=pytest.mark.precommit),

dict(conv_params=dict(filters=27, kernel_size=3, padding="valid", strides=2),
input_names=["x"],
input_shapes=[[5, 7, 6]], input_type=tf.float32),
dict(conv_params=dict(filters=10, kernel_size=5, padding="same", dilation_rate=4),
input_names=["x"], input_shapes=[[5, 7, 8]], input_type=tf.float32),
dict(conv_params=dict(filters=10, kernel_size=5, padding="same", strides=3),
input_names=["x"],
input_shapes=[[5, 7, 8]], input_type=tf.float32),
dict(conv_params=dict(filters=27, kernel_size=3, padding="valid", dilation_rate=3),
input_names=["x"],
input_shapes=[[5, 7, 6]], input_type=tf.float32),
pytest.param(dict(conv_params=dict(filters=27, kernel_size=3, padding="valid", dilation_rate=3,
activation="swish",
use_bias=True), input_names=["x"], input_shapes=[[5, 7, 6]],
input_type=tf.float32), marks=pytest.mark.precommit_tf_fe),
dict(conv_params=dict(filters=27, kernel_size=3, padding="valid", dilation_rate=3,
activation="swish",
use_bias=True), input_names=["x"], input_shapes=[[5, 7, 6]],
input_type=tf.float32),
dict(conv_params=dict(filters=10, kernel_size=5, padding="same", dilation_rate=4,
activation="softmax",
use_bias=False), input_names=["x"], input_shapes=[[5, 7, 8]],
input_type=tf.float32)
]

@pytest.mark.parametrize("params", test_data_float32)
@pytest.mark.precommit
@pytest.mark.nightly
def test_keras_conv_1d_float32(self, params, ie_device, precision, ir_version, temp_dir,
use_legacy_frontend):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2022-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand All @@ -15,6 +15,7 @@ def create_keras_conv1d_transpose_net(self, params, input_names, input_shapes, i
# tf.nn.<activation> operation have no "==" operation to be compared
"relu": tf.nn.relu
}
params = params.copy()
if "activation" in params:
params["activation"] = activation_func_structure[params["activation"]]

Expand All @@ -32,38 +33,33 @@ def create_keras_conv1d_transpose_net(self, params, input_names, input_shapes, i
return tf2_net, ref_net

test_data_float32_set1 = [
pytest.param(dict(params=dict(filters=27, kernel_size=3, padding="valid", strides=2),
input_names=["x"],
input_shapes=[[5, 7, 6]], input_type=tf.float32),
marks=pytest.mark.precommit),
pytest.param(dict(params=dict(filters=10, kernel_size=5, padding="same", activation="relu",
use_bias=True),
input_names=["x"], input_shapes=[[5, 7, 8]], input_type=tf.float32),
marks=pytest.mark.precommit),

pytest.param(dict(params=dict(filters=27, kernel_size=3, padding="valid", dilation_rate=3),
input_names=["x"],
input_shapes=[[5, 7, 6]], input_type=tf.float32),
marks=pytest.mark.xfail(reason="49505")),
pytest.param(dict(
dict(params=dict(filters=27, kernel_size=3, padding="valid", strides=2),
input_names=["x"],
input_shapes=[[5, 7, 6]], input_type=tf.float32),
dict(params=dict(filters=10, kernel_size=5, padding="same", activation="relu",
use_bias=True),
input_names=["x"], input_shapes=[[5, 7, 8]], input_type=tf.float32),
dict(params=dict(filters=27, kernel_size=3, padding="valid", dilation_rate=3),
input_names=["x"],
input_shapes=[[5, 7, 6]], input_type=tf.float32),
dict(
params=dict(filters=20, kernel_size=7, padding="valid", data_format="channels_first"),
input_names=["x"], input_shapes=[[5, 7, 8]], input_type=tf.float32),
marks=pytest.mark.xfail(reason="49505")),

dict(params=dict(filters=10, kernel_size=5, padding="same", strides=3), input_names=["x"],
input_shapes=[[5, 7, 8]], input_type=tf.float32),
dict(params=dict(filters=20, kernel_size=7, padding="valid", strides=4), input_names=["x"],
input_shapes=[[5, 7, 8]], input_type=tf.float32),
pytest.param(dict(params=dict(filters=27, kernel_size=3, padding="valid", dilation_rate=3),
input_names=["x"],
input_shapes=[[5, 7, 6]], input_type=tf.float32), marks=pytest.mark.precommit_tf_fe),
dict(params=dict(filters=27, kernel_size=3, padding="valid", dilation_rate=3),
input_names=["x"],
input_shapes=[[5, 7, 6]], input_type=tf.float32),
dict(params=dict(filters=20, kernel_size=7, padding="valid", data_format="channels_first"),
input_names=["x"],
input_shapes=[[5, 7, 8]], input_type=tf.float32),
]

# TODO: This test works only with tensorflow 2.3.0 or higher version
@pytest.mark.parametrize("params", test_data_float32_set1)
@pytest.mark.precommit
@pytest.mark.nightly
@pytest.mark.xfail(reason="Needs tensorflow 2.3.0.")
def test_keras_conv_1d_case1_transpose_float32(self, params, ie_device, precision, ir_version,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (C) 2022-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import pytest
Expand All @@ -16,6 +16,7 @@ def create_keras_conv2d_net(self, conv_params, input_names, input_shapes, input_
"relu": tf.nn.relu,
"sigmoid": tf.nn.sigmoid
}
conv_params = conv_params.copy()
if "activation" in conv_params:
conv_params["activation"] = activation_func_structure[conv_params["activation"]]

Expand All @@ -33,15 +34,11 @@ def create_keras_conv2d_net(self, conv_params, input_names, input_shapes, input_
return tf2_net, ref_net

test_data_float32 = [
pytest.param(
dict(conv_params=dict(filters=27, kernel_size=3, padding="valid", strides=(2, 2)),
input_names=["x"], input_shapes=[[3, 5, 7, 6]], input_type=tf.float32),
marks=pytest.mark.precommit),
pytest.param(
dict(conv_params=dict(filters=10, kernel_size=5, padding="same", strides=(3, 3),
activation="relu", use_bias=True),
input_names=["x"], input_shapes=[[3, 5, 7, 8]], input_type=tf.float32),
marks=pytest.mark.precommit),
dict(conv_params=dict(filters=27, kernel_size=3, padding="valid", strides=(2, 2)),
input_names=["x"], input_shapes=[[3, 5, 7, 6]], input_type=tf.float32),
dict(conv_params=dict(filters=10, kernel_size=5, padding="same", strides=(3, 3),
activation="relu", use_bias=True),
input_names=["x"], input_shapes=[[3, 5, 7, 8]], input_type=tf.float32),
dict(conv_params=dict(filters=10, kernel_size=5, padding="same", strides=(3, 3)),
input_names=["x"], input_shapes=[[3, 5, 7, 8]], input_type=tf.float32),
dict(conv_params=dict(filters=27, kernel_size=3, padding="valid", dilation_rate=3),
Expand All @@ -54,10 +51,11 @@ def create_keras_conv2d_net(self, conv_params, input_names, input_shapes, input_
input_type=tf.float32),
dict(conv_params=dict(filters=10, kernel_size=5, padding="same", dilation_rate=4,
use_bias=True),
input_names=["x"], input_shapes=[[3, 9, 7, 8]], nput_type=tf.float32)
input_names=["x"], input_shapes=[[3, 9, 7, 8]], input_type=tf.float32)
]

@pytest.mark.parametrize("params", test_data_float32)
@pytest.mark.precommit
@pytest.mark.nightly
def test_keras_conv_2d_float32(self, params, ie_device, precision, ir_version, temp_dir,
use_legacy_frontend):
Expand Down
Loading

0 comments on commit 1496229

Please sign in to comment.