Say I have a 2D signal which is basically 4 channels of 1d signals and each 1d signal is of shape 100. So my input is of shape 100x4. Now I have a single kernel, torch.nn.Conv1d() and I want to apply the same kernel to each of the channels individually. What is the most efficient way to do this?
The method I have come up is to use list, but I feel there should be more elegant way to do the same. My code is
out_list = []
for i in channels:
    # inp is of shape batch_size x channels (4) x vector len (100)
   out = conv(inp[:, [i], :])
    out_list.append(out)
o1 = torch.cat(out_list,0)
o1 = o1.view(num_channels, batch_size, vector_len)
o1 = o1.permute(1,0,2).contiguous()
return o1

Would be glad if there is a better implementation for the same (or if there is any bug in the presented code). Thank you