Why not just do a M spatial convolution and then separate out the channels of the output?
Moutput = F.conv2d(input, Mweight, padding=1) # where Mweight has shape M x C x 3 x 3
for i in range(M):
    output[i] = Moutput[:, i]