Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit 5b0e1e1

Browse files
YingboMachriselrod
andcommitted
Fix allocation in auto_jacvec!
Before: ```julia julia> @Btime auto_jacvec!($dy, $f, $x, $v, $cache1, $cache2); 99.454 μs (1200 allocations: 32.81 KiB) ``` After: ```julia julia> @Btime auto_jacvec!($dy, $f, $x, $v, $cache1, $cache2); 44.668 μs (0 allocations: 0 bytes) ``` Co-authored-by: Chris Elrod <[email protected]>
1 parent 66a0303 commit 5b0e1e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/differentiation/jaches_products.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function auto_jacvec!(
99
cache1 = Dual{typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(Tuple.(reshape(v, size(x))))),
1010
cache2 = similar(cache1),
1111
)
12-
cache1 .= Dual{typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(Tuple.(reshape(v, size(x)))))
12+
cache1 .= Dual{typeof(ForwardDiff.Tag(DeivVecTag(),eltype(x))),eltype(x),1}.(x, ForwardDiff.Partials.(tuple.(reshape(v, size(x)))))
1313
f(cache2, cache1)
1414
vecdy = _vec(dy)
1515
vecdy .= partials.(_vec(cache2), 1)

0 commit comments

Comments
 (0)