SIGSEGV when applying Conv1d with padding

Hi!
I’m trying to apply 1D convolution with padding to preserve input size.
Everything is ok with kernel size = 3 and padding = 1, but pytorch fails with SIGSEGV error when kernel size = 5, padding = 2 and input tensor contains squence of length 1. I’m not using CUDA. Is it a bug?

Code to reproduce the problem:

from torch.autograd import Variable
import torch.nn as nn
data = Variable(th.randn(1, 16, 1))
conv_ok = nn.Conv1d(
    in_channels=16,
    out_channels=16,
    kernel_size=3,
    padding=1)
conv_not_ok = nn.Conv1d(
    in_channels=16,
    out_channels=16,
    kernel_size=5,
    padding=2)

c1 = conv_ok(data)
c2 = conv_not_ok(data)

Hi,

I can reproduce the problem and its definitely a bug in our unfold code.
I will send a PR to fix that today.

Sorry for the inconvenience.

I think the bug is here and an explicit cast might solve the problem.

Yes it is.
I will check the whole function as I’m not sure why lpad and rpad are size_t and not int here…