Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PyAPI] Fix string truncation when special \u0000 is inside string #28373

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

praasz
Copy link
Contributor

@praasz praasz commented Jan 10, 2025

Details:

  • Detect correct length of input string from py::array
  • Remove trailing null characters from strings stored in ov::Tensor
  • There is single misalignment with numpy format when there are trailing null characters. The strides will be not same for OV representation. This is not real (very uncommon) case of use string with many trailing null characters.

Related PRs:

Tickets:

align py::array conversion with numpy logic

Signed-off-by: Raasz, Pawel <[email protected]>
@praasz praasz added this to the 2025.0 milestone Jan 10, 2025
@praasz praasz requested a review from a team as a code owner January 10, 2025 11:19
@github-actions github-actions bot added the category: Python API OpenVINO Python bindings label Jan 10, 2025
Signed-off-by: Raasz, Pawel <[email protected]>
Signed-off-by: Raasz, Pawel <[email protected]>
@praasz praasz changed the title [PyAPI] Fix string turncation when special \u0000 is inside string [PyAPI] Fix string truncation when special \u0000 is inside string Jan 10, 2025
Signed-off-by: Raasz, Pawel <[email protected]>
@@ -118,15 +118,29 @@ const TensorIndexMap cast_to_tensor_index_map(const py::dict& inputs) {

namespace string_helpers {

namespace {
auto find_last_not_null(const std::string& str) {
Copy link
Contributor

@akuporos akuporos Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please specify a return type here for readability?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was done intentionally to auto deduce return type. As local scope helper is easier to modify it. The IDE's hint or compiler will show detailed type if there will be wrong use.

@praasz praasz requested a review from akuporos January 10, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Python API OpenVINO Python bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants