Skip to content
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 = "Bijectors"
uuid = "76274a88-744f-5084-9051-94815aaf08c4"
version = "0.15.8"
version = "0.15.9"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down
9 changes: 5 additions & 4 deletions ext/BijectorsMooncakeExt.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module BijectorsMooncakeExt

using Mooncake:
@is_primitive, MinimalCtx, Mooncake, CoDual, primal, tangent_type, @from_rrule
@is_primitive, MinimalCtx, Mooncake, CoDual, primal, tangent_type, @from_chainrules
using Bijectors: find_alpha, ChainRulesCore

for P in [Float16, Float32, Float64]
@from_rrule(MinimalCtx, Tuple{typeof(find_alpha),P,P,P})
end
@from_chainrules(MinimalCtx, Tuple{typeof(find_alpha),Float16,Float16,Float16})
@from_chainrules(MinimalCtx, Tuple{typeof(find_alpha),Float32,Float32,Float32})
@from_chainrules(MinimalCtx, Tuple{typeof(find_alpha),Float64,Float64,Float64})

# The final argument could be an Integer of some kind. This should be fine provided that
# it has tangent type equal to `NoTangent`, which means that it's non-differentiable and
Expand All @@ -15,6 +15,7 @@ end
# unusual Integer type is encountered.
@is_primitive(MinimalCtx, Tuple{typeof(find_alpha),P,P,Integer} where {P<:Base.IEEEFloat})

# TODO: This needs a corresponding frule!! as well for it to work on forward-mode Mooncake.
function Mooncake.rrule!!(
::CoDual{typeof(find_alpha)}, x::CoDual{P}, y::CoDual{P}, z::CoDual{I}
) where {P<:Base.IEEEFloat,I<:Integer}
Expand Down
1 change: 0 additions & 1 deletion src/chainrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,3 @@ end

# Fixes AD issues with `@debug`
ChainRulesCore.@non_differentiable _debug(::Any)

2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ LazyArrays = "1, 2"
LogDensityProblems = "2"
LogExpFunctions = "0.3.1"
MCMCDiagnosticTools = "0.3"
Mooncake = "0.4"
Mooncake = "0.4.147"
ReverseDiff = "1.4.2"
StableRNGs = "1"
Tracker = "0.2.11"
Expand Down
63 changes: 33 additions & 30 deletions test/ad/chainrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,39 @@ end

if @isdefined Mooncake
rng = Xoshiro(123456)
Mooncake.TestUtils.test_rule(
rng,
Bijectors.find_alpha,
x,
y,
z;
is_primitive=true,
perf_flag=:none,
interp=Mooncake.MooncakeInterpreter(),
)
Mooncake.TestUtils.test_rule(
rng,
Bijectors.find_alpha,
x,
y,
3;
is_primitive=true,
perf_flag=:none,
interp=Mooncake.MooncakeInterpreter(),
)
Mooncake.TestUtils.test_rule(
rng,
Bijectors.find_alpha,
x,
y,
UInt32(3);
is_primitive=true,
perf_flag=:none,
interp=Mooncake.MooncakeInterpreter(),
)
# TODO: Enable Mooncake.ForwardMode as well.
@testset "$mode" for mode in (Mooncake.ReverseMode,)
Mooncake.TestUtils.test_rule(
rng,
Bijectors.find_alpha,
x,
y,
z;
is_primitive=true,
perf_flag=:none,
mode=mode,
)
Mooncake.TestUtils.test_rule(
rng,
Bijectors.find_alpha,
x,
y,
3;
is_primitive=true,
perf_flag=:none,
mode=mode,
)
Mooncake.TestUtils.test_rule(
rng,
Bijectors.find_alpha,
x,
y,
UInt32(3);
is_primitive=true,
perf_flag=:none,
mode=mode,
)
end
end

test_rrule(
Expand Down
4 changes: 3 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ end

if GROUP == "All" || GROUP == "AD"
include("ad/chainrules.jl")
include("ad/enzyme.jl")
if get(ENV, "AD", "All") in ("All", "Enzyme")
include("ad/enzyme.jl")
end
include("ad/flows.jl")
include("ad/pd.jl")
include("ad/corr.jl")
Expand Down
Loading