npyjs icon indicating copy to clipboard operation
npyjs copied to clipboard

Raw access for float16

Open vallsv opened this issue 1 year ago • 2 comments

Hi,

I am using your library for fast prototyping.

It was very convenient to use but i had to patch it to read float16.

float16 is not supported by js, but is supported by webgl. So this allow to fetch the data as an opaque manner, the shape remains the same, and the result is anyway typed with dtype==='float16'.

I also use some wrapper to read float16 values in js, but i think it is not really needed at this stage.

Anyway, here is setup.

import _npyjs from 'npyjs';

const npyjs = new _npyjs();

// Supports float16 as uint16
npyjs.dtypes['<f2'] = {
  name: 'float16',
  size: 16,
  arrayConstructor: Uint16Array,
};

Tell me if you prefer to have a PR. Regards,

vallsv avatar Apr 16 '24 13:04 vallsv

I'd love to have a PR if you are willing to share, thank you!!

j6k4m8 avatar Apr 16 '24 20:04 j6k4m8

Nice, ill try to do that with a data test.

vallsv avatar Apr 17 '24 12:04 vallsv