Skip to content
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

Remove or sanitize inbounds #304

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ext/SparseDiffToolsPolyesterExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function polyesterforwarddiff_color_jacobian(J::AbstractMatrix{<:Number}, f::F,
if colorvec[cols_index[idx]] == color_i]
rows_index_c = rows_index[pick_inds]
cols_index_c = cols_index[pick_inds]
@inbounds @simd for i in 1:length(rows_index_c)
@simd for i in eachindex(rows_index_c, cols_index_c)
J[rows_index_c[i], cols_index_c[i]] = dx[rows_index_c[i]]
end
color_i += 1
Expand Down
4 changes: 2 additions & 2 deletions src/coloring/matrix2graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function matrix2graph(sparse_matrix::AbstractSparseMatrix{<:Number},

if partition_by_rows
rows_by_cols = _rows_by_cols(rows_index, cols_index)
@inbounds for (cur_row, cur_col) in zip(rows_index, cols_index)
for (cur_row, cur_col) in zip(rows_index, cols_index)
if !isempty(rows_by_cols[cur_col])
for next_row in rows_by_cols[cur_col]
if next_row < cur_row
Expand All @@ -56,7 +56,7 @@ function matrix2graph(sparse_matrix::AbstractSparseMatrix{<:Number},
end
else
cols_by_rows = _cols_by_rows(rows_index, cols_index)
@inbounds for (cur_row, cur_col) in zip(rows_index, cols_index)
for (cur_row, cur_col) in zip(rows_index, cols_index)
if !isempty(cols_by_rows[cur_row])
for next_col in cols_by_rows[cur_row]
if next_col < cur_col
Expand Down
6 changes: 3 additions & 3 deletions src/differentiation/compute_jacobian_ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
partial_i = p[i]

if vect isa Array
@inbounds @simd ivdep for j in eachindex(vect)
@inbounds @simd ivdep for j in eachindex(vect, vecx, partial_i)
vect[j] = eltype(t)(vecx[j], ForwardDiff.Partials(partial_i[j]))
end
else
Expand All @@ -377,7 +377,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
if !(sparsity isa Nothing)
for j in 1:chunksize
if dx isa Array
@inbounds @simd for k in eachindex(dx)
@inbounds @simd for k in eachindex(dx, fx)
dx[k] = partials(fx[k], j)
end
else
Expand Down Expand Up @@ -429,7 +429,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
col_index = (i - 1) * chunksize + j
(col_index > ncols) && return J
if J isa Array
@inbounds @simd for k in 1:size(J, 1)
@simd for k in axes(J, 1)
J[k, col_index] = partials(vecfx[k], j)
end
else
Expand Down
Loading