Skip to content

Commit 5ffe97b

Browse files
committed
Fix boundary check in conv2d_implicit_kernel to include channel limits
1 parent 6d84cbb commit 5ffe97b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ggml/src/ggml-cuda/conv2d-implicit.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static __global__ void conv2d_implicit_kernel(const float * __restrict__ input,
116116
int curH = posh_ori[i] + curR * param.d_h; // input h
117117
int curW = posw_ori[i] + curS * param.d_w; // input w
118118
int inOffsetTmp = curC * inChannelOffset + curH * param.w + curW;
119-
if (curH >= 0 && curW >= 0 && curW < param.w && curH < param.h)
119+
if (curH >= 0 && curW >= 0 && curW < param.w && curH < param.h && curC < param.c)
120120
{
121121
input_ldg_reg[i] = input[inOffset + inOffsetTmp];
122122
}
@@ -175,7 +175,7 @@ static __global__ void conv2d_implicit_kernel(const float * __restrict__ input,
175175
int curH = posh_ori[i] + curR * param.d_h; // input h
176176
int curW = posw_ori[i] + curS * param.d_w; // input w
177177
int inOffsetTmp = curC * inChannelOffset + curH * param.w + curW;
178-
if (curH >= 0 && curW >= 0 && curW < param.w && curH < param.h)
178+
if (curH >= 0 && curW >= 0 && curW < param.w && curH < param.h && curC < param.c)
179179
{
180180
input_ldg_reg[i] = input[inOffset + inOffsetTmp];
181181
}

0 commit comments

Comments
 (0)