Skip to content

Commit

Permalink
Don't remove detector
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle committed May 27, 2024
1 parent ea57c36 commit 224df63
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ myvec(x::AbstractArray) = vec(x)

include("onearg.jl")
include("twoarg.jl")
include("detector.jl")

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function ADTypes.jacobian_sparsity(f, x, ::DI.SymbolicsSparsityDetector)
y = similar(f(x))
f!(y, x) = copyto!(y, f(x))
return jacobian_sparsity(f!, y, x)
end

function ADTypes.jacobian_sparsity(f!, y, x, ::DI.SymbolicsSparsityDetector)
f!_vec(y_vec, x_vec) = f!(reshape(y_vec, size(y)), reshape(x_vec, size(x)))
return jacobian_sparsity(f!_vec, vec(y), vec(x))
end

function ADTypes.hessian_sparsity(f, x, ::DI.SymbolicsSparsityDetector)
f_vec(x_vec) = f(reshape(x_vec, size(x)))
return hessian_sparsity(f_vec, vec(x))
end

0 comments on commit 224df63

Please sign in to comment.