Skip to content

Android/fix evalue string serialization#17609

Merged
kirklandsign merged 3 commits intomainfrom
android/fix-evalue-string-serialization
Feb 23, 2026
Merged

Android/fix evalue string serialization#17609
kirklandsign merged 3 commits intomainfrom
android/fix-evalue-string-serialization

Conversation

@kirklandsign
Copy link
Copy Markdown
Contributor

Summary

toByteArray() used toString() (returning "EValue@...") instead of
toStr(), and allocated the buffer using char count instead of byte
count. fromByteArray() threw an exception for strings instead of
deserializing them. Fix both directions using a length-prefixed
format, and also fix the misleading "Unknown Tensor dtype" error
message. Add round-trip tests for ASCII, empty, and Unicode strings.

Test plan

CI

toByteArray() used toString() (returning "EValue@...") instead of
toStr(), and allocated the buffer using char count instead of byte
count. fromByteArray() threw an exception for strings instead of
deserializing them. Fix both directions using a length-prefixed
format, and also fix the misleading "Unknown Tensor dtype" error
message. Add round-trip tests for ASCII, empty, and Unicode strings.
Chinese (3-byte UTF-8) and emoji (4-byte UTF-8 + surrogate pairs)
cover more encoding edge cases than Japanese hiragana alone.
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Feb 21, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17609

Note: Links to docs will display an error until the docs builds have been completed.

❌ 3 New Failures, 53 Pending

As of commit f9bc02c with merge base cf08087 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 21, 2026
@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@kirklandsign kirklandsign marked this pull request as ready for review February 23, 2026 19:13
Copilot AI review requested due to automatic review settings February 23, 2026 19:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes critical bugs in EValue string serialization/deserialization for the Android ExecuTorch extension. Previously, toByteArray() used toString() (which returned "EValue@..." object representation) instead of toStr(), and fromByteArray() threw an exception for strings. The fix implements a length-prefixed binary format for strings and corrects the error message.

Changes:

  • Fixed string serialization to use toStr() instead of toString() and implements length-prefixed format
  • Fixed string deserialization to properly decode strings instead of throwing exceptions
  • Improved error message from "Unknown Tensor dtype" to "Unknown EValue type code"
  • Added comprehensive round-trip tests for ASCII, empty, Chinese, and emoji strings

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
extension/android/executorch_android/src/main/java/org/pytorch/executorch/EValue.java Fixes string serialization/deserialization logic and error messages
extension/android/executorch_android/src/test/java/org/pytorch/executorch/EValueTest.kt Adds comprehensive tests for string serialization round-trips including Unicode

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kirklandsign kirklandsign merged commit bf0cd1c into main Feb 23, 2026
195 of 203 checks passed
@kirklandsign kirklandsign deleted the android/fix-evalue-string-serialization branch February 23, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants