Skip to content

Commit e86b7d4

Browse files
Merge pull request #157 from mateuszbaran/mbaran/better-auto_jacvec
Modify `auto_jacvec` for compatibility with Zygote
2 parents b324c2c + 3f9ba40 commit e86b7d4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/differentiation/jaches_products.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ function auto_jacvec!(dy, f, x, v,
99
dy .= partials.(cache2, 1)
1010
end
1111
function auto_jacvec(f, x, v)
12-
partials.(f(Dual{DeivVecTag}.(x, v)), 1)
12+
fval = f(map((xi, vi) -> Dual{typeof(ForwardDiff.Tag(f,eltype(x)))}(xi, vi), x, v))
13+
map(u -> partials(u)[1], fval)
1314
end
1415

1516
function num_jacvec!(dy,f,x,v,cache1 = similar(v),

0 commit comments

Comments
 (0)