Access to a single step of a conv2d

Hi, i want to acces to a single result of the conv2d Pytorch. In particular for a certain set of neurons, i would like to repeat the computation kernel*input feature map.
i try to recupute manually each multiplication and then the summation but the program takes too much time w.r.t the one without the repeatition.
Which function can i use to doo this quickly? From the Pytorch documentation i show the ‘group’ parameter for Cov2d , but i don’t understand whether this can help me.

I’m not sure what your actual use case is, but if you are trying to implement a convolution “manually” via a matrix multiplication, take a look at nn.Unfold, which gives an example of a conv in the docs.

1 Like

Can you explain to me what is the role of ‘groups’ for Conv2d? Thaks so much

By default a conv kernel will use all input channels of the incoming activation to compute the activation map. If you use the groups argument, the kernel’s channels as well as the input channels will be “split” so that the convolution operation would be equivalent to having multiple conv layers side by side which process only the corresponding subset of the input activation. The result will be concatenated afterwards.

E.g. if groups=in_channels, each channel of the input activation would get its own set of conv filters.