Since you are pooling twice, the spatial dimensions will be 32/2/2=8. Your linear layer should thus take 12*8*8 input features.
If you don’t want to calculate it, you could also print the shape of your tensor before the view operation and just use this sizes.