OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[TF FE] Stabilize L2Loss layer tests on all platforms (#26151)
Roman Kazantsevabbf944fe172
diff --git a/tests/layer_tests/tensorflow_tests/test_tf_L2Loss.py b/tests/layer_tests/tensorflow_tests/test_tf_L2Loss.pyindex e43808fbb68..ddd14eb2ae2 100644--- a/tests/layer_tests/tensorflow_tests/test_tf_L2Loss.py+++ b/tests/layer_tests/tensorflow_tests/test_tf_L2Loss.py@@ -1,38 +1,46 @@# Copyright (C) 2018-2024 Intel Corporation# SPDX-License-Identifier: Apache-2.0+import numpy as npimport pytestimport tensorflow as tffrom common.tf_layer_test_class import CommonTFLayerTest+rng = np.random.default_rng(233453)+class TestL2Loss(CommonTFLayerTest):- def create_l2_loss_net(self, input_shape):+ def _prepare_input(self, inputs_info):+ assert 'input:0' in inputs_info, "Test error: inputs_info must contain `input`"+ input_shape = inputs_info['input:0']+ inputs_data = {}+ inputs_data['input:0'] = rng.uniform(-2.0, 2.0, input_shape).astype(self.input_type)+ return inputs_data++ def create_l2_loss_net(self, input_shape, input_type):+ self.input_type = input_typetf.compat.v1.reset_default_graph()# Create the graph and modelwith tf.compat.v1.Session() as sess:- input = tf.compat.v1.placeholder(tf.float32, input_shape, 'input')+ input = tf.compat.v1.placeholder(input_type, input_shape, 'input')tf.raw_ops.L2Loss(t=input, name='l2_loss')tf.compat.v1.global_variables_initializer()-tf_net = sess.graph_defreturn tf_net, None- test_data_basic = [- dict(input_shape=[1, 2]),- dict(input_shape=[2, 3, 4]),- ]-- @pytest.mark.parametrize("params", test_data_basic)+ @pytest.mark.parametrize("input_shape", [[], [2], [1, 2], [2, 3, 4]])+ @pytest.mark.parametrize("input_type", [np.float16, np.float32, np.float64])@pytest.mark.precommit@pytest.mark.nightly- def test_l2_loss_basic(self, params, ie_device, precision, ir_version, temp_dir,+ def test_l2_loss_basic(self, input_shape, input_type,+ ie_device, precision, ir_version, temp_dir,use_legacy_frontend):- if ie_device == 'GPU':- pytest.xfail('104863')- if use_legacy_frontend:- pytest.skip("L2Loss is not supported by legacy FE.")- self._test(*self.create_l2_loss_net(**params),+ custom_eps = None+ if input_type == np.float16:+ custom_eps = 3 * 1e-3+ if ie_device == 'GPU' and input_shape == []:+ pytest.skip("150321: Accessing out-of-range dimension on GPU")+ self._test(*self.create_l2_loss_net(input_shape, input_type),ie_device, precision, ir_version, temp_dir=temp_dir,- use_legacy_frontend=use_legacy_frontend)+ use_legacy_frontend=use_legacy_frontend, custom_eps=custom_eps)