Skip to content

Commit f3afe13

Browse files
committed
work around length problem
1 parent dfd30d8 commit f3afe13

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/apiutils.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919
###################################
2020

2121
@generated function dualize(::Type{T}, x::StaticArray) where T
22-
N = length(x)
22+
N = _static_length(StaticArraysCore.Size(x))
2323
dx = Expr(:tuple, [:(Dual{T}(x[$i], chunk, Val{$i}())) for i in 1:N]...)
2424
V = StaticArraysCore.similar_type(x, Dual{T,eltype(x),N})
2525
return quote
@@ -29,6 +29,9 @@ end
2929
end
3030
end
3131

32+
# This works around length(::Type{StaticArray}) not being defined in this world-age:
33+
_static_length(::StaticArraysCore.Size{s}) where {s} = StaticArraysCore.tuple_prod(s)
34+
3235
@inline static_dual_eval(::Type{T}, f, x::StaticArray) where T = f(dualize(T, x))
3336

3437
function vector_mode_dual_eval!(f::F, cfg::Union{JacobianConfig,GradientConfig}, x) where {F}

0 commit comments

Comments
 (0)