CTUAvastLab/JsonGrinder.jl

consistently use uint32 instead of int64 for onehot and maybehot matrices

racinmat opened this issue · 2 comments

after the change benchmark it, it should be significantly faster

Benchmark difference between using onehotbatch and explicit constructor. If speed difference would be negligible, use batch variant.

onehotbatch is too slow, see

julia> @btime((Flux.OneHotMatrix(collect(1:100), 1_000); nothing))
  314.530 ns (3 allocations: 928 bytes)
julia> @btime((Flux.OneHotMatrix(collect(UInt32, 1:100), 1_000); nothing))
  301.594 ns (3 allocations: 528 bytes)
julia> @btime((Flux.onehotbatch(1:100, 1:1_000); nothing))
  155.399 μs (906 allocations: 41.70 KiB)