|
| 1 | +using AbstractDifferentiation, Diffractor, Test, LinearAlgebra |
| 2 | +import AbstractDifferentiation as AD |
| 3 | +backend = Diffractor.DiffractorForwardBackend() |
| 4 | + |
| 5 | +@testset "basics" begin |
| 6 | + @test AD.derivative(backend, +, 1.5, 10.0) == (1.0, 1.0) |
| 7 | + @test AD.derivative(backend, *, 1.5, 10.0) == (10.0, 1.5) |
| 8 | + @test only(AD.jacobian(backend, prod, [1.5, 2.5, 10.0])) == [25.0 15.0 3.75] |
| 9 | + @test only(AD.jacobian(backend, identity, [1.5, 2.5, 10.0])) == Matrix(I, 3, 3) |
| 10 | +end |
| 11 | + |
| 12 | +# standard tests from AbstractDifferentiation.test_utils |
| 13 | +include(joinpath(pathof(AbstractDifferentiation), "..", "..", "test", "test_utils.jl")) |
| 14 | +@testset "ForwardDiffBackend" begin |
| 15 | + backends = [ |
| 16 | + @inferred(Diffractor.DiffractorForwardBackend()) |
| 17 | + ] |
| 18 | + @testset for backend in backends |
| 19 | + @test backend isa AD.AbstractForwardMode |
| 20 | + |
| 21 | + @testset "Derivative" begin #setfield!(::Core.Box, ::Symbol, ::Float64) |
| 22 | + @test_broken test_derivatives(backend) |
| 23 | + end |
| 24 | + @testset "Gradient" begin #Diffractor.TangentBundle{1, Float64, Diffractor.TaylorTangent{Tuple{Float64}}}(::Float64, ::Tuple{Float64}) |
| 25 | + @test_broken test_gradients(backend) |
| 26 | + end |
| 27 | + @testset "Jacobian" begin #setfield!(::Core.Box, ::Symbol, ::Vector{Float64}) |
| 28 | + @test_broken test_jacobians(backend) |
| 29 | + end |
| 30 | + @testset "Hessian" begin #setindex!(::ChainRulesCore.ZeroTangent, ::Float64, ::Int64) |
| 31 | + @test_broken test_hessians(backend) |
| 32 | + end |
| 33 | + @testset "jvp" begin #setfield!(::Core.Box, ::Symbol, ::Vector{Float64}) |
| 34 | + @test_broken test_jvp(backend; vaugmented=true) |
| 35 | + end |
| 36 | + @testset "j′vp" begin #setfield!(::Core.Box, ::Symbol, ::Vector{Float64}) |
| 37 | + @test_broken test_j′vp(backend) |
| 38 | + end |
| 39 | + @testset "Lazy Derivative" begin |
| 40 | + test_lazy_derivatives(backend) |
| 41 | + end |
| 42 | + @testset "Lazy Gradient" begin #Diffractor.TangentBundle{1, Float64, Diffractor.TaylorTangent{Tuple{Float64}}}(::Float64, ::Tuple{Float64}) |
| 43 | + @test_broken test_lazy_gradients(backend) |
| 44 | + end |
| 45 | + @testset "Lazy Jacobian" begin #MethodError: no method matching *(::Diffractor.PrimeDerivativeBack{1, Diagonal{Bool, Vector{Bool}}}, ::Vector{Float64}) |
| 46 | + @test_broken test_lazy_jacobians(backend; vaugmented=true) |
| 47 | + end |
| 48 | + @testset "Lazy Hessian" begin # everything everywhere all at once is broken |
| 49 | + @test_broken test_lazy_hessians(backend) |
| 50 | + end |
| 51 | + end |
| 52 | +end |
0 commit comments