Skip to content

Commit c7b8949

Browse files
authored
Dispatch on T <: ForwardDiff.Dual
Not doing so leads to this method also being used for non-Dual LArrays, which currently incurs (unnecessary) allocations.
1 parent 9e3fea0 commit c7b8949

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/LabelledArrays.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module LabelledArrays
22

33
using LinearAlgebra, StaticArrays, ArrayInterfaceCore
4-
import RecursiveArrayTools, PreallocationTools
4+
import RecursiveArrayTools, PreallocationTools, ForwardDiff
55

66
include("slarray.jl")
77
include("larray.jl")
@@ -65,7 +65,7 @@ end
6565
ArrayInterfaceCore.can_setindex(::Type{<:SLArray}) = false
6666

6767
function PreallocationTools.get_tmp(dc::PreallocationTools.DiffCache,
68-
u::LArray{T, N, D, Syms}) where {T, N, D, Syms}
68+
u::LArray{T, N, D, Syms}) where {T <: ForwardDiff.Dual, N, D, Syms}
6969
nelem = div(sizeof(T), sizeof(eltype(dc.dual_du))) * length(dc.du)
7070
if nelem > length(dc.dual_du)
7171
PreallocationTools.enlargedualcache!(dc, nelem)

0 commit comments

Comments
 (0)