npyjs
npyjs copied to clipboard
Supports float16 as an opaque uint16 array
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.