-
Notifications
You must be signed in to change notification settings - Fork 608
Java Tensor and EValue serialization #6620
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/6620
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 7 New FailuresAs of commit 8750e17 with merge base f40daea ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
1effbd0
to
0598d89
Compare
c61a10b
to
74be7a5
Compare
Add serialization and deserialization for EValue (except string) and Tensor. RFC: #6569
74be7a5
to
44283a2
Compare
.put((byte) TYPE_CODE_STRING) | ||
.put(toString().getBytes()) | ||
.array(); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will we add list support as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per Jacob, list is an internal dtype within ET runtime. Maybe we should totally get rid of list in java layer. I could double check with the team
int dtypeSize = 0; | ||
byte[] tensorAsByteArray = null; | ||
if (dtype() == DType.FLOAT) { | ||
dtypeSize = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you reference the consts on L56 and add the missing ones? (uint8, int8)
byte scalarType = buffer.get(); | ||
byte numberOfDimensions = buffer.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use same constants as the serialize function? dtype and shapeLength?
private static final int TYPE_CODE_NONE = 0; | ||
private static final int TYPE_CODE_TENSOR = 1; | ||
private static final int TYPE_CODE_STRING = 2; | ||
private static final int TYPE_CODE_DOUBLE = 3; | ||
private static final int TYPE_CODE_INT = 4; | ||
private static final int TYPE_CODE_BOOL = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can just expose the constants in EValue as public instead of copying this here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really implementation detail and I want to avoid exposing it. Honestly we shouldn't test it as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could consider using switch statements instead of if, but looks good
Will follow up :) |
Add serialization and deserialization for EValue (except string) and Tensor.
Summary
Fixes #6569
Test plan