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

Commit 11e8b64

Browse files
Merge pull request #47 from SciML/adtypes1
MTK sparse no sparse hv cache
2 parents e5ae416 + 049bab7 commit 11e8b64

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ext/OptimizationMTKExt.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ function OptimizationBase.instantiate_function(
3434
hess = (H, θ, args...) -> f.hess(H, θ, p, args...)
3535

3636
hv = function (H, θ, v, args...)
37-
res = adtype.obj_sparse ? (eltype(θ)).(f.hess_prototype) :
38-
ArrayInterface.zeromatrix(θ)
37+
res = (eltype(θ)).(f.hess_prototype)
3938
hess(res, θ, args...)
4039
H .= res * v
4140
end
@@ -81,8 +80,7 @@ function OptimizationBase.instantiate_function(f, cache::OptimizationBase.ReInit
8180
hess = (H, θ, args...) -> f.hess(H, θ, cache.p, args...)
8281

8382
hv = function (H, θ, v, args...)
84-
res = adtype.obj_sparse ? (eltype(θ)).(f.hess_prototype) :
85-
ArrayInterface.zeromatrix(θ)
83+
res = (eltype(θ)).(f.hess_prototype)
8684
hess(res, θ, args...)
8785
H .= res * v
8886
end
@@ -127,8 +125,7 @@ function OptimizationBase.instantiate_function(f, x, adtype::AutoSymbolics, p,
127125
hess = (H, θ, args...) -> f.hess(H, θ, p, args...)
128126

129127
hv = function (H, θ, v, args...)
130-
res = adtype.obj_sparse ? (eltype(θ)).(f.hess_prototype) :
131-
ArrayInterface.zeromatrix(θ)
128+
res = ArrayInterface.zeromatrix(θ)
132129
hess(res, θ, args...)
133130
H .= res * v
134131
end
@@ -174,8 +171,7 @@ function OptimizationBase.instantiate_function(f, cache::OptimizationBase.ReInit
174171
hess = (H, θ, args...) -> f.hess(H, θ, cache.p, args...)
175172

176173
hv = function (H, θ, v, args...)
177-
res = adtype.obj_sparse ? (eltype(θ)).(f.hess_prototype) :
178-
ArrayInterface.zeromatrix(θ)
174+
res = ArrayInterface.zeromatrix(θ)
179175
hess(res, θ, args...)
180176
H .= res * v
181177
end

0 commit comments

Comments
 (0)