Skip to content

Bug fix in chunk-size controlled AD #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/differentiation/compute_jacobian_ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function generate_chunked_partials(x,color,::Val{N}) where N

for color_i in 1:maximum(color)
for j in 1:length(x)
partials[j, color_i] = color[j] == color_i
partials[j,color_i] = color[j]==color_i
end
end

Expand Down Expand Up @@ -100,7 +100,6 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
partial_i = p[i]
t .= Dual{typeof(f)}.(x, partial_i)
f(fx,t)

if J isa SparseMatrixCSC
rows_index, cols_index, val = findnz(J)
for j in 1:chunksize
Expand All @@ -111,15 +110,12 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
end
end
color_i += 1
(color_i > maximum(color)) && continue
end
else
for j in 1:chunksize
col_index = (i-1)*chunksize + j
J[:, col_index] .= partials.(fx, color_i)
color_i += 1
if color_i == maximum(color) + 1
color_i = 1
end
J[:, col_index] .= partials.(fx, j)
end
end
end
Expand Down