Skip to content

Commit

Permalink
Remove workaround for view with ReverseDiff (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion authored Mar 31, 2021
1 parent 6f7ee35 commit f074b8d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DistributionsAD"
uuid = "ced4e74d-a319-5a8a-b0ac-84af2272839c"
version = "0.6.20"
version = "0.6.21"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
17 changes: 0 additions & 17 deletions src/reversediff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,6 @@ include("reversediffx.jl")

adapt_randn(rng::Random.AbstractRNG, x::TrackedArray, dims...) = adapt_randn(rng, value(x), dims...)

# without this definition tests of `VectorOfMultivariate` with `Dirichlet` fail
# upstream bug caused by `view` + `track`: https://github.com/JuliaDiff/ReverseDiff.jl/pull/164
function _logpdf(dist::VectorOfMultivariate, x::AbstractMatrix{<:TrackedReal})
return sum(i -> _logpdf(dist.dists[i], x[:, i]), axes(x, 2))
end

# fix method ambiguity
function _logpdf(dist::FillVectorOfMultivariate, x::AbstractMatrix{<:TrackedReal})
return loglikelihood(dist.dists.value, x)
end

function PoissonBinomial(p::TrackedArray{<:Real}; check_args=true)
return TuringPoissonBinomial(p; check_args = check_args)
end
Expand Down Expand Up @@ -269,12 +258,6 @@ function loglikelihood(d::Dirichlet, x::AbstractMatrix{<:TrackedReal})
return loglikelihood(TuringDirichlet(d), x)
end

# default definition of `loglikelihood` yields gradients of zero?!
# upstream bug caused by `view` + `track`: https://github.com/JuliaDiff/ReverseDiff.jl/pull/164
function loglikelihood(d::TuringDirichlet, x::AbstractMatrix{<:TrackedReal})
return sum(i -> logpdf(d, x[:, i]), axes(x, 2))
end

for func_header in [
:(simplex_logpdf(alpha::AbstractVector{<:TrackedReal}, lmnB::Real, x::AbstractVector)),
:(simplex_logpdf(alpha::AbstractVector, lmnB::TrackedReal, x::AbstractVector)),
Expand Down

2 comments on commit f074b8d

@devmotion
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/33216

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.21 -m "<description of version>" f074b8da7d7f2c1a6a0c0f98350e31e81cf9004e
git push origin v0.6.21

Please sign in to comment.