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

Remove workaround for view with ReverseDiff #159

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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