-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[js/common] allows using Uint16Array as data for float16 tensor #23827
Conversation
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.
Thanks Yulong.
@Honry @xenova Could you please help to check if this PR fixes the problem? It should work but I don't have a chance to test it E2E. Artifacts can be downloaded at https://dev.azure.com/onnxruntime/onnxruntime/_build/results?buildId=1629021&view=artifacts&pathAsName=false&type=publishedArtifacts |
@fs-eire, verified, thanks for the quick fix. |
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.
Thanks for the fix! For transformers.js, we'll also default to Float16Array if available: #23817
@fs-eire, hold on, this still breaks demos that read the outputs as |
Ooh, that's more complicated. How does ORT know what the output type should be? It could look at the input types to deduce the output types (e.g. if there were uint16-as-float16 input tensors, then presumably any output float16 tensors should be uint16 too), but it wouldn't be fully robust (e.g. say you had a model that took int32 inputs and float16-as-uint16 outputs, which there is no input hint to know the output type). Well, it might be a good enough transient heuristic for now. |
Exactly, it’s difficult to know what the output type should be. Users have to add API check to determine if |
as explained by @fdwr, I think there is no way to do this inside ORT to fix this problem, you need to modify the application code. a simple way is that for all float16 output, you always create a Uint16Array wrapper:
|
@Honry Please let me know if you are OK with this change or we need further discussion |
Make sense, and we should remind end users to change their application code if need. |
Sounds worth adding to the breaking changes section: https://github.com/microsoft/webnn-developer-preview?tab=readme-ov-file#breaking-changes |
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.
👍
Description
Resolve #23817
Motivation and Context