npyjs icon indicating copy to clipboard operation
npyjs copied to clipboard

Supports float16 as an opaque uint16 array

Open vallsv opened this issue 1 year ago • 0 comments

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.

vallsv avatar Apr 17 '24 18:04 vallsv