GPU-friendly one-hot encoding

That’s a pity. I wonder if hot1(cu([1,2,3,5,2,1]), 1:5) works? Or something like ifelse.(s' .== k, 1, 0) to make integers?

Also un-GPU-tested, the shortest @tullio version would be:

julia> hot2(s) = @tullio x[s[j], j] := 1;

julia> hot2([1,2,3,5,2,1])
5×6 Matrix{Int64}:
 1  0  0  0  0  1
 0  1  0  0  1  0
 0  0  1  0  0  0
 0  0  0  0  0  0
 0  0  0  1  0  0
4 Likes