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

Special-case ReshapeTransform for singleton inputs #699

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

penelopeysm
Copy link
Member

@penelopeysm penelopeysm commented Oct 25, 2024

Closes #698.

I can confirm that this change fixes the two Turing tests that I listed here TuringLang/Turing.jl#2376 (comment). It might well fix all the other tests too, since they are giving the same error message.

using Turing
import ReverseDiff

alg = HMC(0.01, 5; adtype=AutoReverseDiff())

@model function vdemo6()
    x = Vector{Real}(undef, 10)
    @. x ~ InverseGamma(2, 3)
end
sample(vdemo6(), alg, 10)

@model function vdemo7()
    x = Array{Real}(undef, N, N)
    @. x ~ [InverseGamma(2, 3) for i in 1:N]
end
sample(vdemo7(), alg, 1000)

Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.23%. Comparing base (bd9f465) to head (8c9cc71).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #699   +/-   ##
=======================================
  Coverage   79.22%   79.23%           
=======================================
  Files          30       30           
  Lines        4212     4214    +2     
=======================================
+ Hits         3337     3339    +2     
  Misses        875      875           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11510571276

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 93 unchanged lines in 18 files lost coverage.
  • Overall coverage decreased (-1.5%) to 78.11%

Files with Coverage Reduction New Missed Lines %
src/model.jl 1 93.68%
src/sampler.jl 1 92.73%
ext/DynamicPPLEnzymeCoreExt.jl 1 0.0%
src/contexts.jl 3 75.76%
src/context_implementations.jl 3 63.67%
src/test_utils.jl 3 85.31%
src/model_utils.jl 3 19.64%
src/varnamedvector.jl 3 89.42%
src/distribution_wrappers.jl 4 44.12%
ext/DynamicPPLForwardDiffExt.jl 4 66.67%
Totals Coverage Status
Change from base Build 11501458234: -1.5%
Covered Lines: 3290
Relevant Lines: 4212

💛 - Coveralls

@coveralls
Copy link

coveralls commented Oct 25, 2024

Pull Request Test Coverage Report for Build 11516553436

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 93 unchanged lines in 18 files lost coverage.
  • Overall coverage increased (+0.01%) to 79.633%

Files with Coverage Reduction New Missed Lines %
src/model.jl 1 93.68%
src/sampler.jl 1 92.73%
ext/DynamicPPLEnzymeCoreExt.jl 1 0.0%
src/contexts.jl 3 75.76%
src/context_implementations.jl 3 63.67%
src/test_utils.jl 3 85.31%
src/model_utils.jl 3 19.64%
src/varnamedvector.jl 3 89.42%
src/distribution_wrappers.jl 4 44.12%
ext/DynamicPPLForwardDiffExt.jl 4 66.67%
Totals Coverage Status
Change from base Build 11501458234: 0.01%
Covered Lines: 3339
Relevant Lines: 4193

💛 - Coveralls

Copy link
Member

@mhauru mhauru left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this!

src/utils.jl Outdated Show resolved Hide resolved
@penelopeysm penelopeysm added this pull request to the merge queue Oct 25, 2024
Merged via the queue into master with commit 18af48a Oct 25, 2024
14 checks passed
@penelopeysm penelopeysm deleted the py/reshape-transform-singletons branch October 25, 2024 12:58
@torfjelde
Copy link
Member

Great stuff @penelopeysm :)

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.

ReverseDiff doesn't like DynamicPPL.ReshapeTransform
4 participants