TuringLang / AdvancedHMC.jl

Robust, modular and efficient implementation of advanced Hamiltonian Monte Carlo algorithms
https://turinglang.org/AdvancedHMC.jl/
MIT License
237 stars 41 forks source link

Use SimpleUnPack #318

Closed devmotion closed 1 year ago

devmotion commented 1 year ago

Since UnPack.@unpack is based on unpack(x, Val(key)) it can lead to a lot of undesired specializations, see e.g. https://github.com/SciML/OrdinaryDiffEq.jl/pull/1893. Therefore I put together a more lightweight macro in https://github.com/devmotion/SimpleUnPack.jl (by design, it has less features than UnPack.jl): the expression is just rewritten to a sequence of getproperty calls without any Val on older Julia versions and to the Base destructuring syntax on Julia >= 1.7.