diff --git a/src/bindings/python/src/pyopenvino/core/common.cpp b/src/bindings/python/src/pyopenvino/core/common.cpp index a792a6ff6482c9..1b554c391a6ebd 100644 --- a/src/bindings/python/src/pyopenvino/core/common.cpp +++ b/src/bindings/python/src/pyopenvino/core/common.cpp @@ -187,6 +187,7 @@ void fill_tensor_from_strings(ov::Tensor& tensor, py::array& array) { } py::buffer_info buf = array.request(); auto data = tensor.data(); + std::cout << "fill_tensor_from_strings()" << std::endl; for (size_t i = 0; i < tensor.get_size(); ++i) { char* ptr = reinterpret_cast(buf.ptr) + (i * buf.itemsize); // TODO: check other unicode kinds? 2BYTE and 1BYTE? @@ -194,10 +195,7 @@ void fill_tensor_from_strings(ov::Tensor& tensor, py::array& array) { PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, reinterpret_cast(ptr), buf.itemsize / 4); PyObject* _utf8_obj = PyUnicode_AsUTF8String(_unicode_obj); const char* _tmp_str = PyBytes_AsString(_utf8_obj); - std::string d(_tmp_str); - if (!d.empty()) { - data[i] = d; - } + data[i] = std::string(_tmp_str); Py_XDECREF(_unicode_obj); Py_XDECREF(_utf8_obj); } 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 58e99e037fb931..e31999179a017b 100644 --- a/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp +++ b/src/plugins/intel_gpu/src/plugin/sync_infer_request.cpp @@ -591,6 +591,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) { + std::string* data = m_user_inputs.at(input_idx).ptr->data(); + for (size_t i = 0; i < m_user_inputs.at(input_idx).ptr->get_size(); ++i) { + data[i] = '\0'; + } + } ov::ISyncInferRequest::set_tensor(port, m_user_inputs.at(input_idx).ptr); }