-
Couldn't load subscription status.
- Fork 25.7k
fix asserts in cuda code #39047
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 asserts in cuda code #39047
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,7 +76,7 @@ struct TopKTypeConfig<short> { | |
| typedef unsigned int RadixType; | ||
|
|
||
| static inline __device__ RadixType convert(short v) { | ||
| CUDA_KERNEL_ASSERT(sizeof(short) == 2); | ||
| static_assert(sizeof(short) == 2, ""); | ||
| return 32768u + v; | ||
| } | ||
|
|
||
|
|
@@ -90,7 +90,7 @@ struct TopKTypeConfig<int> { | |
| typedef unsigned int RadixType; | ||
|
|
||
| static inline __device__ RadixType convert(int v) { | ||
| CUDA_KERNEL_ASSERT(sizeof(int) == 4); | ||
| static_assert(sizeof(int) == 4, ""); | ||
| return 2147483648u + v; | ||
| } | ||
|
|
||
|
|
@@ -104,6 +104,7 @@ struct TopKTypeConfig<long> { | |
| typedef unsigned long long int RadixType; | ||
|
|
||
| static inline __device__ RadixType convert(long v) { | ||
| //static_assert fails on windows, so leave it as CUDA_KERNEL_ASSERT | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...how does the CUDA_KERNEL_ASSERT not fail on windows? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will fail, if someone tries to run caffe2 radix sort for long inputs on windows pytorch build. Hopefully, no one will do it, but I can't make it static_assert, because with static_assert windows build itself fails. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we just make this into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not familiar with caffe2 code and don't know if it's possible. It is also probably untested? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it will break anything because of the assert |
||
| CUDA_KERNEL_ASSERT(sizeof(long) == 8); | ||
| return 9223372036854775808ull + v; | ||
| } | ||
|
|
||
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.
oh, these aren't run in CUDA?! Intruiging.