I’ll answer my own query
A1 = A.view(A.shape[0]*A.shape[1], A.shape[2], A.shape[3]).unsqueeze(0)

out = F.conv2d(A1, B, groups=B.shape[0]).permute(1, 0, 2 ,3)
print(out.shape)

# Result: [5, 1, 7, 7]

Verified by computing in batch and individually for each of the 5 entries in the batch and comparing the results.