How to run functional.conv2d with different weights for each sample in batch?

I have different weights for each sample in batch, so, how can I run conv2d with custom weights for each sample on GPU simultaneously? According to functional.conv2d, it convolves the same weights on each input. The slower way I found is to run functional.conv2d in a for loop over each data sample.

Thanks

You could move the batch dimension of the input into the channels and use the groups argument of F.conv2d.