import torch
from torch import nn
from torch.nn import functional as F
for _ in range(1000):
    groups = 12
    conv = nn.Conv2d(12, 12, 3, 1, 1, groups=groups, bias=False)
    kernels = torch.stack(conv.weight.chunk(groups, 0))
    # Reference
    x = torch.randn(1, 12, 24, 24)
    out = conv(x)
    # Comparison
    o1 = F.conv2d(x[:, :1], kernels[0], padding=1)
    if not torch.allclose(o1, out[:, :2]):
        print('False')

still…