Okay. Let’s see, you have an image of size (h, w, c), which in your case should be a square RGB image, so h=w – in the examples below I will assume H_in = 32 --, c=3. Your input volume is of shape (n, n, 3). First, you apply 32 filters of size (3, 3), with stride 2 and padding 1.
The dimension of the new output is given by the formula, from Pytorch Conv2d docs: 
image717×211 21.8 KB
 - In your case, Hout = Wout and padding/kernel size are the same for H and W. Dilation is 1 by default.
So, n_out is floor((32+21-12-1)/2 + 1) =  16. Your output volume after first conv layer is (16, 16, 32) .
The second layer applies 64 filters of shape (3, 3), with stride 2 and padding 1.
So, n_out is floor((16+21-12-1)/2 + 1)  = 8. Your output volume after second conv layer is (8, 8, 64).
The last layer applies 21 (or actually 128, after my last edit) filters of shape (3, 3), with stride 2 and padding 1.
So, n_out is floor((8+21-12-1)/2 + 1)  = 4. Your output after last conv is (4, 4, 128)
Now with MaxPool2d, if kernel size = 1, that won’t do anything at all. It takes the maximum in a (1, 1) square and puts it in the result. You should go for a kernel size of 2 perhaps, but don’t forget to set the stride to 1. From PyTorch [nn.MaxPool2d docs:] (MaxPool2d — PyTorch 1.8.1 documentation).

image760×201 21.9 KB

Based on your Pooling kernel size, you have 4x4x128 or 3x3x128 total activations/values/neurons, which you flatten in a single 2048 or 1152-dimensional vector. That number needs to be the same as the first input to your linear layer.
I hope that this is the info you need.