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

Supports float16 as an opaque uint16 array #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vallsv
Copy link

@vallsv vallsv commented Apr 17, 2024

Closes #44

This PR add support of npy file containing float16.

Float 16-bits is not supported in JavaScript as a TypedArray, but can be passed through javascript as an opaque memory and be used inside webgl.

So what we use instead a Uint16Array. This allow to match the right memory size and the right item indexing. This for example allow to use NdArray library for slicing.

In Javascript, the indexing also allow to read values as a bit field. This can be used to decode the value manually. See for example https://stackoverflow.com/a/8796597.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raw access for float16
1 participant