I get an error when I want to use nn.Conv1d on iOS using libtorch. I have this simple model:
class Conv1dTestModel(nn.Module):
def __init__(self):
super(Conv1dTestModel, self).__init__()
self.conv1d_stack = nn.Sequential(
nn.Conv1d(1, 64, kernel_size=128, padding=8),
nn.MaxPool1d(kernel_size=5, padding=1),
)
def forward(self, x):
N, C, L = x.shape[0], x.shape[1], x.shape[2]
return self.conv1d_stack(x)
N = 16
L = 1024
C = 1
T = torch.rand(N, C, L)
model = Conv1dTestModel()
model(T).shape
torch.jit.script(model.eval().to('cpu')).save('Conv1dTestModel_scripted.pt')
When trying to run this model on iOS with a random tensor of shape {16, 1, 1024} I get the following error message
NNPACK SpatialConvolution_updateOutput failed
The above operation failed in interpreter.
Traceback (most recent call last):
File "/home/dnagy/anaconda3/envs/pt11/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 201
self.weight, self.bias, self.stride,
_single(0), self.dilation, self.groups)
return F.conv1d(input, self.weight, self.bias, self.stride,
~~~~~~~~ <--- HERE
self.padding, self.dilation, self.groups)
Serialized File "code/__torch__/torch/nn/modules/conv.py", line 23
_8 = _2
else:
_8 = torch.conv1d(input, self.weight, self.bias, [1], [8], [1], 1)
~~~~~~~~~~~~ <--- HERE
return _8
I’m using PyTorch 1.4.0