One approach would be to create a new custom model class by deriving from alexnet as the base class and add print statements to the forward method.
However, this might be too cumbersome just to get the output shapes.
I usually just register hooks for all modules, which seems to work fine for some quick debugging:
model = models.alexnet()

for name, child in model.named_modules():
    if isinstance(child, nn.Module):
        child.register_forward_hook(
            lambda m, inp, out, name=name: print('{} output shape {}'.format(name, out.shape)))

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

> features.0 output shape torch.Size([1, 64, 55, 55])
features.1 output shape torch.Size([1, 64, 55, 55])
features.2 output shape torch.Size([1, 64, 27, 27])
features.3 output shape torch.Size([1, 192, 27, 27])
features.4 output shape torch.Size([1, 192, 27, 27])
features.5 output shape torch.Size([1, 192, 13, 13])
features.6 output shape torch.Size([1, 384, 13, 13])
features.7 output shape torch.Size([1, 384, 13, 13])
features.8 output shape torch.Size([1, 256, 13, 13])
features.9 output shape torch.Size([1, 256, 13, 13])
features.10 output shape torch.Size([1, 256, 13, 13])
features.11 output shape torch.Size([1, 256, 13, 13])
features.12 output shape torch.Size([1, 256, 6, 6])
features output shape torch.Size([1, 256, 6, 6])
avgpool output shape torch.Size([1, 256, 6, 6])
classifier.0 output shape torch.Size([1, 9216])
classifier.1 output shape torch.Size([1, 4096])
classifier.2 output shape torch.Size([1, 4096])
classifier.3 output shape torch.Size([1, 4096])
classifier.4 output shape torch.Size([1, 4096])
classifier.5 output shape torch.Size([1, 4096])
classifier.6 output shape torch.Size([1, 1000])
classifier output shape torch.Size([1, 1000])
 output shape torch.Size([1, 1000])