提交 9f665737 authored 作者: abergeron's avatar abergeron

Merge pull request #4025 from nouiz/corrmm_segfault

Fix segfault for very big size. I did some timing and there is no di…
...@@ -86,7 +86,7 @@ class BaseCorrMM(gof.Op): ...@@ -86,7 +86,7 @@ class BaseCorrMM(gof.Op):
def c_code_cache_version(self): def c_code_cache_version(self):
# raise this whenever modifying any of the support_code_files # raise this whenever modifying any of the support_code_files
return (1, 0) return (1, 1)
def c_support_code_apply(self, node, nodename): def c_support_code_apply(self, node, nodename):
# REMEMBER TO RAISE c_code_cache_version when changing any of # REMEMBER TO RAISE c_code_cache_version when changing any of
......
...@@ -46,10 +46,10 @@ void im2col(const %(float_type)s* data_im, const int channels, ...@@ -46,10 +46,10 @@ void im2col(const %(float_type)s* data_im, const int channels,
int h_pad = h * stride_h - pad_h + h_offset; int h_pad = h * stride_h - pad_h + h_offset;
int w_pad = w * stride_w - pad_w + w_offset; int w_pad = w * stride_w - pad_w + w_offset;
if (h_pad >= 0 && h_pad < height && w_pad >= 0 && w_pad < width) if (h_pad >= 0 && h_pad < height && w_pad >= 0 && w_pad < width)
data_col[(c * height_col + h) * width_col + w] = data_col[(npy_intp)(c * height_col + h) * width_col + w] =
data_im[(c_im * height + h_pad) * width + w_pad]; data_im[(npy_intp)(c_im * height + h_pad) * width + w_pad];
else else
data_col[(c * height_col + h) * width_col + w] = 0.; data_col[(npy_intp)(c * height_col + h) * width_col + w] = 0.;
} }
} }
} }
...@@ -75,8 +75,8 @@ void col2im(const %(float_type)s* data_col, const int channels, ...@@ -75,8 +75,8 @@ void col2im(const %(float_type)s* data_col, const int channels,
int h_pad = h * stride_h - pad_h + h_offset; int h_pad = h * stride_h - pad_h + h_offset;
int w_pad = w * stride_w - pad_w + w_offset; int w_pad = w * stride_w - pad_w + w_offset;
if (h_pad >= 0 && h_pad < height && w_pad >= 0 && w_pad < width) if (h_pad >= 0 && h_pad < height && w_pad >= 0 && w_pad < width)
data_im[(c_im * height + h_pad) * width + w_pad] += data_im[(npy_intp)(c_im * height + h_pad) * width + w_pad] +=
data_col[(c * height_col + h) * width_col + w]; data_col[(npy_intp)(c * height_col + h) * width_col + w];
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论