Skip to content

[Android] Support 16bit output data as raw data byte[] #10412

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

Closed
wants to merge 2 commits into from

Conversation

kirklandsign
Copy link
Contributor

@kirklandsign kirklandsign commented Apr 23, 2025

In java, when the returned dtype is fp16 or bf16, instead of crash, use byte[] to represent these raw data, and let user parse the byte[]

We don't support fp16 or bf16 as input dtype. User can convert to fp32.

Resolved: #9881
Resolved: #10371

cc @cbilgin @guangy10 @huydhn @shoumikhin

In java, when the returned dtype is fp16 or bf16, instead of crash, use
byte[] to represent these raw data, and let user parse the byte[]
Copy link

pytorch-bot bot commented Apr 23, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 833d388 with merge base 98c2c53 (image):

NEW FAILURE - The following job has failed:

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

@kirklandsign kirklandsign marked this pull request as ready for review April 23, 2025 21:34
@facebook-github-bot facebook-github-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 Apr 23, 2025
@kirklandsign kirklandsign added topic: not user facing module: benchmark Issues related to the benchmark infrastructure labels Apr 23, 2025
@kirklandsign kirklandsign added the module: android Issues related to Android code, build, and execution label Apr 23, 2025
@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@kirklandsign kirklandsign changed the title [Android] Support 16bit data as raw data byte[] [Android] Support 16bit output data as raw data byte[] Apr 23, 2025
@@ -674,6 +712,10 @@ private static Tensor nativeNewTensor(
tensor = new Tensor_uint8(data, shape);
} else if (DType.INT8.jniCode == dtype) {
tensor = new Tensor_int8(data, shape);
} else if (DType.HALF.jniCode == dtype) {
tensor = new Tensor_raw_data_16b(data, shape, DType.HALF);
} else if (DType.HALF.jniCode == dtype) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is same check as L715, should be DType.BFLOAT16.jniCode == dtype?

@kirklandsign
Copy link
Contributor Author

Per discussion, we use #10414 instead. Don't support it as output data type.

@kirklandsign kirklandsign deleted the java-tensor-16bit-type branch April 24, 2025 06:08
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. module: android Issues related to Android code, build, and execution module: benchmark Issues related to the benchmark infrastructure topic: not user facing
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Android] Add java layer fp16 support Support BFloat16 dtype in Android Tensor API
3 participants