Skip to content

Conversation

@devmotion
Copy link
Member

While working on TuringLang/Turing.jl#1242, I noticed that initially getlogp(vi) (where vi was initialized as VarInfo()) returned 0.0 but subsequently after calling resetlogp!(vi) it actually returned 0. The reason is two-fold: first, vi.logp is initialized as a reference to a Real number if not specified explicitly, and then resetlogp! is implemented as resetlogp!(vi) = (vi.logp[] = 0) which does not perform any conversion to floating point numbers in this case.

I changed both the initialization and resetlogp!. I assume there were reasons for not concretely type vi.logp as default (maybe because of AD?) - however, all tests of Turing passed locally with this PR.

@codecov
Copy link

codecov bot commented Apr 27, 2020

Codecov Report

Merging #86 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #86   +/-   ##
=======================================
  Coverage   76.92%   76.92%           
=======================================
  Files          13       13           
  Lines         845      845           
=======================================
  Hits          650      650           
  Misses        195      195           
Impacted Files Coverage Δ
src/varinfo.jl 83.90% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 26d90d7...39a0756. Read the comment docs.

Copy link
Contributor

@mohamed82008 mohamed82008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR stops UntypedVarInfo from being usable with AD. Currently, this is not an issue since we always convert to TypedVarInfo but UntypedVarInfo is the only VarInfo usable when when some new variable symbols get sampled in a stochastic control flow. I have no problem merging this now though.

@mohamed82008 mohamed82008 merged commit 1ad116f into master Apr 28, 2020
@delete-merged-branch delete-merged-branch bot deleted the logp branch April 28, 2020 02:17
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

Successfully merging this pull request may close these issues.

4 participants