From a7ff891fa552532091576ea39e883c30c5fcf241 Mon Sep 17 00:00:00 2001 From: David Nam Date: Wed, 30 Oct 2024 18:41:08 +0800 Subject: [PATCH] [GPU] Init tensor.data when allocating inputs for string type (#27269) ### Details: - In case the element type is string produces the segmentation fault when input data is an empty string, unless the each element of tensor.data is initialized. ### Tickets: - 148921 --- src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp | 6 ++++++ .../layer_tests/tensorflow_tests/test_tf_LookupTableSize.py | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp index 26771117e2e786..985336b801b9d3 100644 --- a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp +++ b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp @@ -592,6 +592,12 @@ void SyncInferRequest::allocate_input(const ov::Output& port, si auto element_type = port.get_element_type(); m_user_inputs[input_idx] = { create_host_tensor(shape, element_type), TensorOwner::PLUGIN }; + if (element_type == ov::element::string) { + // In case the element type is string and input data is an empty string, + // it produces the segmentation fault unless the each element of tensor.data is initialized. + auto data = m_user_inputs.at(input_idx).ptr->data(); + std::uninitialized_fill_n(data, m_user_inputs.at(input_idx).ptr->get_size(), std::string()); + } ov::ISyncInferRequest::set_tensor(port, m_user_inputs.at(input_idx).ptr); } diff --git a/tests/layer_tests/tensorflow_tests/test_tf_LookupTableSize.py b/tests/layer_tests/tensorflow_tests/test_tf_LookupTableSize.py index e0050c245f1321..4cd5b05f3e86d4 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_LookupTableSize.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_LookupTableSize.py @@ -69,8 +69,6 @@ def create_lookup_table_size_net(self, hash_table_type, keys_type, values_type, 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)