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

Commit e5d905a

Browse files
author
Langwen Huang
committed
fix issue of inconsistent size
1 parent a89c672 commit e5d905a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/differentiation/compute_jacobian_ad.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ function forwarddiff_color_jacobian(f,x::AbstractArray{<:Number},jac_cache::Forw
120120
for j in 1:chunksize
121121
col_index = (i-1)*chunksize + j
122122
(col_index > ncols) && return J
123-
J = J + mapreduce(i -> i==col_index ? partials.(vec(fx), j) : zeros(nrows), hcat, 1:ncols)
123+
Ji = mapreduce(i -> i==col_index ? partials.(vec(fx), j) : zeros(nrows), hcat, 1:ncols)
124+
J = J + (size(Ji)!=size(J) ? reshape(Ji,size(J)) : Ji) #branch when size(dx) == (1,) => size(Ji) == (1,) while size(J) == (1,1)
124125
end
125126
end
126127
end

0 commit comments

Comments
 (0)