@@ -619,14 +619,28 @@ using Turing
619
619
@assert get (result, :c ) == (; :c => Array{Float64}[])
620
620
end
621
621
622
- @testset " ADType" for adbackend in ADUtils. adbackends
622
+ @testset " ADType test with $adbackend " for adbackend in ADUtils. adbackends
623
623
Random. seed! (222 )
624
624
m = DynamicPPL. contextualize (
625
625
gdemo_default, ADUtils. ADTypeCheckContext (adbackend, gdemo_default. context)
626
626
)
627
- # These will error if the adbackend being used is not the one set.
628
- maximum_likelihood (m; adtype= adbackend)
629
- maximum_a_posteriori (m; adtype= adbackend)
627
+ if adbackend isa AutoMooncake
628
+ # Optimization.jl does not support Mooncake as an AD backend, see
629
+ # https://docs.sciml.ai/Optimization/stable/API/ad/#ad
630
+ # If it ever does, then we should just run them to make sure they don't error
631
+ err_msg = " The passed automatic differentiation backend choice is not available"
632
+ @test_throws err_msg maximum_likelihood (m; adtype= adbackend)
633
+ @test_throws err_msg maximum_a_posteriori (m; adtype= adbackend)
634
+ elseif adbackend isa AutoForwardDiff
635
+ # TODO : Figure out why this is happening.
636
+ # https://github.com/TuringLang/Turing.jl/issues/2369
637
+ @test_throws DivideError maximum_likelihood (m; adtype= adbackend)
638
+ @test_throws DivideError maximum_a_posteriori (m; adtype= adbackend)
639
+ else
640
+ # These will error if the adbackend being used is not the one set.
641
+ maximum_likelihood (m; adtype= adbackend)
642
+ maximum_a_posteriori (m; adtype= adbackend)
643
+ end
630
644
end
631
645
end
632
646
0 commit comments