Skip to content

Commit 68bd895

Browse files
committed
bounds check with checkindex
1 parent cf4e230 commit 68bd895

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/NNlibCUDA/src/fold.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function unfold_kernel!(col::AbstractArray{T}, x, col_size, input_size, output_s
1414
end
1515

1616
# check out of bounds
17-
if any((w, h, d) .<= 0 .| (w, h, d) .> input_size)
17+
if !all(checkindex.(Bool, UnitRange.(1, input_size), (w, h, d)))
1818
col[i, kw, kh, kd, c, b] = T(0)
1919
return nothing
2020
end
@@ -37,7 +37,7 @@ function fold_kernel!(x::AbstractArray{T}, col, col_size, input_size, output_siz
3737
w, h, d = @. ((w, h, d) - 1)*stride - pad_lo + 1 + ((kw, kh, kd) - 1)*dilation
3838

3939
# check out of bounds
40-
if any((w, h, d) .<= 0 .| (w, h, d) .> input_size)
40+
if !all(checkindex.(Bool, UnitRange.(1, input_size), (w, h, d)))
4141
return nothing
4242
end
4343

0 commit comments

Comments
 (0)