|
1 | 1 | using SparseDiffTools, CUDA, Test, LinearAlgebra |
2 | 2 | using ArrayInterface: allowed_getindex, allowed_setindex! |
| 3 | +using SparseArrays |
| 4 | + |
3 | 5 | function f(dx,x) |
4 | 6 | dx[2:end-1] = x[1:end-2] - 2x[2:end-1] + x[3:end] |
5 | 7 | allowed_setindex!(dx,-2allowed_getindex(x,1) + allowed_getindex(x,2),1) |
6 | 8 | allowed_setindex!(dx,-2allowed_getindex(x,30) + allowed_getindex(x,29),30) |
7 | 9 | nothing |
8 | 10 | end |
9 | | - |
| 11 | +x = rand(4) |
10 | 12 | _J1 = similar(rand(30,30)) |
11 | 13 | _denseJ1 = cu(collect(_J1)) |
12 | 14 | x = cu(rand(30)) |
13 | 15 | CUDA.allowscalar(false) |
14 | | -forwarddiff_color_jacobian!(_denseJ1, f, x) |
15 | | -@test_broken forwarddiff_color_jacobian!(_denseJ1, f, x, sparsity = _J1) isa Nothing |
16 | | -@test_broken forwarddiff_color_jacobian!(_denseJ1, f, x, colorvec = repeat(1:3,10), sparsity = _J1) isa Nothing |
| 16 | +_J2 = sparse(forwarddiff_color_jacobian!(_denseJ1, f, x)) |
| 17 | +out = copy(_J2) |
| 18 | +forwarddiff_color_jacobian!(out, f, x, colorvec = repeat(1:3,10), sparsity = _J2) |
| 19 | + |
| 20 | +@test_broken forwarddiff_color_jacobian!(_denseJ1, f, x, sparsity = cu(_J1)) isa Nothing |
| 21 | +@test_broken forwarddiff_color_jacobian!(_denseJ1, f, x, colorvec = repeat(1:3,10), sparsity = cu(_J1)) isa Nothing |
17 | 22 | _Jt = similar(Tridiagonal(_J1)) |
18 | 23 | @test_broken forwarddiff_color_jacobian!(_denseJ1, f, x, colorvec = repeat(1:3,10), sparsity = _Jt) isa Nothing |
| 24 | +_Jt2 = similar(Tridiagonal(cu(_J1))) |
| 25 | +@test_broken forwarddiff_color_jacobian!(_denseJ1, f, x, colorvec = repeat(1:3,10), sparsity = _Jt2) isa Nothing |
0 commit comments