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
Hi, I've been able to get a little more detail on an issue I've been seeing in Soss and Tilde. As usual, it's entirely possible the bug may be in one of my packages, but I hope this example might help narrow down the problem.
Say we have this in Tilde:
m =@model n begin
p ~Uniform()
x ~For(n) do j
Bernoulli(p)
endend
x =rand(Bool, 3)
logdensityof(m(3) | (;x), (p=0.2,))
In this code, p is declared local, then assigned, and then used in a closure. But it should be easy to guarantee that p does not change its type. We usually have this, which is why I have lines like p::Float64 = _pars.p. I got this from the Julia docs, which say
If captured variables are used in a performance-critical section of the code, then the following tips help ensure that their use is performant. First, if it is known that a captured variable does not change its type, then this can be declared explicitly with a type annotation (on the variable, not the right-hand side)
Hi, I've been able to get a little more detail on an issue I've been seeing in Soss and Tilde. As usual, it's entirely possible the bug may be in one of my packages, but I hope this example might help narrow down the problem.
Say we have this in Tilde:
From that, Tilde produces this code:
In this code,
p
is declaredlocal
, then assigned, and then used in a closure. But it should be easy to guarantee thatp
does not change its type. We usually have this, which is why I have lines likep::Float64 = _pars.p
. I got this from the Julia docs, which sayAnyway, calling this expression
q
, we then callwhich yields
This ends up boxing
p
. But that's not needed - working with a modified GG I can just remove the lines that create the box, and it works great.The boxing leads to problems, because the assignment
p.contents::Float64 = _pars.p
is not valid.Do you see any changes I could make to my codegen to correct for this, or it does this require a change in GG?
The text was updated successfully, but these errors were encountered: