Is float16 supported in Matlab?

Does MATLAB support float16 operations? If so, how do I convert the double matrix to float16? I am performing an arithmetic operation on a large matrix, where a 16-bit floating representation is enough for my representation. Representation by a double data type takes 4 times more memory.

+4
source share
3 answers

Is your matrix complete? Otherwise, try sparse - save a lot of memory if there are a lot of null elements.

AFAIK, float16 not supported. The lowest, you can go to float -datatype with single , which is a 32-bit data type:

 A = single( rand(50) ); 

You can multiply by a constant and apply to int16 , but you will lose precision.

+4
source

The number classes that Matlab supports out of the box are as follows:

 int8 int16 int32 int64 uint8 uint16 uint32 uint64 single (32-bit float) double (64-bit float) 

plus a complex data type. So, unfortunately, there are no 16-bit floats.

When exchanging Mathworks files, there appears to be half the accuracy of the float library . This requires mex, however.

+5
source

This may be an old question, but I found it looking for a similar problem (half precision in matlab).

Things seemed to change over time: https://www.mathworks.com/help/fixedpoint/ref/half.html

Half precision seems to be supported by Matlab for nativeley.

0
source

All Articles