Skip to content

Commit dca97ac

Browse files
sshin23claude
andcommitted
Fix KA extension structure functions to extend ExaModels methods
The KA extension's _jac_structure!, _obj_hess_structure!, and _con_hess_structure! were local functions, not methods on ExaModels. BatchExaModel.jac_structure! now calls ExaModels._jac_structure! with getbackend(m), so the extension must add methods to ExaModels' functions for GPU dispatch to work. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bede0d2 commit dca97ac

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

ext/ExaModelsKernelAbstractions.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ function ExaModels.jac_structure!(
143143
cols::V,
144144
) where {T,VT,E<:KAExtension,V<:AbstractVector}
145145
if !isempty(rows)
146-
_jac_structure!(T, m.ext.backend, m.cons, rows, cols)
146+
ExaModels._jac_structure!(T, m.ext.backend, m.cons, rows, cols)
147147
end
148148
return rows, cols
149149
end
150-
_jac_structure!(T, backend, ::Tuple{}, rows, cols) = nothing
151-
function _jac_structure!(T, backend, (con, cons...), rows, cols)
152-
_jac_structure!(T, backend, cons, rows, cols)
150+
ExaModels._jac_structure!(T, backend, ::Tuple{}, rows, cols) = nothing
151+
function ExaModels._jac_structure!(T, backend, (con, cons...), rows, cols)
152+
ExaModels._jac_structure!(T, backend, cons, rows, cols)
153153
ExaModels.sjacobian!(backend, rows, cols, con, ExaModels.NaNSource{T}(), ExaModels.NaNSource{T}(), T(NaN))
154154
end
155155

@@ -160,20 +160,20 @@ function ExaModels.hess_structure!(
160160
cols::V,
161161
) where {T,VT,E<:KAExtension,V<:AbstractVector}
162162
if !isempty(rows)
163-
_obj_hess_structure!(T, m.ext.backend, m.objs, rows, cols)
164-
_con_hess_structure!(T, m.ext.backend, m.cons, rows, cols)
165-
end
163+
ExaModels._obj_hess_structure!(T, m.ext.backend, m.objs, rows, cols)
164+
ExaModels._con_hess_structure!(T, m.ext.backend, m.cons, rows, cols)
165+
end
166166
return rows, cols
167167
end
168168

169-
_obj_hess_structure!(T, backend, ::Tuple{}, rows, cols) = nothing
170-
function _obj_hess_structure!(T, backend, (obj, objs...), rows, cols)
171-
_obj_hess_structure!(T, backend, objs, rows, cols)
169+
ExaModels._obj_hess_structure!(T, backend, ::Tuple{}, rows, cols) = nothing
170+
function ExaModels._obj_hess_structure!(T, backend, (obj, objs...), rows, cols)
171+
ExaModels._obj_hess_structure!(T, backend, objs, rows, cols)
172172
ExaModels.shessian!(backend, rows, cols, obj, ExaModels.NaNSource{T}(), ExaModels.NaNSource{T}(), T(NaN), T(NaN))
173173
end
174-
_con_hess_structure!(T, backend, ::Tuple{}, rows, cols) = nothing
175-
function _con_hess_structure!(T, backend, (con, cons...), rows, cols)
176-
_con_hess_structure!(T, backend, cons, rows, cols)
174+
ExaModels._con_hess_structure!(T, backend, ::Tuple{}, rows, cols) = nothing
175+
function ExaModels._con_hess_structure!(T, backend, (con, cons...), rows, cols)
176+
ExaModels._con_hess_structure!(T, backend, cons, rows, cols)
177177
ExaModels.shessian!(backend, rows, cols, con, ExaModels.NaNSource{T}(), ExaModels.NaNSource{T}(), T(NaN), T(NaN))
178178
end
179179

0 commit comments

Comments
 (0)