-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix inconsistencies and speed in C tests #11
Conversation
* Delete unused macros * Delete mostly unused types * Replace format binary16 with E5M2 * Split overly large tests * Fix duplicate test names * Remove in-place tests that use same array as input
Looks good. For formats with inf -> NaN on overflow we may need separate tests in the future. |
I added tests for formats without infinities in 99665da. The tests extended case 2c. However, if I choose unbalanced for |
I set up in
and 1c, 2e pass for me. I have the following in 2c, however. cpfloat_test(91092,0x1f58a0c00) malloc: *** error for object 0x14ff05aa0: pointer being freed was not allocated |
Are you changing the following line to static size_t nformats = 3; If not, the additional format will not be tested – and this might be what's causing the memory issue, although I'm not sure. |
in = 5.120000000000000e+02 [4647714815446351872] in = 4.960000000000000e+02 [4647433340469641216] The tests that fail seem to expect 512 as an answer, but the maximum representable value in E3M4 is 448. The reference is therefore calculated incorrectly. Furthermore, the output produces an infinity which E3M4 does not contain; a NaN should be produced. |
Thanks a lot for looking into this – I think you hit the nail on the head. Currently, the C interface does not allow users to specify a format (such as E3M4), and what is being tested is a format with The largest representable value, on the other hand, is calculated in the usual way as I've just pushed a fix for these, and now all tests seem to pass for the format with unbalanced exponent. |
For E3M4 the maximum value has to be computed differently than usual, as 2^8(2-2^{-2})=448 instead of 2^8(2-2^{-3}). Check Table 2 in https://www.opencompute.org/documents/ocp-8-bit-floating-point-specification-ofp8-revision-1-0-2023-12-01-pdf-1. Are we not having any issues because of this? |
The C tests assume IEEE-compliant formats. It is true that |
This change reduces the execution time of the tests by almost 50%. It ditches
binary16
andTensorFloat-32
(which was only used in test1a.
anyway) and adds inE5M2
.I tried adding
E4M3
instead, but tests1c.
and2e.
fail for that format.