-
Notifications
You must be signed in to change notification settings - Fork 37
Fix compiler output for sub-variables of immutable data #1177
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
Conversation
Benchmark Report
Computer InformationBenchmark Results |
50f1943 to
870faab
Compare
|
DynamicPPL.jl documentation for PR #1177 is available at: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1177 +/- ##
==========================================
+ Coverage 78.95% 78.96% +0.01%
==========================================
Files 41 41
Lines 3896 3899 +3
==========================================
+ Hits 3076 3079 +3
Misses 820 820 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mhauru
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One detail I was wondering about, but we can discuss that post-merge next year. Happy to merge.
| $vn, | ||
| __varinfo__, | ||
| ) | ||
| $(assign_or_set!!(left, value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might the fact that left is now assigned to the value that's gone through tilde_observe!! cause any changes? Maybe something about copies or allocations? I'm guessing not, just thinking out loud.
Closes #1176. The result of this PR on the model macro
is shown in the following diff. Essentially the result is to avoid setting to
data.xdirectly:quote function test(__model__::Model, __varinfo__::AbstractVarInfo, data::Any; ) #= REPL[4]:1 =# begin var"##dist#246" = Normal() var"##vn#243" = (DynamicPPL.resolve_varnames)((VarName){:data}((Accessors.opticcompose)((Accessors.PropertyLens){:x}())), var"##dist#246") var"##isassumption#244" = begin if (DynamicPPL.contextual_isassumption)(__model__.context, (prefix)(__model__.context, var"##vn#243")) if !((DynamicPPL.inargnames)(var"##vn#243", __model__)) || (DynamicPPL.inmissings)(var"##vn#243", __model__) true else data.x === missing end else false end end begin #= /Users/pyong/ppl/dppl/src/compiler.jl:599 =# var"##retval#248" = if (DynamicPPL.contextual_isfixed)(__model__.context, (prefix)(__model__.context, var"##vn#243")) - data.x = (DynamicPPL.getfixed_nested)(__model__.context, (prefix)(__model__.context, var"##vn#243")) + data = (Accessors.set)(data, (BangBang.AccessorsImpl.prefermutation)((Accessors.opticcompose)((Accessors.PropertyLens){:x}())), (DynamicPPL.getfixed_nested)(__model__.context, (prefix)(__model__.context, var"##vn#243"))) elseif var"##isassumption#244" begin (var"##value#247", __varinfo__) = (tilde_assume!!)(__model__.context, (DynamicPPL.unwrap_right_vn)((DynamicPPL.check_tilde_rhs)(var"##dist#246"), var"##vn#243")..., __varinfo__) data = (Accessors.set)(data, (BangBang.AccessorsImpl.prefermutation)((Accessors.opticcompose)((Accessors.PropertyLens){:x}())), var"##value#247") var"##value#247" end else - data.x = if (DynamicPPL.inargnames)(var"##vn#243", __model__) + var"##supplied_val#236" = if (DynamicPPL.inargnames)(var"##vn#243", __model__) data.x else (DynamicPPL.getconditioned_nested)(__model__.context, (prefix)(__model__.context, var"##vn#243")) end - (var"##value#245", __varinfo__) = (tilde_observe!!)(__model__.context, (DynamicPPL.check_tilde_rhs)(var"##dist#246"), data.x, var"##vn#243", __varinfo__) + (var"##value#245", __varinfo__) = (tilde_observe!!)(__model__.context, (DynamicPPL.check_tilde_rhs)(var"##dist#246"), var"##supplied_val#236", var"##vn#243", __varinfo__) + data = (Accessors.set)(data, (BangBang.AccessorsImpl.prefermutation)((Accessors.opticcompose)((Accessors.PropertyLens){:x}())), var"##value#245") var"##value#245" end #= /Users/pyong/ppl/dppl/src/compiler.jl:600 =# return (var"##retval#248", __varinfo__) end end end begin $(Expr(:meta, :doc)) function test(data::Any; ) #= REPL[4]:1 =# return (Model){false}(test, NamedTuple{(:data,)}((data,)); ) end end end