-
Notifications
You must be signed in to change notification settings - Fork 37
Support for immutable AbstractVarInfo #269
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
9bee395 to
c3da562
Compare
src/varinfo.jl
Outdated
| """ | ||
| function settrans!(vi::AbstractVarInfo, trans::Bool, vn::VarName) | ||
| return trans ? set_flag!(vi, vn, "trans") : unset_flag!(vi, vn, "trans") | ||
| function settrans!(vi::AbstractVarInfo, trans::Bool, vn::Union{VarName,AbstractArray{<:VarName}}) |
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.
[JuliaFormatter] reported by reviewdog 🐶
Suggested change
| function settrans!(vi::AbstractVarInfo, trans::Bool, vn::Union{VarName,AbstractArray{<:VarName}}) | |
| function settrans!( | |
| vi::AbstractVarInfo, trans::Bool, vn::Union{VarName,AbstractArray{<:VarName}} | |
| ) |
src/varinfo.jl
Outdated
| foreach(vns) do vn | ||
| unset_flag!(vi, vn, flag) | ||
| end | ||
|
|
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.
[JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
Closed in facour of #309 |
bors bot
pushed a commit
that referenced
this pull request
Sep 8, 2021
This PR adds a `DynamicPPL.TestUtils` submodule which is meant to include functionality to make it easy to test new samplers, new implementations of `AbstractVarInfo`, etc. As of right now, this is mainly just a collection of models with equivalent marginal posteriors using the different features of DPPL, e.g. some are using `.~`, some are using `@submodel`, etc. Eventually this should be expanded to be of more use, but more immediately this will be useful to test functionality in open PRs, e.g. #269, #309, #295, #292. These models are also already used in Turing.jl's test-suite (https://github.com/TuringLang/Turing.jl/blob/9f52d75c25390b68115624b2e6cf464275a88137/test/test_utils/models.jl#L55-L56), so this PR would avoid the code-duplication + make it easier to keep things up-to-date.
bors bot
pushed a commit
that referenced
this pull request
Sep 9, 2021
This PR adds a `DynamicPPL.TestUtils` submodule which is meant to include functionality to make it easy to test new samplers, new implementations of `AbstractVarInfo`, etc. As of right now, this is mainly just a collection of models with equivalent marginal posteriors using the different features of DPPL, e.g. some are using `.~`, some are using `@submodel`, etc. Eventually this should be expanded to be of more use, but more immediately this will be useful to test functionality in open PRs, e.g. #269, #309, #295, #292. These models are also already used in Turing.jl's test-suite (https://github.com/TuringLang/Turing.jl/blob/9f52d75c25390b68115624b2e6cf464275a88137/test/test_utils/models.jl#L55-L56), so this PR would avoid the code-duplication + make it easier to keep things up-to-date.
bors bot
pushed a commit
that referenced
this pull request
Sep 9, 2021
This PR adds a `DynamicPPL.TestUtils` submodule which is meant to include functionality to make it easy to test new samplers, new implementations of `AbstractVarInfo`, etc. As of right now, this is mainly just a collection of models with equivalent marginal posteriors using the different features of DPPL, e.g. some are using `.~`, some are using `@submodel`, etc. Eventually this should be expanded to be of more use, but more immediately this will be useful to test functionality in open PRs, e.g. #269, #309, #295, #292. These models are also already used in Turing.jl's test-suite (https://github.com/TuringLang/Turing.jl/blob/9f52d75c25390b68115624b2e6cf464275a88137/test/test_utils/models.jl#L55-L56), so this PR would avoid the code-duplication + make it easier to keep things up-to-date.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR moves most of the mutating methods to the bang-bang convention + some changes to the compiler to allow the usage of immutable implementations of
AbstractVarInfo.The major change in the compiler is that we replace all return-statements with
return (retval, __varinfo__), ensuring that we preserve support for features such as submodels.Note that the
(m::Model)(...)evaluator still only returns the original return-value, and thus from a user-perspective, nothing has changed. But methods such as_evaluate(m::Model, ...)now return a tuple withAbstractVarInfoas the second argument.Most of the methods we can gracefully depreciate, with the only breaking change being
x = @submodel m(...)no longer works since we need to handle the additional return-value, hence this has changed to@submodel x = m(...).The original motivation of the work in this PR is to make something like #267 feasible.