Skip to content

Commit

Permalink
remove tapir extension
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxd3 committed Aug 23, 2024
1 parent 8c19984 commit 0e53f1a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 42 deletions.
4 changes: 0 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Tapir = "07d77754-e150-4737-8c94-cd238a1fb45b"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"

Expand All @@ -31,7 +30,6 @@ EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
MCMCChains = "c7f686f2-ff18-58e9-bc7b-31028e88f75d"
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
Tapir = "07d77754-e150-4737-8c94-cd238a1fb45b"
ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"

[extensions]
Expand All @@ -40,7 +38,6 @@ DynamicPPLEnzymeCoreExt = ["EnzymeCore"]
DynamicPPLForwardDiffExt = ["ForwardDiff"]
DynamicPPLMCMCChainsExt = ["MCMCChains"]
DynamicPPLReverseDiffExt = ["ReverseDiff"]
DynamicPPLTapirExt = ["Tapir"]
DynamicPPLZygoteRulesExt = ["ZygoteRules"]

[compat]
Expand All @@ -67,7 +64,6 @@ Random = "1.6"
Requires = "1"
ReverseDiff = "1"
Test = "1.6"
Tapir = "0.2.40"
ZygoteRules = "0.2"
julia = "1.6"

Expand Down
35 changes: 0 additions & 35 deletions ext/DynamicPPLTapirExt.jl

This file was deleted.

3 changes: 0 additions & 3 deletions src/DynamicPPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,6 @@ end
@require ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267" include(
"../ext/DynamicPPLReverseDiffExt.jl"
)
@require Tapir = "07d77754-e150-4737-8c94-cd238a1fb45b" include(
"../ext/DynamicPPLTapirExt.jl"
)
@require ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444" include(
"../ext/DynamicPPLZygoteRulesExt.jl"
)
Expand Down
25 changes: 25 additions & 0 deletions src/logdensityfunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,31 @@ function setmodel(f::DynamicPPL.LogDensityFunction, model::DynamicPPL.Model)
return Accessors.@set f.model = model
end

# TODO: special case for Tapir, should move to a package extension once Julia compat is updated
function DynamicPPL.setmodel(
f::LogDensityProblemsAD.ADGradientWrapper,
model::DynamicPPL.Model,
adtype::ADTypes.AutoTapir,
)
if !hasfield(typeof(f), :rule)
@warn "ADGradientWrapper does not have a `rule` field. Please check Tapir version. It is also possible that `adtype` mismatch `ADGradientWrapper` type."
@warn "Using default rule."
return LogDensityProblemsAD.ADgradient(
Val(:Tapir),
DynamicPPL.setmodel(LogDensityProblemsAD.parent(f), model);
safety_on=adtype.safe_mode,
rule=nothing,
)
else
return LogDensityProblemsAD.ADgradient(
Val(:Tapir),
DynamicPPL.setmodel(LogDensityProblemsAD.parent(f), model);
safety_on=adtype.safe_mode,
rule=f.rule,
)
end
end

# HACK: heavy usage of `AbstractSampler` for, well, _everything_, is being phased out. In the mean time
# we need to define these annoying methods to ensure that we stay compatible with everything.
getsampler(f::LogDensityFunction) = getsampler(getcontext(f))
Expand Down

0 comments on commit 0e53f1a

Please sign in to comment.