You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When restructuring a model after Flux.destructure, it becomes type unstable (and slow).
Is there a way to avoid this?
using Flux
using BenchmarkTools
model = Chain(Dense(1,64,σ),Dense(64,1))
p, re = Flux.destructure(model)
re_model(x,p,re) = re(p)(x) # passing re here doesn't make a difference
@code_warntype model([1f0]) # type stable
@btime $model($[1f0]) # 460.406 ns (4 allocations: 864 bytes)
@code_warntype re_model([1f0],p,re) # type unstable
@btime $re_model($[1f0],$p,$re) # 3.850 μs (57 allocations: 3.86 KiB)
The text was updated successfully, but these errors were encountered:
Hi,
When restructuring a model after Flux.destructure, it becomes type unstable (and slow).
Is there a way to avoid this?
The text was updated successfully, but these errors were encountered: