I cannot reproduce this issue using this code snippet:
device = 'cuda'
batch_meshgrid = torch.empty(4, 2, 24, 24).uniform_(-1, 1).to(device)

y_c = batch_meshgrid[:, 0, :, :].unsqueeze(1)
x_c = batch_meshgrid[:, 1, :, :].unsqueeze(1)
sobel_x_filter = 1 / 4 * torch.tensor([[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]).reshape(1, 1, 3, 3).to(device)
sobel_y_filter = sobel_x_filter.permute(0, 1, 3, 2).to(device)


filtered_y_y = F.conv2d(y_c, sobel_y_filter, stride=1, padding=1)
filtered_y_x = F.conv2d(y_c, sobel_x_filter, stride=1, padding=1)
filtered_x_y = F.conv2d(x_c, sobel_y_filter, stride=1, padding=1)
filtered_x_x = F.conv2d(x_c, sobel_x_filter, stride=1, padding=1)

Det = torch.abs(filtered_y_y * filtered_x_x - filtered_y_x * filtered_x_y)
print(Det.shape)

Could you post the shapes you’ve used to run into this issue?