Skip to content

Commit 36c5256

Browse files
committed
Make jacobian work with CuArrays
1 parent 593aba6 commit 36c5256

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/back.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ Calculate the output jacobian `J = d/dx m(x)` such that each row `i` of `J` corr
173173
"""
174174
function jacobian(f, x::AbstractVector)
175175
y::AbstractVector, back = forward(f, x)
176-
(i) = [i == j for j = 1:length(y)]
176+
function (i)
177+
δ = fill!(similar(y, Bool), false)
178+
δ[i] = true
179+
return δ
180+
end
177181
vcat([transpose(back((i))[1]) for i = 1:length(y)]...)
178182
end
179183

0 commit comments

Comments
 (0)