|
25 | 25 | xs, y = randn(2,3), rand() |
26 | 26 | f34(xs, y) = xs[1] * (sum(xs .^ (1:3)') + y^4) # non-diagonal Hessian, two arguments |
27 | 27 |
|
28 | | - # Following should work once we workout what ForwardDiff should do when `Float64` is called on a `Dual` |
29 | | - # https://github.com/JuliaDiff/ForwardDiff.jl/pull/538 |
30 | | - # else might need a custom overload of `(;;ChainRulesCore.ProjectTo)(::Dual)` |
31 | | - # When fixed uncomment the below and delete the broken function |
32 | | - #== |
33 | 28 | dx, dy = diaghessian(f34, xs, y) |
34 | 29 | @test size(dx) == size(xs) |
35 | 30 | @test vec(dx) ≈ diag(hessian(x -> f34(x,y), xs)) |
36 | 31 | @test dy ≈ hessian(y -> f34(xs,y), y) |
37 | | - ==# |
38 | | - function broken() |
39 | | - dx, dy = diaghessian(f34, xs, y) # This fails becase ProjectTo can't project a Dual onto a Float |
40 | | - c1 = size(dx) == size(xs) |
41 | | - c2 = vec(dx) ≈ diag(hessian(x -> f34(x,y), xs)) |
42 | | - c3 = dy ≈ hessian(y -> f34(xs,y), y) |
43 | | - return all([c1, c2, c3]) |
44 | | - end |
45 | | - @test_broken broken() |
46 | 32 |
|
47 | 33 | zs = randn(7,13) # test chunk mode |
48 | 34 | @test length(zs) > ForwardDiff.DEFAULT_CHUNK_THRESHOLD |
|
0 commit comments