Skip to content

Commit

Permalink
[TF FE] Stabilize tests for UnsortedSegmentSum operation on all platf…
Browse files Browse the repository at this point in the history
…orms (openvinotoolkit#27325)

**Details:** Stabilize tests for UnsortedSegmentSum operation on all
platforms

**Ticket:** TBD

---------

Signed-off-by: Kazantsev, Roman <[email protected]>
  • Loading branch information
rkazants authored Oct 30, 2024
1 parent a7ff891 commit 2441dcd
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions tests/layer_tests/tensorflow_tests/test_tf_UnsortedSegmentSum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np
import platform
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest

rng = np.random.default_rng(23254)


class TestUnsortedSegmentSum(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
Expand All @@ -15,10 +16,10 @@ def _prepare_input(self, inputs_info):
data_shape = inputs_info['data:0']
segment_ids_shape = inputs_info['segment_ids:0']
inputs_data = {}
inputs_data['data:0'] = np.random.randint(-50, 50, data_shape).astype(self.data_type)
inputs_data['data:0'] = rng.integers(-10, 10, data_shape).astype(self.data_type)
# segment_ids can have negative values
inputs_data['segment_ids:0'] = np.random.randint(-self.num_segments_val, self.num_segments_val,
segment_ids_shape)
inputs_data['segment_ids:0'] = rng.integers(-self.num_segments_val, self.num_segments_val,
segment_ids_shape).astype(self.segment_ids_type)
return inputs_data

def create_unsorted_segment_sum_net(self, data_shape, segment_ids_shape, num_segments_val, data_type,
Expand Down Expand Up @@ -48,28 +49,18 @@ def create_unsorted_segment_sum_net(self, data_shape, segment_ids_shape, num_seg
]

@pytest.mark.parametrize("params", test_data_basic)
@pytest.mark.parametrize("data_type", [
np.float32, np.int32
])
@pytest.mark.parametrize("segment_ids_type", [
np.int32, np.int64
])
@pytest.mark.parametrize("num_segments_type", [
np.int32, np.int64
])
@pytest.mark.parametrize("data_type", [np.float32, np.int32])
@pytest.mark.parametrize("segment_ids_type", [np.int32, np.int64])
@pytest.mark.parametrize("num_segments_type", [np.int32, np.int64])
@pytest.mark.precommit
@pytest.mark.nightly
@pytest.mark.xfail(condition=platform.system() == 'Darwin' and platform.machine() == 'arm64',
reason='Ticket - 122716')
def test_unsorted_segment_sum_basic(self, params, data_type, segment_ids_type, num_segments_type, ie_device,
precision, ir_version, temp_dir,
use_legacy_frontend):
if use_legacy_frontend:
pytest.skip("UnsortedSegmentSum operation is not supported via legacy frontend.")
if ie_device == 'GPU':
pytest.skip("GPU error: Can't choose implementation for embedding_segment_sum:UnsortedSegmentSum node")
self._test(
*self.create_unsorted_segment_sum_net(**params, data_type=data_type, segment_ids_type=segment_ids_type,
num_segments_type=num_segments_type),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_legacy_frontend=use_legacy_frontend)
pytest.skip("156362: No layout format available for embeddingsegmentssum:UnsortedSegmentSum on GPU")
self._test(*self.create_unsorted_segment_sum_net(**params,
data_type=data_type, segment_ids_type=segment_ids_type,
num_segments_type=num_segments_type),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_legacy_frontend=use_legacy_frontend)

0 comments on commit 2441dcd

Please sign in to comment.