Currently the number of input features to fc1 is set as 512*512=262144, which won’t work in this architecture.
Note that you are using pooling layers, which decrease the spatial size with a factor of 2 in your setup.
Also you are not using any padding in the conv layers, which will reduce the spatial size by 2 pixels using a kernel size of 3.
Here is the working and annotated model:
class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(3, 32, 3)
        self.pool = nn.MaxPool2d(2, 2)
        self.conv2 = nn.Conv2d(32, 64, 3)
        self.fc1 = nn.Linear(64*126*126,1500)
        self.fc2 = nn.Linear(1500, 3)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))  # output size: [batch_size, 32, 255, 255]
        x = self.pool(F.relu(self.conv2(x)))  # output size: [batch_size, 64, 126, 126]
        
        x = x.view(x.size(0), -1)  # output size: [batch_size, 64*126*126]
        x = F.relu(self.fc1(x))
        x = self.fc2(x)
        return x


x = torch.randn(1, 3, 512, 512)
model = Net()
output = model(x)