Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prob macro - pre-allocation syntax #3

Closed
mohamed82008 opened this issue Dec 23, 2019 · 2 comments
Closed

prob macro - pre-allocation syntax #3

mohamed82008 opened this issue Dec 23, 2019 · 2 comments

Comments

@mohamed82008
Copy link
Member

@trappmartin brought up an issue in TuringLang/Turing.jl#997 about the syntax for pre-allocating varinfo. After the PR is merged, we can do:

using Turing

@model demo(y, ::Type{T} = Float64) where {T} = begin
    x = Vector{T}(undef, 10)
    x .~ Normal()
    y .~ Normal.(x, 1.0)
end
xval = rand(10)
varinfo = Turing.VarInfo(demo(xval))
logprob"y = rand(10) | model = demo, x = xval, varinfo = varinfo" 

Pre-allocating is useful if we need to change xval or y in a loop and re-evaluate. Pre-allocating varinfo can be useful in these cases. However, as @trappmartin indicated, the syntax seems to imply we are conditioning on varinfo which we are not. One solution proposed in the PR was to use ; instead of , before varinfo. Another one that I prefer is to not expose this in the macro at all, and only allow it in the functional API under the hood.

@mohamed82008 mohamed82008 changed the title New prob syntax pre-allocation syntax New prob macro - pre-allocation syntax Dec 23, 2019
@mohamed82008 mohamed82008 changed the title New prob macro - pre-allocation syntax prob macro - pre-allocation syntax Dec 23, 2019
@cpfiffer
Copy link
Member

Another one that I prefer is to not expose this in the macro at all, and only allow it in the functional API under the hood.

Yeah, I'd agree with that. The macro is really more for people who want to query their data quickly, while the API might be more for power users who want to root around in performance-land.

@mohamed82008 mohamed82008 transferred this issue from TuringLang/Turing.jl Dec 25, 2019
@yebai
Copy link
Member

yebai commented Dec 16, 2021

Closed in favour of #356

@yebai yebai closed this as completed Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants