ATen cuda kernel dispatch for type

I am using ATen and this example, from here.
I have a kernel that needs one array of floats (for input) and one array of ints (for labels), should I still use AT_DISPATCH_FLOATING_TYPES?

  1. does this line mean only floats will be marshalled to cuda kernel? or is it just specifying the scalar_t?

    AT_DISPATCH_FLOATING_TYPES(X.type(), “lltm_forward_cuda” …

  2. Please correct me if I am wrong: The integral types (int, bool, …) I guess need no special treatment

P.S. it looks like both lines 123 and 157 pass “lltm_forward_cuda” as the second argument, that does not seem right if it is for debugging

1 Like

Re 1: AT_DISPATCH_FLOATING_TYPES will do float and double automatically.
You specify the dispatch for the type of X. When you have an int-Tensor-argument Y, it’ll be the same. You cannot pass an int-Tensor as X here.
If you want half, there also is a _AND_HALF version.
Re 2: You don’t get any special treatment of these and would have to do it on your own.
Probably using backward in the second string is better.

Best regards



Hello If anybody will be looking for it now there are multpple at dispatch macros here