-
Notifications
You must be signed in to change notification settings - Fork 207
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
Generic TopK implementation #744
Conversation
@soumith @wickedfoo This is ready. |
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.
I think this looks good to me.
lib/THC/THCTensorTopK.cuh
Outdated
typedef unsigned int RadixType; | ||
|
||
static inline __device__ RadixType convert(short v) { | ||
return 32768u + 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.
add a static assert that sizeof(short) == 2 to ensure that this is a correct constant
lib/THC/THCTensorTopK.cuh
Outdated
typedef unsigned int RadixType; | ||
|
||
static inline __device__ RadixType convert(int v) { | ||
return 2147483648u + 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.
add a static assert that sizeof(int) == 4 to ensure that this is a correct constant
lib/THC/THCTensorTopK.cuh
Outdated
typedef unsigned long long int RadixType; | ||
|
||
static inline __device__ RadixType convert(long v) { | ||
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.
add a static assert that sizeof(long) == 8 to ensure that this is a correct constant
This PR makes TopK generic. The main changes required to do this were: