Skip to content

Commit cafa9e1

Browse files
sshin23claude
andcommitted
Fix append! for matrix bounds in batch models
Split append! into AbstractVector and AbstractMatrix methods. Matrix bounds (e.g., lvar = zeros(10,4) for a 4-instance batch) are now cat'd directly along dim 1 instead of being vec'd to a flat vector and then incorrectly expanded, which produced (40,4) instead of (10,4). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f13f998 commit cafa9e1

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/nlp.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,15 @@ function append!(backend, a, b::Number, lb)
686686
return cat(a, new_part; dims = 1)
687687
end
688688

689-
function append!(backend, a, b::AbstractArray, lb)
689+
function append!(backend, a, b::AbstractVector, lb)
690690
lb == 0 && return a
691691
arr = convert_array(b, backend)
692-
col = vec(arr)
693-
return cat(a, _expand_to_shape(col, _trailing_dims(a)); dims = 1)
692+
return cat(a, _expand_to_shape(arr, _trailing_dims(a)); dims = 1)
693+
end
694+
function append!(backend, a, b::AbstractMatrix, lb)
695+
lb == 0 && return a
696+
arr = convert_array(b, backend)
697+
return cat(a, arr; dims = 1)
694698
end
695699

696700
function append!(backend, a, b::Base.Generator, lb)

0 commit comments

Comments
 (0)