Convolution between >3d tensor and 1d kernel?

I have two tensors, A and B, with sizes

A.size()
>> torch.Size([10, 5, 5, 5])

B.size()
>> torch.Size([4])

In scipy it’s possible to perform a convolution of the two along a specific axis by

scipy.ndimage.convolve1d(A, B, axis=0)

Is this possible with pytorch? I’ve been trying to make it work with torch.nn.functional.conv1d, but haven’t succeded.

Thanks a lot for your time!

Best regards

I think pad + unfold + matmul + slice may work.

@Eta_C I’m sorry, but I can’t follow. Would you elaborate a little?