Exceptional behavior when parameter groups is not equal to 1

I’ m runing the code:

import torch
te_y = torch.ones([1,4,10])    # torch.Size([1, 4, 10])
operator = torch.tensor([[[1.0, -2.0, 1.0]]]) # torch.Size([1, 1, 3])
torch.nn.functional.conv1d(te_y, operator, padding=1, groups=4)

get the error reporting with:

Given groups=4, expected weight to be at least 4 at dimension 0, but got weight of size [1, 1, 3] instead

But as the docs say:

It should be no error. I want to preform the 1d conv in the each 4 in_channels with the same weight by set the groups as the 4.

In the code you actually pass groups=1 to nn.functional.conv1d, did you mean to write groups=2?

Just to clarify, what part of the docs suggest there should be no error? If groups=2 and in_channels=4, then the 2nd dimension of weight needs to be 2 (=in_channels/groups), in your case it is 1.

For instance, this works:

import torch
B  = 1  # minibatch
IC = 4  # in-channels
G  = 2  # groups
OC = 2  # out-channels, multiple of groups
N  = 10 # spatial dimension of orig tensor
W  = 3  # spatial dimension of convolution

te_y = torch.ones([B, IC, N])
operator = torch.rand(OC, IC//G, W)
torch.nn.functional.conv1d(te_y, operator, padding=1, groups=G)

Output:
tensor([[[2.7952, 4.2234, 4.2234, 4.2234, 4.2234, 4.2234, 4.2234, 4.2234,
          4.2234, 2.6473],
         [1.9053, 3.6016, 3.6016, 3.6016, 3.6016, 3.6016, 3.6016, 3.6016,
          3.6016, 3.0767]]])

Thanks for your answer! I know how to revised my code. I should to set the out_channel to the 4.
It’s my fault to explain my question wrongly and I have revised the question. I want to perform the 1d conv in the each 4 in_channels with the groups = 4.
Thank you again.