-
Notifications
You must be signed in to change notification settings - Fork 171
Add tests to cover scalar handling in launch()
+ Fix fp16 bug
#669
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
Conversation
elif supported_type is __half_raw: | ||
(<supported_type*>ptr).x = <int16_t>(arg.view(numpy_int16)) | ||
else: | ||
(<supported_type*>ptr)[0] = <supported_type>(arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the bug: When arg
is a np.float16
scalar, the old code would treat it as int16_t
(due to lack of standard C++ identifier for fp16 before C++23), and the scalar would be static_cast
to int16_t
, which triggered non-trivial conversion operators. The new code ensures that there is no conversion and the bytes are reinterpret_cast
'd, and in order to hit this new path we need a unique type identifier, which is __half_raw
.
/ok to test f4852bd |
This comment has been minimized.
This comment has been minimized.
/ok to test 63a68de |
|
Description
closes #260.
The test coverage revealed a bug in the fp16 scalar handling. The existing handling is obviously wrong and it's me to blame, but I honestly can't recall why I believed the code was correct 😞
Checklist