diff --git a/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher.py b/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher.py index bce10c9c3774ef..9b14a9f13c3ea4 100644 --- a/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher.py +++ b/src/bindings/python/src/openvino/runtime/utils/data_helpers/data_dispatcher.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 from functools import singledispatch -from typing import Any, Dict, Union, Optional +from typing import Any, Dict, Union, Optional, List import numpy as np @@ -41,6 +41,16 @@ def get_request_tensor( raise TypeError(f"Unsupported key type: {type(key)} for Tensor under key: {key}") +def is_all_ascii(input_array: Union[np.ndarray, List[bytes]]) -> bool: + def isascii(data: Union[str, bytes]) -> bool: + if isinstance(data, bytes): + data = data.decode("utf-8") + return data.isascii() + v_isascii = np.vectorize(isascii) + ascii_flags = v_isascii(input_array) + return ascii_flags.all() + + @singledispatch def value_to_tensor( value: Union[Tensor, np.ndarray, ScalarTypes, str], @@ -321,7 +331,11 @@ def _( tensor.shape = inputs.shape # When copying, type should be up/down-casted automatically. if tensor.element_type == Type.string: - tensor.bytes_data = inputs + # Edge case resolving assignment segfaults on GPU + if is_all_ascii(inputs) and inputs.dtype.char == "U" and inputs.flags["F_CONTIGUOUS"]: + tensor.bytes_data[:] = inputs[:] + else: + tensor.bytes_data = inputs else: tensor.data[:] = inputs[:] else: diff --git a/tests/layer_tests/tensorflow_tests/test_tf_LookupTableSize.py b/tests/layer_tests/tensorflow_tests/test_tf_LookupTableSize.py index e0050c245f1321..04831c5604358a 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_LookupTableSize.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_LookupTableSize.py @@ -68,9 +68,6 @@ def create_lookup_table_size_net(self, hash_table_type, keys_type, values_type, @pytest.mark.nightly def test_lookup_table_size(self, hash_table_type, params, ie_device, precision, ir_version, temp_dir, use_legacy_frontend): - keys_type = params['keys_type'] - if ie_device == 'GPU' and keys_type == str: - pytest.skip("148921: Segmentation fault on GPU") self._test(*self.create_lookup_table_size_net(hash_table_type=hash_table_type, **params), ie_device, precision, ir_version, temp_dir=temp_dir, use_legacy_frontend=use_legacy_frontend)