Skip to content

Commit 2849804

Browse files
author
KristofferC
committed
make Gradient/Jacobian/Hessian-Config mutable
these often get quite large and the fact that they are non-mutable means Julia copies them which is quite expensive
1 parent e8eb009 commit 2849804

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/config.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ Base.eltype(::Type{DerivativeConfig{T,D}}) where {T,D} = eltype(D)
9494
# GradientConfig #
9595
##################
9696

97-
struct GradientConfig{T,V,N,D} <: AbstractConfig{N}
98-
seeds::NTuple{N,Partials{N,V}}
99-
duals::D
97+
mutable struct GradientConfig{T,V,N,D} <: AbstractConfig{N}
98+
const seeds::NTuple{N,Partials{N,V}}
99+
const duals::D
100100
end
101101

102102
"""
@@ -130,9 +130,9 @@ Base.eltype(::Type{GradientConfig{T,V,N,D}}) where {T,V,N,D} = Dual{T,V,N}
130130
# JacobianConfig #
131131
##################
132132

133-
struct JacobianConfig{T,V,N,D} <: AbstractConfig{N}
134-
seeds::NTuple{N,Partials{N,V}}
135-
duals::D
133+
mutable struct JacobianConfig{T,V,N,D} <: AbstractConfig{N}
134+
const seeds::NTuple{N,Partials{N,V}}
135+
const duals::D
136136
end
137137

138138
"""
@@ -195,9 +195,9 @@ Base.eltype(::Type{JacobianConfig{T,V,N,D}}) where {T,V,N,D} = Dual{T,V,N}
195195
# HessianConfig #
196196
#################
197197

198-
struct HessianConfig{T,V,N,DG,DJ} <: AbstractConfig{N}
199-
jacobian_config::JacobianConfig{T,V,N,DJ}
200-
gradient_config::GradientConfig{T,Dual{T,V,N},N,DG}
198+
mutable struct HessianConfig{T,V,N,DG,DJ} <: AbstractConfig{N}
199+
const jacobian_config::JacobianConfig{T,V,N,DJ}
200+
const gradient_config::GradientConfig{T,Dual{T,V,N},N,DG}
201201
end
202202

203203
"""

0 commit comments

Comments
 (0)